管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-10-19 b1f4fd76dbc3eaafe9296fe35b28b4e65510e367
src/main/java/com/lf/server/controller/sys/ResController.java
@@ -5,7 +5,7 @@
import com.lf.server.entity.all.ResponseMsg;
import com.lf.server.entity.sys.ResEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.service.all.FileService;
import com.lf.server.service.data.UploaderService;
import com.lf.server.service.sys.ResService;
import com.lf.server.service.sys.TokenService;
import io.swagger.annotations.Api;
@@ -36,7 +36,7 @@
    TokenService tokenService;
    @Autowired
    FileService fileService;
    UploaderService uploaderService;
    private final static String TAB_NAME = "sys_res";
@@ -97,6 +97,33 @@
                return success(0, null);
            }
            List<ResEntity> rs = resService.selectByPage(name, pageSize, pageSize * (pageIndex - 1));
            return success(count, rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "根据角色分页查询并返回记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleid", value = "角色ID", dataType = "Integer", paramType = "query", example = "1"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"),
            @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectByPageForRole")
    public ResponseMsg<List<ResEntity>> selectByPageForRole(Integer roleid, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            int count = resService.selectCountForRole(roleid);
            if (count == 0) {
                return success(0, null);
            }
            List<ResEntity> rs = resService.selectByPageForRole(roleid, pageSize, pageSize * (pageIndex - 1));
            return success(count, rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
@@ -239,7 +266,7 @@
    public ResponseMsg<String> upload(@RequestParam("file") MultipartFile file, HttpServletRequest req) {
        UserEntity ue = tokenService.getCurrentUser(req);
        return fileService.upload(ue, TAB_NAME, file, this);
        return uploaderService.upload(ue, TAB_NAME, file, this);
    }
    @SysLog()
@@ -248,7 +275,7 @@
            @ApiImplicitParam(name = "guid", value = "附件Guid", dataType = "String", paramType = "body")
    })
    @GetMapping(value = "/download")
    public void download(String guid, HttpServletRequest req, HttpServletResponse res) {
        fileService.download(guid, req, res, this);
    public void download(String guid, HttpServletResponse res) {
        uploaderService.download(guid, res);
    }
}