mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-11 06:57:12 +08:00
feat(system/file): 文件管理呈目录形式展示 (#151)
This commit is contained in:
@@ -35,6 +35,7 @@ import top.continew.admin.system.enums.OptionCategoryEnum;
|
||||
import top.continew.admin.system.model.query.*;
|
||||
import top.continew.admin.system.model.resp.file.FileUploadResp;
|
||||
import top.continew.admin.system.service.*;
|
||||
import top.continew.starter.core.constant.StringConstants;
|
||||
import top.continew.starter.core.validation.ValidationUtils;
|
||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
|
||||
@@ -66,9 +67,11 @@ public class CommonController {
|
||||
|
||||
@Operation(summary = "上传文件", description = "上传文件")
|
||||
@PostMapping("/file")
|
||||
public FileUploadResp upload(@NotNull(message = "文件不能为空") MultipartFile file) {
|
||||
public FileUploadResp upload(@NotNull(message = "文件不能为空") MultipartFile file, String path) {
|
||||
ValidationUtils.throwIf(file::isEmpty, "文件不能为空");
|
||||
FileInfo fileInfo = fileService.upload(file);
|
||||
FileInfo fileInfo = fileService.upload(file, StrUtil.isNotBlank(path)
|
||||
? StrUtil.appendIfMissing(path, StringConstants.SLASH)
|
||||
: "/");
|
||||
return FileUploadResp.builder()
|
||||
.id(fileInfo.getId())
|
||||
.url(fileInfo.getUrl())
|
||||
|
@@ -20,8 +20,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.continew.admin.common.controller.BaseController;
|
||||
import top.continew.admin.system.model.query.FileQuery;
|
||||
import top.continew.admin.system.model.req.FileReq;
|
||||
@@ -30,6 +29,7 @@ import top.continew.admin.system.model.resp.file.FileStatisticsResp;
|
||||
import top.continew.admin.system.service.FileService;
|
||||
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
|
||||
import top.continew.starter.extension.crud.enums.Api;
|
||||
import top.continew.starter.extension.crud.model.resp.IdResp;
|
||||
import top.continew.starter.log.annotation.Log;
|
||||
|
||||
/**
|
||||
@@ -51,4 +51,19 @@ public class FileController extends BaseController<FileService, FileResp, FileRe
|
||||
public FileStatisticsResp statistics() {
|
||||
return baseService.statistics();
|
||||
}
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "检测文件是否存在", description = "检测文件是否存在")
|
||||
@SaCheckPermission("system:file:check")
|
||||
@GetMapping("/check")
|
||||
public FileResp checkFile(String fileHash) {
|
||||
return baseService.check(fileHash);
|
||||
}
|
||||
|
||||
@Operation(summary = "创建文件夹", description = "创建文件夹")
|
||||
@ResponseBody
|
||||
@PostMapping("/createDir")
|
||||
public IdResp<Long> createDir(@RequestBody FileReq req) {
|
||||
return baseService.createDir(req);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user