Explorar o código

Merge branch 'master' of http://git.dongkesoft.com:9001/iBOSS-2.0-Mini/iboss-server-mdm

于继渤 %!s(int64=2) %!d(string=hai) anos
pai
achega
b38cbc5c8b

+ 38 - 18
src/main/java/com/dk/mdm/controller/FileController.java

@@ -1,10 +1,13 @@
 package com.dk.mdm.controller;
 
 import com.alibaba.fastjson.JSONObject;
+import com.dk.common.infrastructure.constant.Constant;
 import com.dk.common.infrastructure.enums.ErrorCodeEnum;
 import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
+import com.dk.mdm.infrastructure.util.AuthUtils;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -21,10 +24,13 @@ public class FileController {
     @Value("${upload-path}")
     private String uploadPath;
 
+    @Autowired
+    private AuthUtils authUtils;
+
     /**
-     * @desc   : 上传文件
+     * @desc : 上传文件
      * @author : 洪旭东
-     * @date   : 2023-06-26 14:09
+     * @date : 2023-06-26 14:09
      */
     @ApiOperation(value = "上传文件", notes = "上传文件")
     @PostMapping("upload")
@@ -45,7 +51,7 @@ public class FileController {
             JSONObject json = new JSONObject();
             json.put("path", filePath.replace(uploadPath, ""));
             json.put("name", fileName);
-            json.put("type",getFileType(fileName));
+            json.put("type", getFileType(fileName));
             json.put("createTime", LocalDateTime.now());
             return ResponseResultUtil.success(json);
         } catch (IOException e) {
@@ -55,37 +61,51 @@ public class FileController {
     }
 
     /**
-     * @desc   : 获取文件类型
+     * @desc : 获取文件类型
      * @author : 周兴
-     * @date   : 2024-03-27 14:09
+     * @date : 2024-03-27 14:09
      */
     private String getFileType(String fileName) {
-        if(fileName.indexOf(".")>=0 ){
+        if (fileName.indexOf(".") >= 0) {
+            String appCode = authUtils.getStaff().getAppCode();
             String fileType = fileName.substring(fileName.lastIndexOf(".") + 1);
             fileType = fileType.toLowerCase();
 
-            if ("jpg".equals(fileType)  || "jepg".equals(fileType)  || "png".equals(fileType)) {
-                return "img";
-            }
             if ("mp4".equals(fileType) || "avi".equals(fileType) || "mov".equals(fileType)) {
                 return "video";
             }
-            if ("xls".equals(fileType) || "xlsx".equals(fileType)) {
-                return "excel";
-            }
-            if ("pdf".equals(fileType)) {
-                return "pdf";
+            // 小程序
+            if (Constant.AppCode.WEIXIN.getCode().equals(appCode)) {
+                if ("xls".equals(fileType) || "xlsx".equals(fileType)) {
+                    return "file";
+                }
+                if ("pdf".equals(fileType)) {
+                    return "file";
+                }
+                if ("jpg".equals(fileType) || "jepg".equals(fileType) || "png".equals(fileType)) {
+                    return "image";
+                }
+            } else {
+                if ("xls".equals(fileType) || "xlsx".equals(fileType)) {
+                    return "excel";
+                }
+                if ("pdf".equals(fileType)) {
+                    return "pdf";
+                }
+                if ("jpg".equals(fileType) || "jepg".equals(fileType) || "png".equals(fileType)) {
+                    return "img";
+                }
             }
         }
         return "";
     }
 
     /**
-     * @desc   : 根据类型创建目录文件夹
+     * @desc : 根据类型创建目录文件夹
      * @author : 洪旭东
-     * @date   : 2023-06-26 14:10
+     * @date : 2023-06-26 14:10
      */
-    private String createDirByPath(String folder){
+    private String createDirByPath(String folder) {
         //斜线
         final String diagonal = "/";
 
@@ -103,6 +123,6 @@ public class FileController {
                 dir.mkdir();
             }
         }
-        return base+diagonal;
+        return base + diagonal;
     }
 }

+ 5 - 1
src/main/java/com/dk/mdm/infrastructure/util/AuthUtils.java

@@ -80,7 +80,11 @@ public class AuthUtils {
             if (json==null){
                 return null;
             }else{
-                return JSONObject.parseObject(JSONObject.toJSONString(JSONObject.parseObject(json)), StaffEntity.class);
+                StaffEntity staffEntity = JSONObject.parseObject(JSONObject.toJSONString(JSONObject.parseObject(json)), StaffEntity.class);
+                staffEntity.setAppCode(appCode);
+                staffEntity.setCpCode(cpCode);
+                staffEntity.setCpId(Integer.parseInt(cpId) );
+                return staffEntity;
             }
         } catch (Exception e) {
             log.error(e.toString(),e);

+ 0 - 24
src/main/java/com/dk/mdm/service/mst/OrgMacService.java

@@ -1,24 +0,0 @@
-package com.dk.mdm.service.mst;
-
-import com.dk.mdm.model.pojo.mst.OrgMac;
-import com.dk.mdm.mapper.mst.OrgMacMapper;
-import com.dk.common.service.BaseService;
-import com.dk.common.mapper.BaseMapper;
-import org.springframework.stereotype.Service;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-@Service
-@Transactional
-public class OrgMacService extends BaseService<OrgMac> {
-
-
-	@Override
-	public BaseMapper<OrgMac> getRepository() {
-		return orgMacMapper;
-	}
-
-	@Autowired
-	private OrgMacMapper orgMacMapper;
-
-}

+ 0 - 23
src/main/java/com/dk/mdm/service/mst/OrgWhService.java

@@ -1,23 +0,0 @@
-package com.dk.mdm.service.mst;
-
-import com.dk.mdm.model.pojo.mst.OrgWh;
-import com.dk.mdm.mapper.mst.OrgWhMapper;
-import com.dk.common.service.BaseService;
-import com.dk.common.mapper.BaseMapper;
-import org.springframework.stereotype.Service;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-@Service
-@Transactional
-public class OrgWhService extends BaseService<OrgWh> {
-
-	@Override
-	public BaseMapper<OrgWh> getRepository() {
-		return orgWhMapper;
-	}
-
-	@Autowired
-	private OrgWhMapper orgWhMapper;
-
-}