管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-12-19 5c9f31377e3f4dbdb20a5f50f5aaf6fdbbfa87f5
src/main/java/com/lf/server/controller/all/BaseQueryController.java
@@ -10,17 +10,21 @@
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.entity.sys.AttachEntity;
import com.lf.server.helper.AesHelper;
import com.lf.server.helper.ClassHelper;
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 com.lf.server.service.sys.AttachService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@@ -30,12 +34,15 @@
 */
public class BaseQueryController extends BaseController {
    @Autowired
    AttachService attachService;
    @Autowired
    BaseQueryService baseQueryService;
    @SysLog()
    @ApiOperation(value = "查询记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "映射名称", dataType = "String", paramType = "query", example = "dlgAgnp"),
            @ApiImplicitParam(name = "name", value = "映射名称", dataType = "String", paramType = "query", example = "dlgagnp"),
            @ApiImplicitParam(name = "filter", value = "过滤条件", dataType = "String", paramType = "query", example = "gid >= 50 and name like '县' and objectid < 5000.0"),
            @ApiImplicitParam(name = "wkt", value = "WKT(著名文本)", dataType = "String", paramType = "query", example = "gAPpDbZ53XfoQfvT8dj/uhBWX5os8kBJQ1LrNvH3VX7byFQdUJMPiEr8Fkj0q2i1pw+L8KFrvR0MLXq2xaO21nlQQXmEPofJxpDQZwEWUIFZsToXo1kLRD3t6WQezxWB8YTzXHM20Ba73x/ZuuezVhOFOq1U8HKf1dXQdv7gBzEB6fWMmFDc3FuH8GDDHv3LfT86Gio9VgMO6ohlrUdf3ZKtTHeLSuzGF4t0RZuX97YBNo25IIzpeTfRTXBxfdxA")
    })
@@ -43,7 +50,7 @@
    @PostMapping(value = "/selectCount")
    public ResponseMsg<Long> selectCount(String name, String filter, String wkt) {
        try {
            BasicMapper baseMapper = baseQueryService.getBasicMapper(name);
            BasicMapper baseMapper = ClassHelper.getBasicMapper(name);
            if (baseMapper == null) {
                return fail("查询对象不存在", null);
            }
@@ -63,7 +70,7 @@
    @SysLog()
    @ApiOperation(value = "分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "映射名称", dataType = "String", paramType = "query", example = "dlgAgnp"),
            @ApiImplicitParam(name = "name", value = "映射名称", dataType = "String", paramType = "query", example = "dlgagnp"),
            @ApiImplicitParam(name = "filter", value = "过滤条件", dataType = "String", paramType = "query", example = ""),
            @ApiImplicitParam(name = "wkt", value = "WKT(著名文本)", dataType = "String", paramType = "query", example = ""),
            //@ApiImplicitParam(name = "srid", value = "空间引用标识符", dataType = "Integer", paramType = "query", example = "4326"),
@@ -74,7 +81,7 @@
    @PostMapping(value = "/selectByPage")
    public ResponseMsg<List<Object>> selectByPage(String name, String filter, String wkt, Integer pageIndex, Integer pageSize) {
        try {
            BasicMapper baseMapper = baseQueryService.getBasicMapper(name);
            BasicMapper baseMapper = ClassHelper.getBasicMapper(name);
            if (baseMapper == null) {
                return fail("查询对象不存在", null);
            }
@@ -96,18 +103,18 @@
    @SysLog()
    @ApiOperation(value = "根据ID查询WKT")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "映射名称", dataType = "String", paramType = "query", example = "dlgAgnp"),
            @ApiImplicitParam(name = "name", value = "映射名称", dataType = "String", paramType = "query", example = "dlgagnp"),
            @ApiImplicitParam(name = "gid", value = "GID", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectWktById")
    public ResponseMsg<String> selectWktById(String name, Integer gid) {
        try {
            GeomBaseMapper baseMapper = baseQueryService.getGeoBaseMapper(name);
            GeomBaseMapper baseMapper = ClassHelper.getGeoBaseMapper(name);
            if (baseMapper == null) {
                return fail("查询对象不存在", null);
            }
            String tab = baseQueryService.getTabName(baseMapper);
            String tab = BaseQueryService.getTabName(baseMapper);
            if (StringHelper.isNull(tab)) {
                return fail("查询对象不存在", null);
            }
@@ -126,19 +133,19 @@
    @SysLog()
    @ApiOperation(value = "模糊搜索字段")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "映射名称", dataType = "String", paramType = "query", example = "dlgAgnp"),
            @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);
            BasicMapper baseMapper = ClassHelper.getBasicMapper(name);
            if (baseMapper == null) {
                return fail("查询对象不存在", null);
            }
            String tab = baseQueryService.getTabName(baseMapper);
            String tab = BaseQueryService.getTabName(baseMapper);
            if (StringHelper.isNull(tab)) {
                return fail("查询对象不存在", null);
            }
@@ -211,12 +218,12 @@
    @GetMapping(value = "/selectFields")
    public ResponseMsg<List<DictEntity>> selectFields(String name) {
        try {
            BasicMapper baseMapper = baseQueryService.getBasicMapper(name);
            BasicMapper baseMapper = ClassHelper.getBasicMapper(name);
            if (baseMapper == null) {
                return fail("查询对象不存在", null);
            }
            String tabName = baseQueryService.getTabName(baseMapper);
            String tabName = BaseQueryService.getTabName(baseMapper);
            if (tabName == null) {
                return null;
            }
@@ -238,12 +245,12 @@
    @GetMapping(value = "/selectDomains")
    public ResponseMsg<List<DomainEntity>> selectDomains(String name) {
        try {
            BasicMapper baseMapper = baseQueryService.getBasicMapper(name);
            BasicMapper baseMapper = ClassHelper.getBasicMapper(name);
            if (baseMapper == null) {
                return fail("查询对象不存在", null);
            }
            String tabName = baseQueryService.getTabName(baseMapper);
            String tabName = BaseQueryService.getTabName(baseMapper);
            if (tabName == null) {
                return null;
            }
@@ -256,4 +263,45 @@
            return fail(ex.getMessage(), null);
        }
    }
}
    @SysLog()
    @ApiOperation(value = "查询文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tabName", value = "表名", dataType = "String", paramType = "query", example = "lf.sys_style"),
            @ApiImplicitParam(name = "eventid", value = "主键", dataType = "String", paramType = "query", example = "fa25979a5ef8b43ba82a0be35b3fb0d4")
    })
    @GetMapping(value = "/selectFiles")
    public ResponseMsg<List<AttachEntity>> selectFiles(String tabName, String eventid) {
        try {
            if (StringHelper.isEmpty(tabName) || StringHelper.isEmpty(eventid)) {
                return fail("参数不能为空", null);
            }
            List<AttachEntity> list = attachService.selectByTab(tabName, eventid);
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "删除文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "ID数组", dataType = "Integer", paramType = "query", example = "1,2")
    })
    @GetMapping(value = "/deletes")
    public ResponseMsg<Integer> deleteFiles(@RequestParam List<Integer> ids) {
        try {
            if (ids == null || ids.isEmpty()) {
                return fail("id数组不能为空", -1);
            }
            int rows = attachService.deletes(ids);
            return success(rows);
        } catch (Exception ex) {
            return fail(ex.getMessage(), 0);
        }
    }
}