管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-10-29 1b603d3b281d022baed62967d7d7eba63b454ec2
src/main/java/com/lf/server/controller/all/BaseQueryController.java
@@ -1,7 +1,6 @@
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;
@@ -9,6 +8,7 @@
import com.lf.server.entity.all.ResponseMsg;
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;
@@ -38,13 +38,13 @@
    @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);
@@ -68,13 +68,13 @@
    @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);
@@ -101,7 +101,12 @@
                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);
            }
@@ -111,4 +116,36 @@
            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 = "/selectFuzzy")
    public ResponseMsg<List<String>> selectFuzzy(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);
            }
            value = value == null ? StringHelper.getLikeStr("") : StringHelper.getLikeStr(value.replace("'", ""));
            List<String> rs = baseMapper.selectFuzzy(tab, field, value);
            return success(rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
}