|
@@ -6,6 +6,9 @@ import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.common.SysFileDO
|
|
|
import cn.iocoder.dashboard.modules.system.service.common.SysFileService;
|
|
|
import cn.iocoder.dashboard.util.servlet.ServletUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -13,7 +16,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-
|
|
|
import java.io.IOException;
|
|
|
|
|
|
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
|
|
@@ -27,12 +29,19 @@ public class SysFileController {
|
|
|
@Resource
|
|
|
private SysFileService fileService;
|
|
|
|
|
|
+ @ApiOperation("上传文件")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "path", value = "文件附件", required = true, dataTypeClass = MultipartFile.class),
|
|
|
+ @ApiImplicitParam(name = "path", value = "文件路径", required = true, example = "yudaoyuanma.png", dataTypeClass = Long.class)
|
|
|
+ })
|
|
|
@PostMapping("/upload")
|
|
|
public CommonResult<String> uploadFile(@RequestParam("file") MultipartFile file,
|
|
|
@RequestParam("path") String path) throws IOException {
|
|
|
return success(fileService.createFile(path, IoUtil.readBytes(file.getInputStream())));
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("下载文件")
|
|
|
+ @ApiImplicitParam(name = "path", value = "文件附件", required = true, dataTypeClass = MultipartFile.class)
|
|
|
@GetMapping("/get/{path}")
|
|
|
public void getFile(HttpServletResponse response, @PathVariable("path") String path) throws IOException {
|
|
|
SysFileDO file = fileService.getFile(path);
|