月球大数据地理空间分析展示平台-【后端】-月球后台服务
13693261870
2023-07-18 340ed663ca8d8d14f29dc958c0a50103955c879c
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.service.all.PermsService;
import com.moon.server.service.all.UploadAttachService;
import com.moon.server.service.sys.ResService;
import com.moon.server.service.sys.TokenService;
@@ -12,10 +13,10 @@
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.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@@ -28,54 +29,19 @@
@RestController
@RequestMapping("/res")
public class ResController extends BaseController {
    @Autowired
    @Resource
    ResService resService;
    @Autowired
    @Resource
    TokenService tokenService;
    @Autowired
    @Resource
    PermsService permsService;
    @Resource
    UploadAttachService uploadAttachService;
    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 = "分页查询并返回记录数")
@@ -132,6 +98,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")
@@ -161,6 +140,9 @@
            }
            int count = resService.insert(entity);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -184,6 +166,9 @@
            }
            int count = resService.inserts(list);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -200,6 +185,9 @@
    public ResponseMsg<Integer> delete(int id) {
        try {
            int count = resService.delete(id);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -220,6 +208,9 @@
            }
            int count = resService.deletes(ids);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -242,6 +233,9 @@
            }
            int count = resService.update(entity);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -266,6 +260,9 @@
            }
            int count = resService.updates(list);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {