管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-11-24 2a1ed8816d8ce5d1fe093e15a4e7ee7e7219570a
src/main/java/com/lf/server/controller/data/MetaController.java
@@ -39,63 +39,26 @@
    DownloadService downloadService;
    @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 = metaService.selectCount(name);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -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<MetaEntity>> selectByPage(String name, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            List<MetaEntity> rs = metaService.selectByPage(name, pageSize, pageSize * (pageIndex - 1));
            return success(rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "分页查询并返回记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dirid", value = "目录ID", dataType = "Integer", paramType = "query", example = "10"),
            @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 = "/selectByPageAndCount")
    public ResponseMsg<List<MetaEntity>> selectByPageAndCount(String name, Integer pageSize, Integer pageIndex) {
    public ResponseMsg<List<MetaEntity>> selectByPageAndCount(Integer dirid, String name, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            int count = metaService.selectCount(name);
            int count = metaService.selectCount(dirid, name);
            if (count == 0) {
                return success(0, null);
            }
            List<MetaEntity> rs = metaService.selectByPage(name, pageSize, pageSize * (pageIndex - 1));
            List<MetaEntity> rs = metaService.selectByPage(dirid, name, pageSize, pageSize * (pageIndex - 1));
            return success(count, rs);
        } catch (Exception ex) {
@@ -291,8 +254,11 @@
    @RequestMapping(value = "/downloadFile", method = RequestMethod.GET)
    public void downloadFile(@RequestBody DownloadReqEntity reqEntity, HttpServletRequest req, HttpServletResponse res) {
        try {
            if (null == reqEntity || StringHelper.isEmpty(reqEntity.getPwd())) {
                WebHelper.writeInfo(HttpStatus.BAD_REQUEST, "密码不能为空", res);
            }
            if (StringHelper.isEmpty(reqEntity.getGuid())) {
                WebHelper.writeInfo(HttpStatus.UNAUTHORIZED, "找不到文件ID", res);
                WebHelper.writeInfo(HttpStatus.BAD_REQUEST, "找不到文件ID", res);
                return;
            }
@@ -307,8 +273,8 @@
            de.setDownloadUser(ue.getId());
            int rows = downloadService.update(de);
            //String filePath = exportService.getDownloadFilePath(de);
            //WebHelper.download(filePath, de.getName(), res);
            String filePath = downloadService.getDownloadFilePath(de);
            WebHelper.download(filePath, de.getName(), res);
        } catch (Exception ex) {
            WebHelper.writeInfo(HttpStatus.ERROR, ex.getMessage(), res);
        }