Browse Source

加入小程序上传专用接口

wangliang 1 year ago
parent
commit
7100cc4907

+ 1 - 2
sop-api/src/main/java/com/qmth/sop/server/api/SysController.java

@@ -274,14 +274,13 @@ public class SysController {
     @RequestMapping(value = "/file/upload/app", method = RequestMethod.POST)
     @Transactional
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = AttachmentResult.class)})
-    @OperationLog(logType = LogTypeEnum.UN_KNOW)
     @Aac(auth = false)
     public Result fileUploadApp(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,
                                 @ApiParam(value = "上传文件类型", required = true) @RequestParam UploadFileEnum type,
                                 @ApiParam(value = "小程序签名key") @RequestParam(required = false) String key) throws Exception {
         BasicAttachment basicAttachment = null;
         try {
-            basicAttachment = basicAttachmentService.saveAttachment(file, type, key);
+            basicAttachment = basicAttachmentService.saveAttachmentNoAuth(file, type, key);
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             basicAttachmentService.deleteAttachment(basicAttachment);

+ 11 - 0
sop-business/src/main/java/com/qmth/sop/business/service/BasicAttachmentService.java

@@ -59,6 +59,17 @@ public interface BasicAttachmentService extends IService<BasicAttachment> {
      */
     public BasicAttachment saveAttachment(MultipartFile file, UploadFileEnum type, String key) throws Exception;
 
+    /**
+     * 上传文件接口
+     *
+     * @param file
+     * @param type
+     * @param key
+     * @return
+     * @throws Exception
+     */
+    public BasicAttachment saveAttachmentNoAuth(MultipartFile file, UploadFileEnum type, String key) throws Exception;
+
     /**
      * 删除附件
      *

+ 2 - 2
sop-business/src/main/java/com/qmth/sop/business/service/SysUserRoleService.java

@@ -6,7 +6,6 @@ import com.qmth.sop.business.bean.result.MenuResult;
 import com.qmth.sop.business.entity.SysRole;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.SysUserRole;
-import com.qmth.sop.business.entity.TBDingApply;
 import com.qmth.sop.common.enums.RoleTypeEnum;
 
 import java.util.List;
@@ -74,7 +73,8 @@ public interface SysUserRoleService extends IService<SysUserRole> {
      *
      * @param serviceId
      * @param userId
+     * @param sopNo
      * @return
      */
-    List<String> listByServiceId(Long serviceId, Long userId);
+    List<String> listByServiceId(Long serviceId, Long userId, String sopNo);
 }

+ 28 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/BasicAttachmentServiceImpl.java

@@ -195,6 +195,34 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
         return basicAttachment;
     }
 
+    /**
+     * 上传文件接口
+     *
+     * @param file
+     * @param type
+     * @param key
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public BasicAttachment saveAttachmentNoAuth(MultipartFile file, UploadFileEnum type, String key) throws Exception {
+        BasicAttachment basicAttachment = null;
+        AttachmentInfoDto attachmentInfoDto = this.validateAttachment(file);
+        if (Objects.nonNull(attachmentInfoDto)) {
+            StringJoiner stringJoiner = SystemConstant.getDirName(type, true).add(SystemConstant.getNanoId()).add(attachmentInfoDto.getFormat());
+            String path = stringJoiner.toString().replaceAll("\\\\", SystemConstant.ORG_SPLIT);
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put(SystemConstant.TYPE, fileStoreUtil.uploadFileEnumIsOss(type) ? SystemConstant.OSS : SystemConstant.LOCAL);
+            fileStoreUtil.ossUpload(path, file.getInputStream(), attachmentInfoDto.getMd5(), type.getFssType());
+            jsonObject.put(SystemConstant.UPLOAD_TYPE, type);
+            jsonObject.put(SystemConstant.PATH, path);
+            basicAttachment = new BasicAttachment(jsonObject.toJSONString(), attachmentInfoDto, null, key);
+            this.save(basicAttachment);
+        }
+        Optional.ofNullable(basicAttachment).orElseThrow(() -> ExceptionResultEnum.ATTACHMENT_ERROR.exception());
+        return basicAttachment;
+    }
+
     /**
      * 删除附件
      *

+ 2 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysUserRoleServiceImpl.java

@@ -136,10 +136,11 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
      *
      * @param serviceId
      * @param userId
+     * @param sopNo
      * @return
      */
     @Override
-    public List<String> listByServiceId(Long serviceId, Long userId) {
+    public List<String> listByServiceId(Long serviceId, Long userId, String sopNo) {
         SysUser sysUser = sysUserService.getById(userId);
         Optional.ofNullable(sysUser).orElseThrow(() -> ExceptionResultEnum.USER_NO_EXISTS.exception());
 

+ 2 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingApplyServiceImpl.java

@@ -94,7 +94,7 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
         CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(sopNo, crmNo);
         Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 
-        List<String> sysUserRoleList = sysUserRoleService.listByServiceId(crmProjectResult.getServiceUnitId(), sysUser.getId());
+        List<String> sysUserRoleList = sysUserRoleService.listByServiceId(crmProjectResult.getServiceUnitId(), sysUser.getId(), sopNo);
         List<String> approveUserIds = new ArrayList<>();
         approveUserIds.addAll(sysUserRoleList);
         FlowApproveParam flowApproveParam = new FlowApproveParam(tbDingApply.getFlowDeploymentId(), FlowApprovePassEnum.START, approveUserIds, crmNo);
@@ -347,7 +347,7 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
         Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
         Optional.ofNullable(crmProjectResult.getRegionCoordinatorId()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("crm区域协调人数据为空"));
 
-        List<String> sysUserRoleList = sysUserRoleService.listByServiceId(crmProjectResult.getServiceUnitId(), tbDingApply.getCreateId());
+        List<String> sysUserRoleList = sysUserRoleService.listByServiceId(crmProjectResult.getServiceUnitId(), tbDingApply.getCreateId(), tbDingApply.getSopNo());
         List<String> approveUserIds = new ArrayList<>();
         approveUserIds.addAll(sysUserRoleList);
         activitiService.taskApprove(new FlowApproveParam(taskId, FlowApprovePassEnum.PASS, approveUserIds, tfCustomFlowEntity.getCrmNo(), dingExceptionApprove.getTitle()));