| | |
| | |
|
| | | import java.io.File;
|
| | | import java.util.ArrayList;
|
| | | import java.util.LinkedHashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import com.ruoyi.basic.service.StorageBlobService;
|
| | | import com.ruoyi.framework.web.domain.R;
|
| | | import io.swagger.annotations.Api;
|
| | | import io.swagger.annotations.ApiOperation;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | *
|
| | | * @author ruoyi
|
| | | */
|
| | | @Api(tags = "通用接口")
|
| | | @RestController
|
| | | @RequestMapping("/common")
|
| | | public class CommonController
|
| | |
| | | {
|
| | | log.error("下载文件失败", e);
|
| | | }
|
| | | }
|
| | |
|
| | | @Autowired
|
| | | private StorageBlobService storageBlobService;
|
| | |
|
| | |
|
| | | /**
|
| | | * minio通用上传请求(多个)
|
| | | */
|
| | | @PostMapping("/minioUploads")
|
| | | @ApiOperation(value = "minio通用上传请求")
|
| | | public AjaxResult minioUploadFiles(List<MultipartFile> files, String bucketName, Long type) throws Exception
|
| | | {
|
| | | return AjaxResult.success(storageBlobService.updateStorageBlobs(files, bucketName,type));
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 通用上传请求(多个,返回文件列表,供附件上传组件使用)
|
| | | */
|
| | | @PostMapping("/uploadsList")
|
| | | @ApiOperation(value = "通用上传请求(多个,返回文件列表)")
|
| | | public AjaxResult uploadsList(List<MultipartFile> files) throws Exception
|
| | | {
|
| | | try
|
| | | {
|
| | | if (files == null || files.isEmpty())
|
| | | {
|
| | | return AjaxResult.error("未选择文件");
|
| | | }
|
| | | // 上传文件路径
|
| | | String filePath = RuoYiConfig.getUploadPath();
|
| | | List<Map<String, String>> result = new ArrayList<>();
|
| | | for (MultipartFile file : files)
|
| | | {
|
| | | // 上传并返回新文件名称
|
| | | String fileName = FileUploadUtils.upload(filePath, file);
|
| | | String url = serverConfig.getUrl() + fileName;
|
| | | Map<String, String> item = new LinkedHashMap<>();
|
| | | item.put("name", file.getOriginalFilename());
|
| | | item.put("url", url);
|
| | | result.add(item);
|
| | | }
|
| | | return AjaxResult.success(result);
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | return AjaxResult.error(e.getMessage());
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 本地资源通用下载
|
| | | */
|
| | | @GetMapping("/download/resource")
|