mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 01:59:20 +08:00
feat: 迁移旧媒体文件到统一文件系统 sys/file
Backend: - SysFileController 新增 deleteFile + updateFile 接口 - 新增 SysFileUpdateDTO 用于更新文件元信息 - SysFileServiceImpl 实现 deleteFile + updateFile(带 companyId 校验) Frontend: - 导入订单页面改用 batchUploadFilesApi(返回 storagePath) - 文件管理页 media/file/index.vue 改用 system/file API - uploadFileApi → batchUploadFilesApi - url → accessUrl - updateFileApi 改用 system/file - FileEditModal 改用 system/file 类型和 API 旧媒体系统 (media/file) 不再使用,待后续清理。
This commit is contained in:
+18
@@ -5,12 +5,14 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import top.xyquan.ecomdmbbackend.common.annotation.RequireRole;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.file.model.dto.BatchCreateOssFileDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.file.model.dto.BatchSignUrlDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.file.model.dto.SysFileFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.file.model.dto.SysFileUpdateDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.file.model.vo.BatchSignUrlVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.file.model.vo.SysFileUploadVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.file.model.vo.SysFileVO;
|
||||
@@ -66,5 +68,21 @@ public class SysFileController {
|
||||
PageResultVO<SysFileVO> result = sysFileService.getFilePage(pageQueryDTO);
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除文件")
|
||||
@DeleteMapping("/{fileId}")
|
||||
@RequireRole(description = "删除文件")
|
||||
public ApiResponse<Void> deleteFile(@PathVariable Long fileId) {
|
||||
sysFileService.deleteFile(fileId);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "更新文件元信息")
|
||||
@PutMapping("/{fileId}")
|
||||
@RequireRole(description = "更新文件")
|
||||
public ApiResponse<Void> updateFile(@PathVariable Long fileId, @Valid @RequestBody SysFileUpdateDTO dto) {
|
||||
sysFileService.updateFile(fileId, dto);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.sys.file.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 更新文件元信息DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "更新文件元信息DTO")
|
||||
public class SysFileUpdateDTO {
|
||||
|
||||
@Schema(description = "标签,多个用逗号分隔")
|
||||
private String tags;
|
||||
|
||||
@Schema(description = "描述/备注")
|
||||
private String remark;
|
||||
}
|
||||
+16
@@ -6,6 +6,7 @@ import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.file.model.dto.BatchCreateOssFileDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.file.model.dto.BatchSignUrlDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.file.model.dto.SysFileFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.file.model.dto.SysFileUpdateDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.file.model.vo.BatchSignUrlVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.file.model.vo.SysFileUploadVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.file.model.vo.SysFileVO;
|
||||
@@ -65,5 +66,20 @@ public interface SysFileService {
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResultVO<SysFileVO> getFilePage(PageQueryDTO<SysFileFilterDTO> pageQueryDTO);
|
||||
|
||||
/**
|
||||
* 删除文件记录(物理文件通过定时任务或OSS生命周期策略清理)
|
||||
*
|
||||
* @param id 文件ID
|
||||
*/
|
||||
void deleteFile(Long id);
|
||||
|
||||
/**
|
||||
* 更新文件元信息(标签、描述)
|
||||
*
|
||||
* @param id 文件ID
|
||||
* @param dto 更新内容
|
||||
*/
|
||||
void updateFile(Long id, SysFileUpdateDTO dto);
|
||||
}
|
||||
|
||||
|
||||
+28
@@ -658,5 +658,33 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFilePO> im
|
||||
// 构建分页结果
|
||||
return PageResultVO.create(voList, pageResult.getTotal(), pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFile(Long id) {
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
SysFilePO file = this.getById(id);
|
||||
if (file == null || !file.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("文件不存在");
|
||||
}
|
||||
// 删除数据库记录(物理文件由OSS生命周期或定时任务清理)
|
||||
this.removeById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFile(Long id, SysFileUpdateDTO dto) {
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
SysFilePO file = this.getById(id);
|
||||
if (file == null || !file.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("文件不存在");
|
||||
}
|
||||
// 更新元信息
|
||||
if (dto.getTags() != null) {
|
||||
file.setTags(dto.getTags());
|
||||
}
|
||||
if (dto.getRemark() != null) {
|
||||
file.setRemark(dto.getRemark());
|
||||
}
|
||||
this.updateById(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user