|
@@ -1,6 +1,8 @@
|
|
package com.zanxiang.manage.controller;
|
|
package com.zanxiang.manage.controller;
|
|
|
|
|
|
import com.zanxiang.common.domain.ResultVo;
|
|
import com.zanxiang.common.domain.ResultVo;
|
|
|
|
+import com.zanxiang.common.enums.FileTypeEnum;
|
|
|
|
+import com.zanxiang.common.exception.BaseException;
|
|
import com.zanxiang.module.oss.service.IOssService;
|
|
import com.zanxiang.module.oss.service.IOssService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -10,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -31,8 +34,12 @@ public class OssController {
|
|
@ApiOperation(value = "文件上传oss")
|
|
@ApiOperation(value = "文件上传oss")
|
|
@GetMapping(value = "/form/upload/")
|
|
@GetMapping(value = "/form/upload/")
|
|
@ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Map.class)})
|
|
@ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Map.class)})
|
|
- public ResultVo<Map<String, String>> formUpload(String filePrefix, String mime) {
|
|
|
|
- return new ResultVo<>(ossService.formUpload(filePrefix, mime));
|
|
|
|
|
|
+ public ResultVo<Map<String, String>> formUpload(@RequestParam String fileType, @RequestParam String type) {
|
|
|
|
+ FileTypeEnum fileTypeEnum = FileTypeEnum.getByFileType(fileType);
|
|
|
|
+ if (fileTypeEnum == null) {
|
|
|
|
+ throw new BaseException("错误的文件类型");
|
|
|
|
+ }
|
|
|
|
+ return new ResultVo<>(ossService.formUpload(fileTypeEnum.getFilePath(), type));
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|