فهرست منبع

文件上传修改

yanguofeng 2 سال پیش
والد
کامیت
813bcb2a14

+ 16 - 2
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/controller/AdmFileController.java

@@ -3,6 +3,7 @@ package com.persagy.adm.server.custom.controller;
 
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.persagy.adm.server.custom.dto.CadFiles;
 import com.persagy.adm.server.custom.entity.CadFileQueryParam;
 import com.persagy.adm.server.custom.entity.db.AdmCad;
 import com.persagy.adm.server.custom.service.IAdmCadService;
@@ -10,9 +11,12 @@ import com.persagy.dmp.common.context.AppContext;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.common.utils.ResultHelper;
 import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -48,11 +52,21 @@ public class AdmFileController {
      * 保存CAD文件信息
      */
     @PostMapping("/saveCadFileInfo")
-    public CommonResult<Void> saveCadFileInfo(@RequestBody List<AdmCad> admFiles){
+    public CommonResult<Void> saveCadFileInfo(@RequestBody @Validated CadFiles cadFiles){
+        List<AdmCad> admFiles = new ArrayList<>();
         AppContext context = AppContext.getContext();
-        admFiles.forEach(admCad -> {
+        cadFiles.getFiles().forEach(file -> {
+            AdmCad admCad = new AdmCad();
             admCad.setGroupCode(context.getGroupCode());
             admCad.setProjectId(context.getProjectId());
+            admCad.setBuildingId(cadFiles.getBuildingId());
+            admCad.setFloorId(cadFiles.getFloorId());
+            admCad.setMajorCode(cadFiles.getMajorCode());
+            admCad.setMajorName(cadFiles.getMajorName());
+            admCad.setCheckStatus(false);
+            admCad.setFileKey(file.getFileKey());
+            admCad.setFileName(file.getFileName());
+            admFiles.add(admCad);
         });
         iAdmCadService.saveOrUpdateBatch(admFiles);
         return ResultHelper.success();

+ 26 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/dto/CadFiles.java

@@ -0,0 +1,26 @@
+package com.persagy.adm.server.custom.dto;
+
+
+import com.persagy.adm.server.custom.entity.CadFileInfo;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.util.List;
+
+@Data
+public class CadFiles {
+    @NotBlank(message = "floorId不能为空")
+   private String floorId;
+    @NotBlank(message = "buildingId不能为空")
+    private String buildingId;
+    @NotBlank(message = "majorCode不能为空")
+    private String majorCode;
+    @NotBlank(message = "majorName不能为空")
+    private String majorName;
+
+    @NotNull(message = "文件列表不能为空")
+    @Size(min = 0,max = 1000)
+    private List<CadFileInfo> files;
+}

+ 6 - 9
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/entity/CadFileInfo.java

@@ -2,15 +2,12 @@ package com.persagy.adm.server.custom.entity;
 
 import lombok.Data;
 
+import javax.validation.constraints.NotBlank;
+
 @Data
 public class CadFileInfo {
-    private String id;
-    private String fileId;
-    private String projectId;
-    private String buildingId;
-    private String floorId;
-    private String bizType;
-    private String fileType;
-    private String remark;
-    private int orderNum;
+    @NotBlank(message = "fileKey不能为空")
+    private String fileKey;
+    @NotBlank(message = "fileName不能为空")
+    private String fileName;
 }