月球大数据地理空间分析展示平台-【后端】-月球后台服务
1
13693261870
2024-11-11 fee67ca8a0760315047a52fc4101a8f4f80b7a7f
src/main/java/com/moon/server/controller/sys/ResController.java
@@ -5,6 +5,7 @@
import com.moon.server.entity.all.ResponseMsg;
import com.moon.server.entity.sys.ResEntity;
import com.moon.server.entity.sys.UserEntity;
import com.moon.server.helper.StringHelper;
import com.moon.server.service.all.PermsService;
import com.moon.server.service.all.UploadAttachService;
import com.moon.server.service.sys.ResService;
@@ -21,10 +22,7 @@
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
 * 资源管理
 * @author WWW
 */
@SuppressWarnings("ALL")
@Api(tags = "运维管理\\资源管理")
@RestController
@RequestMapping("/res")
@@ -44,63 +42,29 @@
    private final static String TAB_NAME = "lf.sys_res";
    @SysLog()
    @ApiOperation(value = "查询记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", required = false, example = "")
    })
    @GetMapping({"/selectCount"})
    public ResponseMsg<Integer> selectCount(String name) {
        try {
            int count = resService.selectCount(name);
            return success(count);
        } catch (Exception ex) {
            return fail(ex, -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = ""),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"),
            @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectByPage")
    public ResponseMsg<List<ResEntity>> selectByPage(String name, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            List<ResEntity> rs = resService.selectByPage(name, pageSize, pageSize * (pageIndex - 1));
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
    @SysLog()
    @ApiOperation(value = "分页查询并返回记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = ""),
            @ApiImplicitParam(name = "status", value = "状态", dataType = "Integer", paramType = "query", example = ""),
            @ApiImplicitParam(name = "category", value = "服务类别", dataType = "Integer", paramType = "query", example = ""),
            @ApiImplicitParam(name = "type", value = "服务类型", dataType = "Integer", paramType = "query", example = ""),
            @ApiImplicitParam(name = "data", value = "数据类型", dataType = "Integer", paramType = "query", example = ""),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"),
            @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectByPageAndCount")
    public ResponseMsg<List<ResEntity>> selectByPageAndCount(String name, Integer pageSize, Integer pageIndex) {
    public ResponseMsg<List<ResEntity>> selectByPageAndCount(String name, Integer status, Integer category, Integer type, Integer data, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            int count = resService.selectCount(name);
            int count = resService.selectCount(name, status, category, type, data);
            if (count == 0) {
                return success(0, null);
            }
            List<ResEntity> rs = resService.selectByPage(name, pageSize, pageSize * (pageIndex - 1));
            List<ResEntity> rs = resService.selectByPage(name, status, category, type, data, pageSize, pageSize * (pageIndex - 1));
            return success(count, rs);
        } catch (Exception ex) {
@@ -136,6 +100,19 @@
    }
    @SysLog()
    @ApiOperation(value = "查询所有")
    @GetMapping(value = "/selectAll")
    public ResponseMsg<List<ResEntity>> selectAll() {
        try {
            List<ResEntity> list = resService.selectAll();
            return success(list);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
    @SysLog()
    @ApiOperation(value = "根据ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", dataType = "int", paramType = "query", example = "1")
@@ -162,12 +139,11 @@
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                entity.setCreateUser(ue.getId());
                entity.setDepid(ue.getDepcode());
            }
            permsService.clearPermsCache();
            int count = resService.insert(entity);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -187,13 +163,12 @@
            if (ue != null) {
                for (ResEntity entity : list) {
                    entity.setCreateUser(ue.getId());
                    entity.setDepid(ue.getDepcode());
                }
            }
            permsService.clearPermsCache();
            int count = resService.inserts(list);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -209,10 +184,8 @@
    @GetMapping(value = "/delete")
    public ResponseMsg<Integer> delete(int id) {
        try {
            permsService.clearPermsCache();
            int count = resService.delete(id);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -232,10 +205,9 @@
                return fail("id数组不能为空", -1);
            }
            int count = resService.deletes(ids);
            if (count > 0) {
                permsService.clearResCache();
            }
            permsService.clearPermsCache();
            String strs = StringHelper.join(ids, ",");
            int count = resService.deletes(strs);
            return success(count);
        } catch (Exception ex) {
@@ -255,12 +227,11 @@
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                entity.setUpdateUser(ue.getId());
                entity.setDepid(ue.getDepcode());
            }
            permsService.clearPermsCache();
            int count = resService.update(entity);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -281,13 +252,12 @@
            if (ue != null) {
                for (ResEntity entity : list) {
                    entity.setUpdateUser(ue.getId());
                    entity.setDepid(ue.getDepcode());
                }
            }
            permsService.clearPermsCache();
            int count = resService.updates(list);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {