管道基础大数据平台系统开发-【后端】-Server
13693261870
2023-08-28 d565e050f3188fc729cb8178be7d5cc04844ce0d
src/main/java/com/lf/server/controller/sys/ResController.java
@@ -6,7 +6,8 @@
import com.lf.server.entity.sys.ResEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.service.all.PermsService;
import com.lf.server.service.all.UploadService;
import com.lf.server.service.all.UploadAttachService;
import com.lf.server.service.data.DownloadService;
import com.lf.server.service.sys.ResService;
import com.lf.server.service.sys.TokenService;
import io.swagger.annotations.Api;
@@ -37,12 +38,15 @@
    TokenService tokenService;
    @Autowired
    UploadService uploadService;
    @Autowired
    PermsService permsService;
    private final static String TAB_NAME = "sys_res";
    @Autowired
    DownloadService downloadService;
    @Autowired
    UploadAttachService uploadAttachService;
    private final static String TAB_NAME = "lf.sys_res";
    @SysLog()
    @ApiOperation(value = "查询记录数")
@@ -56,7 +60,7 @@
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -78,7 +82,7 @@
            return success(rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -103,7 +107,7 @@
            List<ResEntity> rs = resService.selectByPage(name, pageSize, pageSize * (pageIndex - 1));
            return success(count, rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -130,7 +134,7 @@
            return success(count, rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -147,14 +151,12 @@
                entity.setCreateUser(ue.getId());
            }
            permsService.clearPermsCache();
            int count = resService.insertRes(entity);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -173,14 +175,12 @@
                }
            }
            permsService.clearPermsCache();
            int count = resService.insertRess(list);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -192,14 +192,12 @@
    @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) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -215,14 +213,12 @@
                return fail("id数组不能为空", -1);
            }
            permsService.clearPermsCache();
            int count = resService.deleteRess(ids);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -240,14 +236,12 @@
                entity.setUpdateUser(ue.getId());
            }
            permsService.clearPermsCache();
            int count = resService.updateRes(entity);
            if (count > 0) {
                permsService.clearResCache();
            }
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -263,7 +257,7 @@
            return success(resEntity);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -276,7 +270,7 @@
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -287,7 +281,7 @@
    public ResponseMsg<String> upload(@RequestParam("file") MultipartFile file, HttpServletRequest req) {
        UserEntity ue = tokenService.getCurrentUser(req);
        return uploadService.upload(ue, TAB_NAME, file, this);
        return uploadAttachService.upload(ue, TAB_NAME, file, this);
    }
    @SysLog()
@@ -297,6 +291,16 @@
    })
    @GetMapping(value = "/download")
    public void download(String guid, HttpServletResponse res) {
        uploadService.download(guid, res);
        uploadAttachService.download(guid, false, res);
    }
    @SysLog()
    @ApiOperation(value = "查看文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "guid", value = "附件Guid", dataType = "String", paramType = "body")
    })
    @GetMapping(value = "/downloadForView")
    public void downloadForView(String guid, HttpServletResponse res) {
        uploadAttachService.download(guid, true, res);
    }
}