Explorar o código

人员照片上传改至公共方法

jz.kai %!s(int64=5) %!d(string=hai) anos
pai
achega
530b6260e5

+ 0 - 25
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonInfoController.java

@@ -761,31 +761,6 @@ public class PersonInfoController {
         return msgResult;
     }
 
-    @PostMapping("upload")
-    @ApiOperation(value="人员照片上传")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name="subFolder",value = "路径",required = true,paramType = "form"),
-            @ApiImplicitParam(name = "photoFile",value = "员工照片", required = true,paramType="form", dataType = "__file")
-    })
-    public MessageResult<String> upload(String subFolder, MultipartFile photoFile){
-        MessageResult<String> messageResult = new MessageResult<>();
-
-        try {
-            String retFileUrl = OSSUtil.upload(ossConfig,"/" + subFolder,photoFile.getOriginalFilename(),photoFile.getInputStream());
-
-            messageResult.setResult(true);
-            messageResult.setData(retFileUrl);
-            messageResult.setCode(200);
-        } catch (Exception e) {
-            logger.error(e.getMessage(),e);
-
-            messageResult.setResult(false);
-            messageResult.setMessage(e.getMessage());
-        }
-
-        return messageResult;
-    }
-
 //    @ApiOperation(value="导出人员")
 //    @PostMapping("exportXls")
 //    public MessageResult<String> exportXls(@RequestBody List<String> ids){

+ 61 - 0
web/src/main/java/com/jpsoft/smart/modules/common/controller/fileUploadController.java

@@ -0,0 +1,61 @@
+package com.jpsoft.smart.modules.common.controller;
+
+import com.jpsoft.smart.config.OSSConfig;
+import com.jpsoft.smart.modules.common.dto.MessageResult;
+import com.jpsoft.smart.modules.common.utils.DES3;
+import com.jpsoft.smart.modules.common.utils.OSSUtil;
+import com.jpsoft.smart.modules.sys.entity.User;
+import com.jpsoft.smart.modules.sys.service.UserService;
+import io.jsonwebtoken.Jwts;
+import io.jsonwebtoken.security.Keys;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import springfox.documentation.annotations.ApiIgnore;
+
+import javax.servlet.http.HttpSession;
+import java.security.Key;
+import java.util.Base64;
+import java.util.Date;
+
+@RestController
+public class fileUploadController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private OSSConfig ossConfig;
+
+    @PostMapping("uploadPicture")
+    @ApiOperation(value="人员照片上传")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name="subFolder",value = "路径",required = true,paramType = "form"),
+            @ApiImplicitParam(name = "photoFile",value = "员工照片", required = true,paramType="form", dataType = "__file")
+    })
+    public MessageResult<String> uploadPicture(String subFolder, MultipartFile photoFile){
+        MessageResult<String> messageResult = new MessageResult<>();
+
+        try {
+            String retFileUrl = OSSUtil.upload(ossConfig,"/" + subFolder,photoFile.getOriginalFilename(),photoFile.getInputStream());
+
+            messageResult.setResult(true);
+            messageResult.setData(retFileUrl);
+            messageResult.setCode(200);
+        } catch (Exception e) {
+            logger.error(e.getMessage(),e);
+
+            messageResult.setResult(false);
+            messageResult.setMessage(e.getMessage());
+        }
+
+        return messageResult;
+    }
+}