Skip to content

Commit 5a9958c

Browse files
committed
chore: 补充文件上传相关接口的文档参数注解
1 parent 9d6d798 commit 5a9958c

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

continew-webapi/src/main/java/top/continew/admin/controller/common/CommonController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ public class CommonController {
6666
private final OptionService optionService;
6767

6868
@Operation(summary = "上传文件", description = "上传文件")
69+
@Parameter(name = "parentPath", description = "上级目录", example = "/", in = ParameterIn.QUERY)
6970
@PostMapping("/file")
70-
public FileUploadResp upload(@NotNull(message = "文件不能为空") MultipartFile file,
71-
String parentPath) throws IOException {
71+
public FileUploadResp upload(@NotNull(message = "文件不能为空") @RequestPart MultipartFile file,
72+
@RequestParam(required = false) String parentPath) throws IOException {
7273
ValidationUtils.throwIf(file::isEmpty, "文件不能为空");
7374
FileInfo fileInfo = fileService.upload(file, parentPath);
7475
return FileUploadResp.builder()

continew-webapi/src/main/java/top/continew/admin/controller/system/FileController.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import cn.dev33.satoken.annotation.SaCheckPermission;
2020
import io.swagger.v3.oas.annotations.Operation;
21+
import io.swagger.v3.oas.annotations.Parameter;
22+
import io.swagger.v3.oas.annotations.enums.ParameterIn;
2123
import io.swagger.v3.oas.annotations.tags.Tag;
2224
import jakarta.validation.Valid;
2325
import jakarta.validation.constraints.NotNull;
@@ -64,11 +66,12 @@ public class FileController extends BaseController<FileService, FileResp, FileRe
6466
* @return 文件上传响应参数
6567
* @throws IOException /
6668
*/
67-
@SaCheckPermission("system:file:upload")
6869
@Operation(summary = "上传文件", description = "上传文件")
70+
@Parameter(name = "parentPath", description = "上级目录", example = "/", in = ParameterIn.QUERY)
71+
@SaCheckPermission("system:file:upload")
6972
@PostMapping("/upload")
70-
public FileUploadResp upload(@NotNull(message = "文件不能为空") MultipartFile file,
71-
String parentPath) throws IOException {
73+
public FileUploadResp upload(@NotNull(message = "文件不能为空") @RequestPart MultipartFile file,
74+
@RequestParam(required = false) String parentPath) throws IOException {
7275
ValidationUtils.throwIf(file::isEmpty, "文件不能为空");
7376
FileInfo fileInfo = baseService.upload(file, parentPath);
7477
return FileUploadResp.builder()

continew-webapi/src/main/java/top/continew/admin/controller/system/UserController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void downloadImportTemplate(HttpServletResponse response) throws IOExcept
8686
@Operation(summary = "解析导入数据", description = "解析导入数据")
8787
@SaCheckPermission("system:user:import")
8888
@PostMapping("/import/parse")
89-
public UserImportParseResp parseImport(@NotNull(message = "文件不能为空") MultipartFile file) {
89+
public UserImportParseResp parseImport(@NotNull(message = "文件不能为空") @RequestPart MultipartFile file) {
9090
ValidationUtils.throwIf(file::isEmpty, "文件不能为空");
9191
return baseService.parseImport(file);
9292
}

0 commit comments

Comments
 (0)