| | |
| | | package cn.gistack.resource.endpoint; |
| | | |
| | | import cn.gistack.resource.builder.oss.OssBuilder; |
| | | import cn.gistack.resource.entity.TextualResearchAttach; |
| | | import cn.gistack.resource.service.IAttachService; |
| | | import cn.gistack.resource.service.TextualResearchAttachService; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.SneakyThrows; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 对象存储端点 |
| | |
| | | * 附件表服务 |
| | | */ |
| | | private final IAttachService attachService; |
| | | |
| | | /** |
| | | * 附件表服务 |
| | | */ |
| | | private final TextualResearchAttachService textualResearchAttachService; |
| | | |
| | | /** |
| | | * 创建存储桶 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 考证附件上传并保存 |
| | | * @param file 文件 |
| | | * @param resGuid 水库编号 |
| | | * @return |
| | | */ |
| | | @SneakyThrows |
| | | @PostMapping("/put-file-by-textualResearchAttach") |
| | | public R putFileByPrefixTextualResearchAttach(@RequestParam MultipartFile file,String resGuid,Integer type) { |
| | | BladeFile bladeFile = ossBuilder.templateByPrefixPath("textualResearchAttach").putFile(file.getOriginalFilename(), file.getInputStream()); |
| | | buildTextualResearchAttach(resGuid,bladeFile,type); |
| | | return R.data(bladeFile); |
| | | } |
| | | |
| | | /** |
| | | * 保存考证附件上传数据 |
| | | * @param bladeFile |
| | | */ |
| | | private void buildTextualResearchAttach(String resGuid,BladeFile bladeFile,Integer type) { |
| | | TextualResearchAttach attach = new TextualResearchAttach(); |
| | | attach.setResGuid(resGuid); |
| | | attach.setType(type); |
| | | attach.setPath(bladeFile.getName()); |
| | | attach.setName(bladeFile.getOriginalName()); |
| | | attach.setCreateTime(new Date()); |
| | | // 保存 |
| | | textualResearchAttachService.save(attach); |
| | | } |
| | | |
| | | /** |
| | | * 上传文件 |
| | | * |
| | | * @param fileName 存储桶对象名称 |