mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
重构媒体模块
This commit is contained in:
-8
@@ -2,7 +2,6 @@ package top.xyquan.ecomdmbbackend.modules.ec.model.dto.order;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@@ -12,13 +11,6 @@ import lombok.Data;
|
||||
@Schema(description = "创建订单状态DTO")
|
||||
public class CreateOrderStatusDTO {
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
@Schema(description = "状态码", example = "0", required = true)
|
||||
@NotNull(message = "状态码不能为空")
|
||||
private Integer statusCode;
|
||||
|
||||
/**
|
||||
* 状态名称
|
||||
*/
|
||||
|
||||
-7
@@ -11,13 +11,6 @@ import lombok.Data;
|
||||
@Schema(description = "创建推广费类型DTO")
|
||||
public class CreatePromotionFeeTypeDTO {
|
||||
|
||||
/**
|
||||
* 类型编码
|
||||
*/
|
||||
@Schema(description = "类型编码", example = "DIRECT_TRAFFIC", required = true)
|
||||
@NotBlank(message = "类型编码不能为空")
|
||||
private String typeCode;
|
||||
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
|
||||
-1
@@ -27,7 +27,6 @@ import top.xyquan.ecomdmbbackend.modules.ec.service.ProductSpecService;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.service.ShopService;
|
||||
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
+5
-3
@@ -55,9 +55,11 @@ public class MediaFileController {
|
||||
}
|
||||
|
||||
@Operation(summary = "更新文件信息", description = "更新文件的元数据信息")
|
||||
@PutMapping("/update")
|
||||
public ApiResponse<MediaFileVO> updateFile(@Valid @RequestBody UpdateFileDTO updateFileDTO) {
|
||||
MediaFileVO mediaFileVO = mediaFileService.updateFile(updateFileDTO);
|
||||
@PutMapping("/update/{id}")
|
||||
public ApiResponse<MediaFileVO> updateFile(
|
||||
@Parameter(description = "文件ID") @PathVariable Long id,
|
||||
@Valid @RequestBody UpdateFileDTO updateFileDTO) {
|
||||
MediaFileVO mediaFileVO = mediaFileService.updateFile(id, updateFileDTO);
|
||||
return ApiResponse.success(mediaFileVO);
|
||||
}
|
||||
|
||||
|
||||
+5
-3
@@ -68,9 +68,11 @@ public class MediaImageController {
|
||||
}
|
||||
|
||||
@Operation(summary = "更新图片信息", description = "更新图片的元数据信息")
|
||||
@PutMapping("/update")
|
||||
public ApiResponse<MediaImageVO> updateImage(@Valid @RequestBody UpdateImageDTO updateImageDTO) {
|
||||
MediaImageVO mediaImageVO = mediaImageService.updateImage(updateImageDTO);
|
||||
@PutMapping("/update/{id}")
|
||||
public ApiResponse<MediaImageVO> updateImage(
|
||||
@Parameter(description = "图片ID") @PathVariable Long id,
|
||||
@Valid @RequestBody UpdateImageDTO updateImageDTO) {
|
||||
MediaImageVO mediaImageVO = mediaImageService.updateImage(id, updateImageDTO);
|
||||
return ApiResponse.success(mediaImageVO);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -27,9 +27,9 @@ public class MediaFileDTO {
|
||||
private String filename;
|
||||
|
||||
/**
|
||||
* 文件类型,如 PDF/CAD/Excel
|
||||
* 文件格式,如 pdf/cad/xlsx/doc
|
||||
*/
|
||||
private String fileType;
|
||||
private String fileFormat;
|
||||
|
||||
/**
|
||||
* 文件哈希值,用于去重
|
||||
|
||||
+2
-2
@@ -14,9 +14,9 @@ public class MediaFileFilterDTO {
|
||||
private String filename;
|
||||
|
||||
/**
|
||||
* 文件类型
|
||||
* 文件格式
|
||||
*/
|
||||
private String fileType;
|
||||
private String fileFormat;
|
||||
|
||||
/**
|
||||
* 标签
|
||||
|
||||
+7
-2
@@ -26,9 +26,14 @@ public class MediaImageDTO {
|
||||
private String filename;
|
||||
|
||||
/**
|
||||
* 图片分类 (设计图,实物图,细节图,工艺图,其他)
|
||||
* 图片分类 (image,avatar,logo)
|
||||
*/
|
||||
private String type;
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 图片格式,如 jpg/png/gif/webp
|
||||
*/
|
||||
private String imageFormat;
|
||||
|
||||
/**
|
||||
* 文件哈希值,用于去重
|
||||
|
||||
+10
@@ -13,6 +13,16 @@ public class MediaImageFilterDTO {
|
||||
*/
|
||||
private String filename;
|
||||
|
||||
/**
|
||||
* 图片分类
|
||||
*/
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 图片格式
|
||||
*/
|
||||
private String imageFormat;
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
|
||||
-13
@@ -2,25 +2,12 @@ package top.xyquan.ecomdmbbackend.modules.media.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 更新文件信息DTO
|
||||
*/
|
||||
@Data
|
||||
public class UpdateFileDTO {
|
||||
|
||||
/**
|
||||
* 文件ID
|
||||
*/
|
||||
@NotNull(message = "文件ID不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 文件类型,如 PDF/CAD/Excel
|
||||
*/
|
||||
private String fileType;
|
||||
|
||||
/**
|
||||
* 标签,逗号分隔
|
||||
*/
|
||||
|
||||
-13
@@ -2,25 +2,12 @@ package top.xyquan.ecomdmbbackend.modules.media.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 更新图片信息DTO
|
||||
*/
|
||||
@Data
|
||||
public class UpdateImageDTO {
|
||||
|
||||
/**
|
||||
* 图片ID
|
||||
*/
|
||||
@NotNull(message = "图片ID不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 图片分类
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 标签,逗号分隔
|
||||
*/
|
||||
|
||||
+3
-3
@@ -39,10 +39,10 @@ public class MediaFilePO {
|
||||
private String filename;
|
||||
|
||||
/**
|
||||
* 文件类型,如 PDF/CAD/Excel
|
||||
* 文件格式,如 pdf/cad/xlsx/doc
|
||||
*/
|
||||
@TableField("file_type")
|
||||
private String fileType;
|
||||
@TableField("file_format")
|
||||
private String fileFormat;
|
||||
|
||||
/**
|
||||
* 文件哈希值,用于去重
|
||||
|
||||
+8
-2
@@ -41,8 +41,14 @@ public class MediaImagePO {
|
||||
/**
|
||||
* 图片分类 (image,avatar,logo)
|
||||
*/
|
||||
@TableField("type")
|
||||
private String type;
|
||||
@TableField("category")
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 图片格式,如 jpg/png/gif/webp
|
||||
*/
|
||||
@TableField("image_format")
|
||||
private String imageFormat;
|
||||
|
||||
/**
|
||||
* 文件哈希值,用于去重
|
||||
|
||||
+2
-2
@@ -31,9 +31,9 @@ public class MediaFileVO {
|
||||
private String filename;
|
||||
|
||||
/**
|
||||
* 文件类型,如 PDF/CAD/Excel
|
||||
* 文件格式,如 pdf/cad/xlsx/doc
|
||||
*/
|
||||
private String fileType;
|
||||
private String fileFormat;
|
||||
|
||||
/**
|
||||
* 文件哈希值,用于去重
|
||||
|
||||
+7
-2
@@ -31,9 +31,14 @@ public class MediaImageVO {
|
||||
private String filename;
|
||||
|
||||
/**
|
||||
* 图片分类 (设计图,实物图,细节图,工艺图,其他)
|
||||
* 图片分类 (image,avatar,logo)
|
||||
*/
|
||||
private String type;
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 图片格式,如 jpg/png/gif/webp
|
||||
*/
|
||||
private String imageFormat;
|
||||
|
||||
/**
|
||||
* 文件哈希值,用于去重
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ public interface MediaFileService {
|
||||
/**
|
||||
* 更新文件信息
|
||||
*/
|
||||
MediaFileVO updateFile(UpdateFileDTO updateFileDTO);
|
||||
MediaFileVO updateFile(Long id, UpdateFileDTO updateFileDTO);
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
|
||||
+5
-5
@@ -27,7 +27,7 @@ public interface MediaImageService {
|
||||
/**
|
||||
* 更新图片信息
|
||||
*/
|
||||
MediaImageVO updateImage(UpdateImageDTO updateImageDTO);
|
||||
MediaImageVO updateImage(Long id, UpdateImageDTO updateImageDTO);
|
||||
|
||||
/**
|
||||
* 删除图片
|
||||
@@ -55,12 +55,12 @@ public interface MediaImageService {
|
||||
PageResultVO<MediaImageVO> getImagePage(PageQueryDTO<MediaImageFilterDTO> pageQueryDTO);
|
||||
|
||||
/**
|
||||
* 根据文件哈希和类型查询图片信息
|
||||
* 根据文件哈希和分类查询图片信息
|
||||
*/
|
||||
MediaImageVO getImageByHashAndType(String fileHash, String type);
|
||||
MediaImageVO getImageByHashAndType(String fileHash, String category);
|
||||
|
||||
/**
|
||||
* 上传指定类型的图片
|
||||
* 上传指定分类的图片
|
||||
*/
|
||||
MediaImageVO uploadImageWithType(MultipartFile file, String type);
|
||||
MediaImageVO uploadImageWithType(MultipartFile file, String category);
|
||||
}
|
||||
|
||||
+10
-11
@@ -47,8 +47,8 @@ public class MediaFileServiceImpl extends ServiceImpl<MediaFileMapper, MediaFile
|
||||
// 计算文件哈希
|
||||
String fileHash = FileHashUtils.calculateFileHash(file);
|
||||
|
||||
// 通过文件后缀判断文件类型
|
||||
String fileType = FileUploadUtils.getFileExtension(file.getOriginalFilename());
|
||||
// 通过文件后缀判断文件格式
|
||||
String fileFormat = FileUploadUtils.getFileExtension(file.getOriginalFilename()).toLowerCase();
|
||||
|
||||
// 检查当前公司是否已有相同哈希的文件且文件存在
|
||||
List<MediaFilePO> existingFiles = baseMapper.selectByFileHashes(List.of(fileHash));
|
||||
@@ -82,7 +82,7 @@ public class MediaFileServiceImpl extends ServiceImpl<MediaFileMapper, MediaFile
|
||||
mediaFile.setCompanyId(companyId);
|
||||
mediaFile.setUrl(fileUrl);
|
||||
mediaFile.setFilename(file.getOriginalFilename());
|
||||
mediaFile.setFileType(fileType);
|
||||
mediaFile.setFileFormat(fileFormat);
|
||||
mediaFile.setFileHash(fileHash);
|
||||
mediaFile.setUploadBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
@@ -111,12 +111,12 @@ public class MediaFileServiceImpl extends ServiceImpl<MediaFileMapper, MediaFile
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public MediaFileVO updateFile(UpdateFileDTO updateFileDTO) {
|
||||
public MediaFileVO updateFile(Long id, UpdateFileDTO updateFileDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 检查文件是否存在且属于当前公司
|
||||
MediaFilePO existingFile = this.getById(updateFileDTO.getId());
|
||||
MediaFilePO existingFile = this.getById(id);
|
||||
if (existingFile == null) {
|
||||
throw new BusinessException("文件不存在");
|
||||
}
|
||||
@@ -126,10 +126,9 @@ public class MediaFileServiceImpl extends ServiceImpl<MediaFileMapper, MediaFile
|
||||
throw new BusinessException("无权操作此文件");
|
||||
}
|
||||
|
||||
// 更新文件信息
|
||||
// 更新文件信息(不更新文件格式字段,格式在创建时确定后不可修改)
|
||||
MediaFilePO mediaFile = new MediaFilePO();
|
||||
mediaFile.setId(updateFileDTO.getId());
|
||||
mediaFile.setFileType(updateFileDTO.getFileType());
|
||||
mediaFile.setId(id);
|
||||
mediaFile.setTags(updateFileDTO.getTags());
|
||||
mediaFile.setRemark(updateFileDTO.getRemark());
|
||||
mediaFile.setUpdateBy(currentUserContext.getCurrentUserId()); // 记录更新人
|
||||
@@ -138,7 +137,7 @@ public class MediaFileServiceImpl extends ServiceImpl<MediaFileMapper, MediaFile
|
||||
this.updateById(mediaFile);
|
||||
|
||||
// 重新查询更新后的记录
|
||||
MediaFilePO updatedFile = this.getById(updateFileDTO.getId());
|
||||
MediaFilePO updatedFile = this.getById(id);
|
||||
return convertToVO(updatedFile);
|
||||
}
|
||||
|
||||
@@ -217,8 +216,8 @@ public class MediaFileServiceImpl extends ServiceImpl<MediaFileMapper, MediaFile
|
||||
if (filter.getFilename() != null && !filter.getFilename().trim().isEmpty()) {
|
||||
wrapper.like(MediaFilePO::getFilename, filter.getFilename());
|
||||
}
|
||||
if (filter.getFileType() != null && !filter.getFileType().trim().isEmpty()) {
|
||||
wrapper.eq(MediaFilePO::getFileType, filter.getFileType());
|
||||
if (filter.getFileFormat() != null && !filter.getFileFormat().trim().isEmpty()) {
|
||||
wrapper.eq(MediaFilePO::getFileFormat, filter.getFileFormat());
|
||||
}
|
||||
if (filter.getTags() != null && !filter.getTags().trim().isEmpty()) {
|
||||
wrapper.like(MediaFilePO::getTags, filter.getTags());
|
||||
|
||||
+30
-23
@@ -47,8 +47,11 @@ public class MediaImageServiceImpl extends ServiceImpl<MediaImageMapper, MediaIm
|
||||
// 计算文件哈希
|
||||
String fileHash = FileHashUtils.calculateFileHash(file);
|
||||
|
||||
// 设置图片类型默认值
|
||||
String type = "image";
|
||||
// 设置图片分类默认值
|
||||
String category = "image";
|
||||
|
||||
// 通过文件后缀判断图片格式
|
||||
String imageFormat = FileUploadUtils.getFileExtension(file.getOriginalFilename()).toLowerCase();
|
||||
|
||||
// 检查当前公司是否已有相同哈希的图片且文件存在
|
||||
List<MediaImagePO> existingImages = baseMapper.selectByFileHashes(List.of(fileHash));
|
||||
@@ -82,7 +85,8 @@ public class MediaImageServiceImpl extends ServiceImpl<MediaImageMapper, MediaIm
|
||||
mediaImage.setCompanyId(companyId);
|
||||
mediaImage.setUrl(fileUrl);
|
||||
mediaImage.setFilename(file.getOriginalFilename());
|
||||
mediaImage.setType(type);
|
||||
mediaImage.setCategory(category);
|
||||
mediaImage.setImageFormat(imageFormat);
|
||||
mediaImage.setFileHash(fileHash);
|
||||
mediaImage.setUploadBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
@@ -111,12 +115,12 @@ public class MediaImageServiceImpl extends ServiceImpl<MediaImageMapper, MediaIm
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public MediaImageVO updateImage(UpdateImageDTO updateImageDTO) {
|
||||
public MediaImageVO updateImage(Long id, UpdateImageDTO updateImageDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 检查图片是否存在且属于当前公司
|
||||
MediaImagePO existingImage = this.getById(updateImageDTO.getId());
|
||||
MediaImagePO existingImage = this.getById(id);
|
||||
if (existingImage == null) {
|
||||
throw new BusinessException("图片不存在");
|
||||
}
|
||||
@@ -126,24 +130,18 @@ public class MediaImageServiceImpl extends ServiceImpl<MediaImageMapper, MediaIm
|
||||
throw new BusinessException("无权操作此图片");
|
||||
}
|
||||
|
||||
// 更新图片信息
|
||||
// 更新图片信息(不更新分类和格式字段,这些字段在创建时确定后不可修改)
|
||||
MediaImagePO mediaImage = new MediaImagePO();
|
||||
mediaImage.setId(updateImageDTO.getId());
|
||||
mediaImage.setType(updateImageDTO.getType());
|
||||
mediaImage.setId(id);
|
||||
mediaImage.setTags(updateImageDTO.getTags());
|
||||
mediaImage.setRemark(updateImageDTO.getRemark());
|
||||
mediaImage.setUpdateBy(currentUserContext.getCurrentUserId()); // 记录更新人
|
||||
|
||||
// 设置默认值
|
||||
if (mediaImage.getType() == null) {
|
||||
mediaImage.setType("其他");
|
||||
}
|
||||
|
||||
// 更新图片记录
|
||||
this.updateById(mediaImage);
|
||||
|
||||
// 重新查询更新后的记录
|
||||
MediaImagePO updatedImage = this.getById(updateImageDTO.getId());
|
||||
MediaImagePO updatedImage = this.getById(id);
|
||||
return convertToVO(updatedImage);
|
||||
}
|
||||
|
||||
@@ -223,7 +221,6 @@ public class MediaImageServiceImpl extends ServiceImpl<MediaImageMapper, MediaIm
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<MediaImagePO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(MediaImagePO::getCompanyId, companyId)
|
||||
.eq(MediaImagePO::getType, "image") // 固定查询image类型
|
||||
.isNull(MediaImagePO::getDeleteTime);
|
||||
|
||||
// 添加过滤条件
|
||||
@@ -232,6 +229,12 @@ public class MediaImageServiceImpl extends ServiceImpl<MediaImageMapper, MediaIm
|
||||
if (filter.getFilename() != null && !filter.getFilename().trim().isEmpty()) {
|
||||
wrapper.like(MediaImagePO::getFilename, filter.getFilename());
|
||||
}
|
||||
if (filter.getCategory() != null && !filter.getCategory().trim().isEmpty()) {
|
||||
wrapper.eq(MediaImagePO::getCategory, filter.getCategory());
|
||||
}
|
||||
if (filter.getImageFormat() != null && !filter.getImageFormat().trim().isEmpty()) {
|
||||
wrapper.eq(MediaImagePO::getImageFormat, filter.getImageFormat());
|
||||
}
|
||||
if (filter.getTags() != null && !filter.getTags().trim().isEmpty()) {
|
||||
wrapper.like(MediaImagePO::getTags, filter.getTags());
|
||||
}
|
||||
@@ -260,9 +263,9 @@ public class MediaImageServiceImpl extends ServiceImpl<MediaImageMapper, MediaIm
|
||||
|
||||
List<MediaImagePO> mediaImages = baseMapper.selectByFileHashes(List.of(fileHash));
|
||||
|
||||
// 查找指定类型且文件存在的图片
|
||||
// 查找指定分类且文件存在的图片
|
||||
MediaImagePO mediaImage = mediaImages.stream()
|
||||
.filter(img -> type.equals(img.getType()) && FileHashUtils.fileExists(img.getUrl()))
|
||||
.filter(img -> type.equals(img.getCategory()) && FileHashUtils.fileExists(img.getUrl()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
@@ -270,15 +273,18 @@ public class MediaImageServiceImpl extends ServiceImpl<MediaImageMapper, MediaIm
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaImageVO uploadImageWithType(MultipartFile file, String type) {
|
||||
public MediaImageVO uploadImageWithType(MultipartFile file, String category) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 计算文件哈希
|
||||
String fileHash = FileHashUtils.calculateFileHash(file);
|
||||
|
||||
// 检查是否已有相同哈希和类型的图片(支持跨公司共享)
|
||||
MediaImageVO existingImage = getImageByHashAndType(fileHash, type);
|
||||
// 通过文件后缀判断图片格式
|
||||
String imageFormat = FileUploadUtils.getFileExtension(file.getOriginalFilename()).toLowerCase();
|
||||
|
||||
// 检查是否已有相同哈希和分类的图片(支持跨公司共享)
|
||||
MediaImageVO existingImage = getImageByHashAndType(fileHash, category);
|
||||
if (existingImage != null) {
|
||||
// 如果已存在,直接返回现有记录
|
||||
return existingImage;
|
||||
@@ -286,9 +292,9 @@ public class MediaImageServiceImpl extends ServiceImpl<MediaImageMapper, MediaIm
|
||||
|
||||
// 上传文件到对应目录
|
||||
String fileUrl;
|
||||
if ("avatar".equals(type)) {
|
||||
if ("avatar".equals(category)) {
|
||||
fileUrl = FileUploadUtils.uploadAvatar(file);
|
||||
} else if ("logo".equals(type)) {
|
||||
} else if ("logo".equals(category)) {
|
||||
fileUrl = FileUploadUtils.uploadLogo(file);
|
||||
} else {
|
||||
fileUrl = FileUploadUtils.uploadImage(file);
|
||||
@@ -299,7 +305,8 @@ public class MediaImageServiceImpl extends ServiceImpl<MediaImageMapper, MediaIm
|
||||
mediaImage.setCompanyId(companyId);
|
||||
mediaImage.setUrl(fileUrl);
|
||||
mediaImage.setFilename(file.getOriginalFilename());
|
||||
mediaImage.setType(type);
|
||||
mediaImage.setCategory(category);
|
||||
mediaImage.setImageFormat(imageFormat);
|
||||
mediaImage.setFileHash(fileHash);
|
||||
mediaImage.setUploadBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ CREATE TABLE `media_file` (
|
||||
`company_id` bigint unsigned NOT NULL,
|
||||
`url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '文件URL',
|
||||
`filename` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '文件名',
|
||||
`file_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '文件类型,如 PDF/CAD/Excel',
|
||||
`file_format` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '文件格式,如 pdf/cad/xlsx/doc',
|
||||
`file_hash` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '文件哈希值,用于去重',
|
||||
`tags` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '标签,逗号分隔',
|
||||
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '文件描述',
|
||||
@@ -17,6 +17,7 @@ CREATE TABLE `media_file` (
|
||||
KEY `fk_media_file_company` (`company_id`) USING BTREE,
|
||||
KEY `fk_media_file_uploader` (`upload_by`) USING BTREE,
|
||||
KEY `idx_media_file_hash` (`file_hash`) USING BTREE COMMENT '文件哈希索引,用于快速查找',
|
||||
KEY `idx_media_file_format` (`file_format`) USING BTREE COMMENT '文件格式索引',
|
||||
CONSTRAINT `fk_media_file_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_media_file_uploader` FOREIGN KEY (`upload_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='文件资源池表';
|
||||
@@ -26,7 +27,8 @@ CREATE TABLE `media_image` (
|
||||
`company_id` bigint unsigned NOT NULL,
|
||||
`url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '图片URL',
|
||||
`filename` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '原始文件名',
|
||||
`type` enum('image','avatar','logo') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT 'image' COMMENT '图片分类',
|
||||
`category` enum('image','avatar','logo') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT 'image' COMMENT '图片分类',
|
||||
`image_format` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '图片格式,如 jpg/png/gif/webp',
|
||||
`file_hash` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '文件哈希值,用于去重',
|
||||
`tags` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '标签,逗号分隔如 spring,工艺图,客户A',
|
||||
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '图片说明',
|
||||
@@ -40,6 +42,8 @@ CREATE TABLE `media_image` (
|
||||
KEY `fk_media_image_company` (`company_id`) USING BTREE,
|
||||
KEY `fk_media_image_uploader` (`upload_by`) USING BTREE,
|
||||
KEY `idx_media_image_hash` (`file_hash`) USING BTREE COMMENT '图片哈希索引,用于快速查找',
|
||||
KEY `idx_media_image_category` (`category`) USING BTREE COMMENT '图片分类索引',
|
||||
KEY `idx_media_image_format` (`image_format`) USING BTREE COMMENT '图片格式索引',
|
||||
CONSTRAINT `fk_media_image_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_media_image_uploader` FOREIGN KEY (`upload_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='图片资源池表';
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 304 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 251 KiB |
|
Before Width: | Height: | Size: 294 KiB After Width: | Height: | Size: 294 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 294 KiB |
Reference in New Issue
Block a user