소스 검색

通用流程关联业务和附件信息保存

dongpo 1 년 전
부모
커밋
8017222223

+ 7 - 5
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/universal/vo/OaUniversalSaveReqVO.java

@@ -33,7 +33,7 @@ public class OaUniversalSaveReqVO {
     @Schema(description = "申请用户账号uuid", example = "28769")
     private String userUuid;
 
-    @Schema(description = "部门id", example = "12910")
+    @Schema(description = "部门id", example = "1")
     private Long deptId;
 
     @Schema(description = "部门uuid", example = "18681")
@@ -42,13 +42,15 @@ public class OaUniversalSaveReqVO {
     @Schema(description = "职位")
     private String position;
 
-    @Schema(description = "申请事项标题")
+    @Schema(description = "申请事项标题", example = "申请事项标题,最多20字")
+    @NotNull(message = "申请事项标题不能为空")
     private String title;
 
-    @Schema(description = "详细描述", example = "随便")
+    @Schema(description = "详细描述", example = "详细描述,最多200字")
+    @NotNull(message = "详细描述不能为空")
     private String description;
 
-    @Schema(description = "备注")
+    @Schema(description = "备注", example = "备注,最多200字")
     private String remarks;
 
     @Schema(description = "流程实例id", example = "18345")
@@ -72,7 +74,7 @@ public class OaUniversalSaveReqVO {
     @Schema(description = "最后审核时间")
     private LocalDateTime finalAuditDate;
 
-    @Schema(description = "数据来源,0流程添加、1手动添加")
+    @Schema(description = "数据来源,0流程添加、1手动添加", example = "0")
     private String infoSource;
 
 

+ 7 - 2
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/universal/OaUniversalServiceImpl.java

@@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskReturnRe
 import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.universal.OaUniversalDO;
 import cn.iocoder.yudao.module.bpm.dal.mysql.oa.universal.OaUniversalMapper;
 import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
+import cn.iocoder.yudao.module.infra.api.file.FileApi;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.commons.lang3.StringUtils;
@@ -59,6 +60,9 @@ public class OaUniversalServiceImpl extends ServiceImpl<OaUniversalMapper, OaUni
     @Resource
     private TaskService taskService;
 
+    @Resource
+    private FileApi fileApi;
+
     @Override
     @Transactional
     public Long startOaUniversal(Long userId, OaUniversalSaveReqVO createReqVO) {
@@ -101,7 +105,7 @@ public class OaUniversalServiceImpl extends ServiceImpl<OaUniversalMapper, OaUni
                     .setFinalAuditDate(LocalDateTime.now())
                     .setCurrentAuditEmployeeId(Long.valueOf(task.getAssignee())));
 
-            // TODO 发送通知
+            // TODO dp 发送通知
 
         }else {
             // 暂存,不发起流程
@@ -111,8 +115,9 @@ public class OaUniversalServiceImpl extends ServiceImpl<OaUniversalMapper, OaUni
                     .setAuditStatus("0"));
         }
 
-        // TODO 保存或更新附件uuid
+        // 保存业务uuid到附件中
         if (CollectionUtil.isNotEmpty(createReqVO.getFileIdList())) {
+            fileApi.updateFileBiz(createReqVO.getFileIdList(), oaUniversal.getUniversalId());
         }
 
         // 返回

+ 10 - 0
yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApi.java

@@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.infra.api.file;
 
 import cn.iocoder.yudao.module.infra.api.file.dto.FileDTO;
 
+import java.util.List;
+
 /**
  * 文件 API 接口
  *
@@ -49,4 +51,12 @@ public interface FileApi {
      * @return 文件对象
      */
     FileDTO uploadFile(String name, String path, byte[] content);
+
+    /**
+     * 更新文件业务id
+     *
+     * @param fileIdList 文件id集合
+     * @param serviceId  业务id
+     */
+    Integer updateFileBiz(List<Long> fileIdList, String serviceId);
 }

+ 8 - 0
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApiImpl.java

@@ -3,11 +3,14 @@ package cn.iocoder.yudao.module.infra.api.file;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.module.infra.api.file.dto.FileDTO;
 import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileRespVO;
+import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
 import cn.iocoder.yudao.module.infra.service.file.FileService;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
 
 import javax.annotation.Resource;
+import java.util.List;
 
 /**
  * 文件 API 实现类
@@ -32,4 +35,9 @@ public class FileApiImpl implements FileApi {
         return BeanUtils.toBean(fileRespVO, FileDTO.class);
     }
 
+    @Override
+    public Integer updateFileBiz(List<Long> fileIdList, String serviceId) {
+        return fileService.updateFileBiz(fileIdList, serviceId);
+    }
+
 }

+ 7 - 0
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java

@@ -1,8 +1,10 @@
 package cn.iocoder.yudao.module.infra.controller.admin.file;
 
 import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.lang.Assert;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.URLUtil;
+import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
@@ -25,6 +27,8 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 
+import java.util.Objects;
+
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 import static cn.iocoder.yudao.module.infra.framework.file.core.utils.FileTypeUtils.writeAttachment;
 
@@ -104,6 +108,9 @@ public class FileController {
     @Operation(summary = "上传文件", description = "模式一:后端上传文件;返回的为对象")
     public CommonResult<FileRespVO> uploadFile(FileUploadReqVO uploadReqVO) throws Exception {
         MultipartFile file = uploadReqVO.getFile();
+        if (file == null) {
+            CommonResult.error(GlobalErrorCodeConstants.BAD_REQUEST.getCode(), "文件不能为空");
+        }
         String path = uploadReqVO.getPath();
         return success(fileService.uploadFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
     }

+ 1 - 1
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/file/FileRespVO.java

@@ -36,6 +36,6 @@ public class FileRespVO {
     @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
     private LocalDateTime createTime;
 
-    @Schema(description = "文件字典类型(0:通用类型)", example = "2")
+    @Schema(description = "文件字典类型(0:通用类型)", example = "0")
     private Integer fileDictType;
 }

+ 10 - 0
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileService.java

@@ -3,6 +3,9 @@ package cn.iocoder.yudao.module.infra.service.file;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.*;
 import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+
+import java.util.List;
 
 /**
  * 文件 Service 接口
@@ -77,4 +80,11 @@ public interface FileService {
      */
     FilePresignedUrlRespVO getFilePresignedUrl(String path) throws Exception;
 
+    /**
+     * 更新文件业务id
+     *
+     * @param fileIdList 文件id集合
+     * @param serviceId  业务id
+     */
+    Integer updateFileBiz(List<Long> fileIdList, String serviceId);
 }

+ 10 - 0
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java

@@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.infra.framework.file.core.client.s3.FilePresigned
 import cn.iocoder.yudao.module.infra.framework.file.core.utils.FileTypeUtils;
 import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
 import cn.iocoder.yudao.module.infra.dal.mysql.file.FileMapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import lombok.SneakyThrows;
 import org.springframework.stereotype.Service;
 
@@ -19,6 +20,7 @@ import javax.annotation.Resource;
 
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
+import java.util.List;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_NOT_EXISTS;
@@ -174,4 +176,12 @@ public class FileServiceImpl implements FileService {
                 object -> object.setConfigId(fileClient.getId()));
     }
 
+    @Override
+    public Integer updateFileBiz(List<Long> fileIdList, String serviceId) {
+        LambdaUpdateWrapper<FileDO> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.set(FileDO::getServiceId, serviceId)
+                .in(FileDO::getId, fileIdList);
+        return fileMapper.update(updateWrapper);
+    }
+
 }