From 68985c22a03d280a96e89f4d0e67f144259fab92 Mon Sep 17 00:00:00 2001
From: 安瑾然 <107107765@qq.com>
Date: 星期三, 13 七月 2022 11:54:54 +0800
Subject: [PATCH] commit
---
src/main/java/com/example/jz/controller/MinIOController.java | 28 +++++++++++++++++++++-------
1 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/src/main/java/com/example/jz/controller/MinIOController.java b/src/main/java/com/example/jz/controller/MinIOController.java
index e640f40..5924f20 100644
--- a/src/main/java/com/example/jz/controller/MinIOController.java
+++ b/src/main/java/com/example/jz/controller/MinIOController.java
@@ -1,21 +1,35 @@
package com.example.jz.controller;
+import com.example.jz.modle.R;
import com.example.jz.service.MinIOService;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
+import java.io.IOException;
@RestController
@RequestMapping("/minio")
+@Api(tags = "MinIO鎺ュ彛")
public class MinIOController {
@Resource
private MinIOService minIOService;
- @RequestMapping(method = RequestMethod.GET,value = "/{fileName}")
- public String getUrl(@PathVariable String fileName){
- return "";
+ @RequestMapping(method = RequestMethod.GET, value = "/getUrl")
+ @ApiOperation("鑾峰彇鏂囦欢棰勮鍦板潃")
+ public R<String> getUrl(@RequestParam String fileName) {
+ return R.ok(minIOService.getPreviewFileUrl(fileName));
+ }
+
+ @PostMapping("/upload")
+ @ApiOperation("涓婁紶鏂囦欢")
+ public R<String> uploadFile(@RequestParam("file") MultipartFile file) throws IOException {
+ if (file.isEmpty()) {
+ return R.failed("鏂囦欢涓虹┖");
+ }
+ String fileName = minIOService.upload(file);
+ return R.ok(fileName);
}
}
--
Gitblit v1.8.0