Procházet zdrojové kódy

把归档在线收集

“zhifk” před 2 roky
rodič
revize
e6b5572739

+ 21 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/ArchiveFileClient.java

@@ -0,0 +1,21 @@
+package org.springblade.business.feign;
+
+import org.springblade.business.vo.ArchiveFileVO;
+import org.springblade.common.constant.BusinessConstant;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+
+/**
+ * @author zhifk
+ */
+@FeignClient(value = BusinessConstant.APPLICATION_WEATHER_NAME)
+public interface ArchiveFileClient {
+    /**
+     * 接口前缀
+     */
+    String API_PREFIX = "/api/business";
+    @PostMapping(API_PREFIX + "/savePushUserMessageWarning")
+    void saveArchiveFile(@RequestBody ArchiveFileVO vo);
+}

+ 76 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchiveFileController.java

@@ -0,0 +1,76 @@
+package org.springblade.archive.controller;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import lombok.SneakyThrows;
+import org.springblade.business.entity.ArchiveFile;
+import org.springblade.business.feign.ArchiveFileClient;
+import org.springblade.business.vo.ArchiveFileVO;
+import org.springblade.core.boot.ctrl.BladeController;
+
+import org.springblade.core.oss.model.BladeFile;
+import org.springblade.core.tool.api.R;
+import org.springblade.resource.feign.IOSSClient;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+
+/**
+ *  控制器
+ *
+ * @author BladeX
+ * @since 2022-07-08
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/archiveFile")
+@Api(value = "工程文件接口", tags = "工程文件接口")
+public class ArchiveFileController extends BladeController {
+
+	private final ArchiveFileClient archiveFileClient;
+    private final IOSSClient iossClient;
+    /**
+     * 上传文件
+     *
+     * @param file 文件
+     * @return ObjectStat
+     */
+    @SneakyThrows
+    @PostMapping("/put-file-attach")
+    @ApiOperationSupport(order = 1)
+    @ApiOperation(value = "工程上传", notes = "工程上传")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "file", value = "文件源", required = true)
+    })
+    public R<String> putFileAttach(@RequestParam("file") MultipartFile file) {
+        // 上传工程文件文件
+        R<BladeFile> bladeFile = iossClient.addFileInfo(file);
+
+        return R.data(bladeFile.getData().getLink());
+    }
+    /**
+     * 批量新增
+     */
+    @PostMapping("/batchSave")
+    @ApiOperationSupport(order = 3)
+    @ApiOperation(value = "批量新增")
+    public R<Boolean> batchSave(@RequestBody ArchiveFileVO vo){
+        List<ArchiveFileVO> saveList = vo.getList();
+        if(saveList != null && saveList.size() > 0){
+            for(ArchiveFileVO saveVo : saveList){
+                saveVo.setStatus(new Integer("0").equals(saveVo.getIsApproval()) ? 2 : 0);
+                saveVo.setIsCertification(new Integer("0").equals(saveVo.getIsNeedCertification()) ? 1 : 0);
+            }
+        }
+        archiveFileClient.saveArchiveFile(vo);
+        return R.data(true);
+    }
+}

+ 21 - 0
blade-service/blade-business/src/main/java/org/springblade/business/feignClient/ArchiveFileClientImpl.java

@@ -0,0 +1,21 @@
+package org.springblade.business.feignClient;
+
+import lombok.AllArgsConstructor;
+import org.springblade.business.feign.ArchiveFileClient;
+import org.springblade.business.service.IArchiveFileService;
+import org.springblade.business.vo.ArchiveFileVO;
+import org.springframework.web.bind.annotation.RestController;
+
+
+@RestController
+@AllArgsConstructor
+public class ArchiveFileClientImpl implements ArchiveFileClient {
+
+    private final IArchiveFileService iArchiveFileService;
+
+
+    @Override
+    public void saveArchiveFile(ArchiveFileVO vo) {
+        this.iArchiveFileService.saveArchiveFile(vo.getList());
+    }
+}

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/IArchiveFileService.java

@@ -47,5 +47,5 @@ public interface IArchiveFileService extends BaseService<ArchiveFile> {
 	List<ArchiveFile> getDeleteDataByIds(List<String> ids);
 
 
-
+	void saveArchiveFile(List<ArchiveFileVO> list);
 }

+ 5 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/ArchiveFileServiceImpl.java

@@ -88,4 +88,9 @@ public class ArchiveFileServiceImpl extends BaseServiceImpl<ArchiveFileMapper, A
 		return baseMapper.getDeleteDataByIds(ids);
 	}
 
+	@Override
+	public void saveArchiveFile(List<ArchiveFileVO> list) {
+		this.saveBatch(JSONArray.parseArray(JSONObject.toJSONString(list), ArchiveFile.class));
+	}
+
 }