| | |
| | | package com.lf.server.controller.all; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.metadata.OrderItem; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.lf.server.aspect.SysLog; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.ctrl.IdNameEntity; |
| | | import com.lf.server.entity.ctrl.TabEntity; |
| | | import com.lf.server.entity.data.DictEntity; |
| | | import com.lf.server.entity.data.DomainEntity; |
| | | import com.lf.server.helper.AesHelper; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.mapper.all.BasicMapper; |
| | | import com.lf.server.mapper.all.GeomBaseMapper; |
| | | import com.lf.server.service.all.BaseQueryService; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | |
| | | @GetMapping({"/selectCount"}) |
| | | public ResponseMsg<Long> selectCount(String name, String filter, String wkt, Integer srid) { |
| | | try { |
| | | BaseMapper baseMapper = baseQueryService.getBaseMapper(name); |
| | | BasicMapper baseMapper = baseQueryService.getBasicMapper(name); |
| | | if (baseMapper == null) { |
| | | return fail("查询对象不存在", null); |
| | | } |
| | | |
| | | QueryWrapper wrapper = new QueryWrapper(); |
| | | baseQueryService.addFilterWrapper(baseMapper, wrapper, filter); |
| | | baseQueryService.addFilterWrapper(wrapper, filter); |
| | | baseQueryService.addGeomWrapper(baseMapper, wrapper, wkt, srid); |
| | | |
| | | long count = baseMapper.selectCount(wrapper); |
| | |
| | | @GetMapping(value = "/selectByPage") |
| | | public ResponseMsg<List<Object>> selectByPage(String name, String filter, String wkt, Integer srid, Integer pageIndex, Integer pageSize) { |
| | | try { |
| | | BaseMapper baseMapper = baseQueryService.getBaseMapper(name); |
| | | BasicMapper baseMapper = baseQueryService.getBasicMapper(name); |
| | | if (baseMapper == null) { |
| | | return fail("查询对象不存在", null); |
| | | } |
| | | |
| | | QueryWrapper wrapper = new QueryWrapper(); |
| | | baseQueryService.addFilterWrapper(baseMapper, wrapper, filter); |
| | | baseQueryService.addFilterWrapper(wrapper, filter); |
| | | baseQueryService.addGeomWrapper(baseMapper, wrapper, wkt, srid); |
| | | |
| | | Page<Object> page = new Page<>(pageIndex, pageSize); |
| | |
| | | return fail("查询对象不存在", null); |
| | | } |
| | | |
| | | String wkt = baseMapper.selectWktById(gid); |
| | | String tab = baseQueryService.getTabName(baseMapper); |
| | | if (StringHelper.isNull(tab)) { |
| | | return fail("查询对象不存在", null); |
| | | } |
| | | |
| | | String wkt = baseMapper.selectWktById(tab, gid); |
| | | if (!StringHelper.isEmpty(wkt)) { |
| | | wkt = AesHelper.encrypt(wkt); |
| | | } |
| | |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "模糊搜索字段") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "映射名称", dataType = "String", paramType = "query", example = "dlgAgnp"), |
| | | @ApiImplicitParam(name = "field", value = "字段", dataType = "String", paramType = "query", example = "name"), |
| | | @ApiImplicitParam(name = "value", value = "值", dataType = "String", paramType = "query", example = "'县'") |
| | | }) |
| | | @GetMapping(value = "/selectFieldFuzzy") |
| | | public ResponseMsg<List<String>> selectFieldFuzzy(String name, String field, String value) { |
| | | try { |
| | | BasicMapper baseMapper = baseQueryService.getBasicMapper(name); |
| | | if (baseMapper == null) { |
| | | return fail("查询对象不存在", null); |
| | | } |
| | | |
| | | String tab = baseQueryService.getTabName(baseMapper); |
| | | if (StringHelper.isNull(tab)) { |
| | | return fail("查询对象不存在", null); |
| | | } |
| | | if (StringHelper.isEmpty(field) || StringHelper.isSqlInjection(field)) { |
| | | return fail("查询字段不正确", null); |
| | | } |
| | | if (!StringHelper.isEmpty(value)) { |
| | | value = value.trim().replace("'", ""); |
| | | } |
| | | |
| | | value = StringHelper.getLikeStr2(value); |
| | | List<String> rs = baseMapper.selectFieldFuzzy(tab, field, value); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "模糊搜索用户") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "用户名", dataType = "String", paramType = "query", example = "室") |
| | | }) |
| | | @GetMapping(value = "/selectUserFuzzy") |
| | | public ResponseMsg<List<IdNameEntity>> selectUserFuzzy(String name) { |
| | | try { |
| | | List<IdNameEntity> rs = baseQueryService.selectUserFuzzy(name); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "模糊搜索单位") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "单位名", dataType = "String", paramType = "query", example = "司") |
| | | }) |
| | | @GetMapping(value = "/selectDepFuzzy") |
| | | public ResponseMsg<List<IdNameEntity>> selectDepFuzzy(String name) { |
| | | try { |
| | | List<IdNameEntity> rs = baseQueryService.selectDepFuzzy(name); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询所有表") |
| | | @GetMapping(value = "/selectTabs") |
| | | public ResponseMsg<List<TabEntity>> selectTabs() { |
| | | try { |
| | | List<TabEntity> list = baseQueryService.selectTabs(); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询字段信息") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "映射名称", dataType = "String", paramType = "query", example = "dlgAgnp") |
| | | }) |
| | | @GetMapping(value = "/selectFields") |
| | | public ResponseMsg<List<DictEntity>> selectFields(String name) { |
| | | try { |
| | | BasicMapper baseMapper = baseQueryService.getBasicMapper(name); |
| | | if (baseMapper == null) { |
| | | return fail("查询对象不存在", null); |
| | | } |
| | | |
| | | String tabName = baseQueryService.getTabName(baseMapper); |
| | | if (tabName == null) { |
| | | return null; |
| | | } |
| | | |
| | | String[] strs = tabName.split("."); |
| | | List<DictEntity> list = baseQueryService.selectFields(strs[0], strs[1]); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询值域信息") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "映射名称", dataType = "String", paramType = "query", example = "dlgAgnp") |
| | | }) |
| | | @GetMapping(value = "/selectDomains") |
| | | public ResponseMsg<List<DomainEntity>> selectDomains(String name) { |
| | | try { |
| | | BasicMapper baseMapper = baseQueryService.getBasicMapper(name); |
| | | if (baseMapper == null) { |
| | | return fail("查询对象不存在", null); |
| | | } |
| | | |
| | | String tabName = baseQueryService.getTabName(baseMapper); |
| | | if (tabName == null) { |
| | | return null; |
| | | } |
| | | |
| | | String[] strs = tabName.split("."); |
| | | List<DomainEntity> list = baseQueryService.selectDomains(strs[0], strs[1]); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | } |