管道基础大数据平台系统开发-【后端】-Server
13693261870
2023-08-28 d565e050f3188fc729cb8178be7d5cc04844ce0d
src/main/java/com/lf/server/controller/sys/ResController.java
@@ -1,11 +1,13 @@
package com.lf.server.controller.sys;
import com.lf.server.aspect.SysLog;
import com.lf.server.annotation.SysLog;
import com.lf.server.controller.all.BaseController;
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.data.UploaderService;
import com.lf.server.service.all.PermsService;
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;
@@ -36,9 +38,15 @@
    TokenService tokenService;
    @Autowired
    UploaderService uploaderService;
    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 = "查询记录数")
@@ -52,7 +60,7 @@
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -74,7 +82,7 @@
            return success(rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -99,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);
        }
    }
@@ -126,7 +134,7 @@
            return success(count, rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -143,11 +151,12 @@
                entity.setCreateUser(ue.getId());
            }
            permsService.clearPermsCache();
            int count = resService.insertRes(entity);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -166,11 +175,12 @@
                }
            }
            permsService.clearPermsCache();
            int count = resService.insertRess(list);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -182,11 +192,12 @@
    @GetMapping(value = "/deleteRes")
    public ResponseMsg<Integer> deleteRes(int id) {
        try {
            permsService.clearPermsCache();
            int count = resService.deleteRes(id);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -201,10 +212,13 @@
            if (ids == null || ids.isEmpty()) {
                return fail("id数组不能为空", -1);
            }
            permsService.clearPermsCache();
            int count = resService.deleteRess(ids);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -222,11 +236,12 @@
                entity.setUpdateUser(ue.getId());
            }
            permsService.clearPermsCache();
            int count = resService.updateRes(entity);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -242,7 +257,7 @@
            return success(resEntity);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -255,7 +270,7 @@
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -266,7 +281,7 @@
    public ResponseMsg<String> upload(@RequestParam("file") MultipartFile file, HttpServletRequest req) {
        UserEntity ue = tokenService.getCurrentUser(req);
        return uploaderService.upload(ue, TAB_NAME, file, this);
        return uploadAttachService.upload(ue, TAB_NAME, file, this);
    }
    @SysLog()
@@ -276,6 +291,16 @@
    })
    @GetMapping(value = "/download")
    public void download(String guid, HttpServletResponse res) {
        uploaderService.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);
    }
}