From 65f1296728ac4a2c207d411b50659af683628413 Mon Sep 17 00:00:00 2001
From: luoyb <412940104@qq.com>
Date: 星期五, 30 七月 2021 09:22:39 +0800
Subject: [PATCH] fix: 导入新员工时也同步写一条入职记录

---
 febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/controller/EmpAccessoryController.java |   85 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 78 insertions(+), 7 deletions(-)

diff --git a/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/controller/EmpAccessoryController.java b/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/controller/EmpAccessoryController.java
index 41e93fd..90e29c2 100644
--- a/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/controller/EmpAccessoryController.java
+++ b/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/controller/EmpAccessoryController.java
@@ -12,8 +12,12 @@
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
-import javax.validation.Valid;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
 import java.util.Map;
 
 /**
@@ -32,7 +36,6 @@
     private final IEmpAccessoryService empAccessoryService;
 
     @GetMapping
-    @PreAuthorize("hasAuthority('empAccessory:list')")
     public FebsResponse getAllEmpAccessorys(EmpAccessory empAccessory) {
         return new FebsResponse().data(empAccessoryService.findEmpAccessorys(empAccessory));
     }
@@ -45,10 +48,9 @@
     }
 
     @PostMapping
-    @PreAuthorize("hasAuthority('empAccessory:add')")
-    public void addEmpAccessory(@Valid EmpAccessory empAccessory) throws FebsException {
+    public void addEmpAccessory(@NotNull(message = "{required}") Long labelid,@NotNull(message = "{required}") Long empId, MultipartFile file) throws FebsException {
         try {
-            this.empAccessoryService.createEmpAccessory(empAccessory);
+            this.empAccessoryService.createEmpAccessory(labelid,file,empId);
         } catch (Exception e) {
             String message = "新增EmpAccessory失败";
             log.error(message, e);
@@ -58,9 +60,9 @@
 
     @DeleteMapping
     @PreAuthorize("hasAuthority('empAccessory:delete')")
-    public void deleteEmpAccessory(EmpAccessory empAccessory) throws FebsException {
+    public void deleteEmpAccessory(@NotBlank(message = "{required}")  String accessoryids) throws FebsException {
         try {
-            this.empAccessoryService.deleteEmpAccessory(empAccessory);
+            this.empAccessoryService.deleteEmpAccessory(accessoryids);
         } catch (Exception e) {
             String message = "删除EmpAccessory失败";
             log.error(message, e);
@@ -76,6 +78,75 @@
         } catch (Exception e) {
             String message = "修改EmpAccessory失败";
             log.error(message, e);
+            throw new FebsException(e.getMessage());
+        }
+    }
+
+    @PostMapping("/download")
+    @PreAuthorize("hasAuthority('empAccessory:download')")
+    public void download(@NotBlank(message = "{required}")  String accessoryids, HttpServletRequest request, HttpServletResponse response) throws FebsException {
+        try {
+            this.empAccessoryService.download(accessoryids,request,response);
+        } catch (Exception e) {
+            String message = "下载文件失败";
+            log.error(message, e);
+            throw new FebsException(message);
+        }
+    }
+
+    @PostMapping("/mvFiles")
+    @PreAuthorize("hasAuthority('empAccessory:mv')")
+    public void mvFiles(@NotBlank(message = "{required}")  String accessoryids,@NotNull(message = "{required}") Long labelid,@NotNull(message = "{required}")  Long empId) throws FebsException {
+        try {
+            this.empAccessoryService.mvFiles(accessoryids,labelid,empId);
+        } catch (Exception e) {
+            String message = "移动文件失败";
+            log.error(message, e);
+            throw new FebsException(message);
+        }
+    }
+    @PostMapping("/singledownload")
+    @PreAuthorize("hasAuthority('empAccessory:singledownload')")
+    public void singledownload(@NotBlank(message = "{required}")  String empIds, @NotNull(message = "{required}")  Long labelid, HttpServletRequest request, HttpServletResponse response) throws FebsException {
+        try {
+            this.empAccessoryService.singledownload(empIds,labelid,request,response);
+        } catch (Exception e) {
+            String message = "下载文件失败";
+            log.error(message, e);
+            throw new FebsException(message);
+        }
+    }
+    @GetMapping("{labelid}")
+    @PreAuthorize("hasAuthority('empAccessory:delete')")
+    public FebsResponse getLabelCount(@PathVariable(value = "labelid") String labelid) throws FebsException {
+        try {
+            return new FebsResponse().data(empAccessoryService.getLabelCount(Long.valueOf(labelid)));
+        } catch (Exception e) {
+            String message = "修改Label失败";
+            log.error(message, e);
+            throw new FebsException(message);
+        }
+    }
+
+
+    @PostMapping("autoInstall")
+    public void autoInstall(  String fileids) throws FebsException {
+        try {
+            this.empAccessoryService.autoInstall(fileids);
+        } catch (Exception e) {
+            String message = "插入文件失败";
+            log.error(message, e);
+            throw new FebsException(message);
+        }
+    }
+
+    @GetMapping("image/{accessoryid}")
+    public void getImage(@PathVariable String accessoryid, HttpServletResponse response) throws FebsException {
+        try {
+            this.empAccessoryService.getImage(accessoryid,response);
+        } catch (Exception e) {
+            String message = "获取员工图片异常";
+            log.error(message, e);
             throw new FebsException(message);
         }
     }

--
Gitblit v1.8.0