管道基础大数据平台系统开发-【后端】-Server
13693261870
2024-03-25 b6b0cb226fcf184525ee7b36af3a09471e9c0057
src/main/java/com/lf/server/controller/sys/ResController.java
@@ -5,7 +5,6 @@
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.helper.StringHelper;
import com.lf.server.service.all.PermsService;
import com.lf.server.service.all.UploadAttachService;
import com.lf.server.service.data.DownloadService;
@@ -152,10 +151,8 @@
                entity.setCreateUser(ue.getId());
            }
            permsService.clearPermsCache();
            int count = resService.insertRes(entity);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -178,10 +175,8 @@
                }
            }
            permsService.clearPermsCache();
            int count = resService.insertRess(list);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -197,10 +192,8 @@
    @GetMapping(value = "/deleteRes")
    public ResponseMsg<Integer> deleteRes(int id) {
        try {
            permsService.clearPermsCache();
            int count = resService.deleteRes(id);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -220,10 +213,8 @@
                return fail("id数组不能为空", -1);
            }
            permsService.clearPermsCache();
            int count = resService.deleteRess(ids);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -245,10 +236,8 @@
                entity.setUpdateUser(ue.getId());
            }
            permsService.clearPermsCache();
            int count = resService.updateRes(entity);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -313,53 +302,5 @@
    @GetMapping(value = "/downloadForView")
    public void downloadForView(String guid, HttpServletResponse res) {
        uploadAttachService.download(guid, true, res);
    }
    @SysLog()
    @ApiOperation(value = "请求下载")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "guids", value = "附件Guid数组", dataType = "String", paramType = "body", allowMultiple = true, example = "e5b6ae0889b88111f13a4b6e048348db,fa4f299e901a0c46e634f8fcc8185c0c")
    })
    @ResponseBody
    @PostMapping(value = "/downloadReq")
    public ResponseMsg<Object> downloadReqForGuids(String[] guids, HttpServletRequest req, HttpServletResponse res) {
        try {
            if (null == guids || guids.length == 0) {
                return fail("Guid数组为空");
            }
            UserEntity ue = tokenService.getCurrentUser(req);
            String guid = uploadAttachService.downloadReqForGuids(ue, guids);
            return success("");
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
    @SysLog()
    @ApiOperation(value = "请求下载")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tab", value = "表名", dataType = "String", paramType = "body", example = "bd.b_borehole"),
            @ApiImplicitParam(name = "guids", value = "附件Guid数组", dataType = "String", paramType = "body", allowMultiple = true, example = "08e5b4ad-93b8-46f6-adaa-46a6274af4ce,6f94f4f8-6e8d-44e7-8803-3d068d34983f")
    })
    @ResponseBody
    @PostMapping(value = "/downloadReq")
    public ResponseMsg<Object> downloadReqForTabGuids(String tab, String[] guids, HttpServletRequest req, HttpServletResponse res) {
        try {
            if (StringHelper.isEmpty(tab)) {
                return fail("表名为空");
            }
            if (null != guids && guids.length == 0) {
                guids = null;
            }
            UserEntity ue = tokenService.getCurrentUser(req);
            String guid = uploadAttachService.downloadReqForTabGuids(ue, tab, guids);
            return success(guid);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
}