|
@@ -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);
|
|
|
+ }
|
|
|
+}
|