管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-02-23 242625593d053aa842d3dd91cc426c8a109eb395
src/main/java/com/lf/server/controller/show/ExportController.java
@@ -11,6 +11,7 @@
import com.lf.server.helper.WebHelper;
import com.lf.server.service.data.DownloadService;
import com.lf.server.service.show.ExportService;
import com.lf.server.service.sys.DownlogService;
import com.lf.server.service.sys.TokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -38,17 +39,20 @@
    ExportService exportService;
    @Autowired
    DownlogService downlogService;
    @Autowired
    DownloadService downloadService;
    @SysLog()
    @ApiOperation(value = "分页查询")
    @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<DownloadEntity>> selectByPage(String name, Integer pageSize, Integer pageIndex, HttpServletRequest req) {
    public ResponseMsg<List<DownloadEntity>> selectPageCountForDownload(String name, Integer pageSize, Integer pageIndex, HttpServletRequest req) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
@@ -59,11 +63,11 @@
                return fail("用户未登录", null);
            }
            int count = downloadService.selectCountForUser(ue.getCreateUser(), 2, name);
            int count = downloadService.selectCountForUser(ue.getId(), 2, name);
            if (count == 0) {
                return success(0, null);
            }
            List<DownloadEntity> rs = downloadService.selectByPageForUser(ue.getCreateUser(), 2, name, pageSize, pageSize * (pageIndex - 1));
            List<DownloadEntity> rs = downloadService.selectByPageForUser(ue.getId(), 2, name, pageSize, pageSize * (pageIndex - 1));
            return success(count, rs);
        } catch (Exception ex) {
@@ -117,16 +121,14 @@
                return;
            }
            UserEntity ue = tokenService.getCurrentUser(req);
            DownloadEntity de = downloadService.selectByGuid(guid);
            if (null == de) {
                WebHelper.writeInfo(HttpStatus.NOT_FOUND, "文件不存在", res);
                return;
            }
            de.setDcount(de.getDcount() + 1);
            de.setDownloadUser(ue.getId());
            int rows = downloadService.update(de);
            UserEntity ue = tokenService.getCurrentUser(req);
            downlogService.updateInfos(ue, de, req);
            String filePath = downloadService.getDownloadFilePath(de);
            WebHelper.download(filePath, de.getName(), res);