mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-10-27 18:57:14 +08:00
refactor(system): 优化文件相关类的属性顺序和注释,增强代码可读性
- 优化文件相关类的属性顺序和注释,增强代码可读性 - 优化 File、Message 相关代码的包结构
This commit is contained in:
@@ -61,21 +61,12 @@ public class FileRecorderImpl implements FileRecorder {
|
|||||||
fileInfo.setId(id.longValue() + "");
|
fileInfo.setId(id.longValue() + "");
|
||||||
String originalFilename = EscapeUtil.unescape(fileInfo.getOriginalFilename());
|
String originalFilename = EscapeUtil.unescape(fileInfo.getOriginalFilename());
|
||||||
file.setName(StrUtil.contains(originalFilename, StringConstants.DOT)
|
file.setName(StrUtil.contains(originalFilename, StringConstants.DOT)
|
||||||
? StrUtil.subBefore(originalFilename, StringConstants.DOT, true)
|
? StrUtil.subBefore(originalFilename, StringConstants.DOT, true)
|
||||||
: originalFilename);
|
: originalFilename);
|
||||||
file.setUrl(fileInfo.getUrl());
|
file.setUrl(fileInfo.getUrl());
|
||||||
file.setSize(fileInfo.getSize());
|
file.setSize(fileInfo.getSize());
|
||||||
file.setExtension(fileInfo.getExt());
|
|
||||||
file.setType(FileTypeEnum.getByExtension(file.getExtension()));
|
|
||||||
file.setThumbnailUrl(fileInfo.getThUrl());
|
|
||||||
file.setThumbnailSize(fileInfo.getThSize());
|
|
||||||
StorageDO storage = (StorageDO) fileInfo.getAttr().get(ClassUtil.getClassName(StorageDO.class, false));
|
|
||||||
file.setStorageId(storage.getId());
|
|
||||||
file.setCreateTime(DateUtil.toLocalDateTime(fileInfo.getCreateTime()));
|
|
||||||
file.setUpdateUser(UserContextHolder.getUserId());
|
|
||||||
file.setUpdateTime(file.getCreateTime());
|
|
||||||
String absPath = fileInfo.getPath();
|
String absPath = fileInfo.getPath();
|
||||||
if (absPath.endsWith("/")) {
|
if (absPath.endsWith(StringConstants.SLASH)) {
|
||||||
String tempAbsPath = absPath.substring(0, absPath.length() - 1);
|
String tempAbsPath = absPath.substring(0, absPath.length() - 1);
|
||||||
String[] pathArr = tempAbsPath.split(StringConstants.SLASH);
|
String[] pathArr = tempAbsPath.split(StringConstants.SLASH);
|
||||||
if (pathArr.length > 1) {
|
if (pathArr.length > 1) {
|
||||||
@@ -84,11 +75,20 @@ public class FileRecorderImpl implements FileRecorder {
|
|||||||
file.setParentPath(StringConstants.SLASH);
|
file.setParentPath(StringConstants.SLASH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file.setMd5(fileInfo.getHashInfo().getMd5());
|
|
||||||
file.setAbsPath(fileInfo.getPath());
|
file.setAbsPath(fileInfo.getPath());
|
||||||
file.setMetadata(JSONUtil.toJsonStr(fileInfo.getMetadata()));
|
file.setExtension(fileInfo.getExt());
|
||||||
file.setThumbnailMetadata(JSONUtil.toJsonStr(fileInfo.getThMetadata()));
|
file.setType(FileTypeEnum.getByExtension(file.getExtension()));
|
||||||
file.setContentType(fileInfo.getContentType());
|
file.setContentType(fileInfo.getContentType());
|
||||||
|
file.setMd5(fileInfo.getHashInfo().getMd5());
|
||||||
|
file.setMetadata(JSONUtil.toJsonStr(fileInfo.getMetadata()));
|
||||||
|
file.setThumbnailUrl(fileInfo.getThUrl());
|
||||||
|
file.setThumbnailSize(fileInfo.getThSize());
|
||||||
|
file.setThumbnailMetadata(JSONUtil.toJsonStr(fileInfo.getThMetadata()));
|
||||||
|
StorageDO storage = (StorageDO)fileInfo.getAttr().get(ClassUtil.getClassName(StorageDO.class, false));
|
||||||
|
file.setStorageId(storage.getId());
|
||||||
|
file.setCreateTime(DateUtil.toLocalDateTime(fileInfo.getCreateTime()));
|
||||||
|
file.setUpdateUser(UserContextHolder.getUserId());
|
||||||
|
file.setUpdateTime(file.getCreateTime());
|
||||||
fileMapper.insert(file);
|
fileMapper.insert(file);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -133,8 +133,8 @@ public class FileRecorderImpl implements FileRecorder {
|
|||||||
private FileDO getFileByUrl(String url) {
|
private FileDO getFileByUrl(String url) {
|
||||||
Optional<FileDO> fileOptional = fileMapper.lambdaQuery().eq(FileDO::getUrl, url).oneOpt();
|
Optional<FileDO> fileOptional = fileMapper.lambdaQuery().eq(FileDO::getUrl, url).oneOpt();
|
||||||
return fileOptional.orElseGet(() -> fileMapper.lambdaQuery()
|
return fileOptional.orElseGet(() -> fileMapper.lambdaQuery()
|
||||||
.likeLeft(FileDO::getUrl, StrUtil.subAfter(url, StringConstants.SLASH, true))
|
.likeLeft(FileDO::getUrl, StrUtil.subAfter(url, StringConstants.SLASH, true))
|
||||||
.oneOpt()
|
.oneOpt()
|
||||||
.orElse(null));
|
.orElse(null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ public enum FileTypeEnum implements BaseEnum<Integer> {
|
|||||||
* 图片
|
* 图片
|
||||||
*/
|
*/
|
||||||
IMAGE(2, "图片", List
|
IMAGE(2, "图片", List
|
||||||
.of("jpg", "jpeg", "png", "gif", "bmp", "webp", "ico", "psd", "tiff", "dwg", "jxr", "apng", "xcf")),
|
.of("jpg", "jpeg", "png", "gif", "bmp", "webp", "ico", "psd", "tiff", "dwg", "jxr", "apng", "xcf")),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文档
|
* 文档
|
||||||
@@ -64,8 +64,7 @@ public enum FileTypeEnum implements BaseEnum<Integer> {
|
|||||||
/**
|
/**
|
||||||
* 音频
|
* 音频
|
||||||
*/
|
*/
|
||||||
AUDIO(5, "音频", List.of("mp3", "flac", "wav", "ogg", "midi", "m4a", "aac", "amr", "ac3", "aiff")),
|
AUDIO(5, "音频", List.of("mp3", "flac", "wav", "ogg", "midi", "m4a", "aac", "amr", "ac3", "aiff")),;
|
||||||
;
|
|
||||||
|
|
||||||
private final Integer value;
|
private final Integer value;
|
||||||
private final String description;
|
private final String description;
|
||||||
@@ -79,8 +78,8 @@ public enum FileTypeEnum implements BaseEnum<Integer> {
|
|||||||
*/
|
*/
|
||||||
public static FileTypeEnum getByExtension(String extension) {
|
public static FileTypeEnum getByExtension(String extension) {
|
||||||
return Arrays.stream(FileTypeEnum.values())
|
return Arrays.stream(FileTypeEnum.values())
|
||||||
.filter(t -> t.getExtensions().contains(StrUtil.emptyIfNull(extension).toLowerCase()))
|
.filter(t -> t.getExtensions().contains(StrUtil.emptyIfNull(extension).toLowerCase()))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(FileTypeEnum.UNKNOWN);
|
.orElse(FileTypeEnum.UNKNOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package top.continew.admin.system.mapper;
|
|||||||
|
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
import top.continew.admin.system.model.entity.FileDO;
|
import top.continew.admin.system.model.entity.FileDO;
|
||||||
import top.continew.admin.system.model.resp.FileStatisticsResp;
|
import top.continew.admin.system.model.resp.file.FileStatisticsResp;
|
||||||
import top.continew.starter.data.mp.base.BaseMapper;
|
import top.continew.starter.data.mp.base.BaseMapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import top.continew.admin.system.model.entity.MessageDO;
|
import top.continew.admin.system.model.entity.MessageDO;
|
||||||
import top.continew.admin.system.model.resp.MessageResp;
|
import top.continew.admin.system.model.resp.message.MessageResp;
|
||||||
import top.continew.starter.data.mp.base.BaseMapper;
|
import top.continew.starter.data.mp.base.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -70,43 +70,43 @@ public class FileDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
private String absPath;
|
private String absPath;
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件元数据
|
|
||||||
*/
|
|
||||||
private String metadata;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件类型
|
|
||||||
*/
|
|
||||||
private String contentType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件md5值
|
|
||||||
*/
|
|
||||||
private String md5;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扩展名
|
* 扩展名
|
||||||
*/
|
*/
|
||||||
private String extension;
|
private String extension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容类型
|
||||||
|
*/
|
||||||
|
private String contentType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类型
|
* 类型
|
||||||
*/
|
*/
|
||||||
private FileTypeEnum type;
|
private FileTypeEnum type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MD5 值
|
||||||
|
*/
|
||||||
|
private String md5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 元数据
|
||||||
|
*/
|
||||||
|
private String metadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缩略图大小(字节)
|
* 缩略图大小(字节)
|
||||||
*/
|
*/
|
||||||
private Long thumbnailSize;
|
private Long thumbnailSize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缩略图URL
|
* 缩略图 URL
|
||||||
*/
|
*/
|
||||||
private String thumbnailUrl;
|
private String thumbnailUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件元数据
|
* 缩略图元数据
|
||||||
*/
|
*/
|
||||||
private String thumbnailMetadata;
|
private String thumbnailMetadata;
|
||||||
|
|
||||||
@@ -126,10 +126,10 @@ public class FileDO extends BaseDO {
|
|||||||
fileInfo.setUrl(this.url);
|
fileInfo.setUrl(this.url);
|
||||||
fileInfo.setSize(this.size);
|
fileInfo.setSize(this.size);
|
||||||
fileInfo.setFilename(StrUtil.contains(this.url, StringConstants.SLASH)
|
fileInfo.setFilename(StrUtil.contains(this.url, StringConstants.SLASH)
|
||||||
? StrUtil.subAfter(this.url, StringConstants.SLASH, true)
|
? StrUtil.subAfter(this.url, StringConstants.SLASH, true)
|
||||||
: this.url);
|
: this.url);
|
||||||
fileInfo.setOriginalFilename(StrUtils
|
fileInfo.setOriginalFilename(StrUtils
|
||||||
.blankToDefault(this.extension, this.name, ex -> this.name + StringConstants.DOT + ex));
|
.blankToDefault(this.extension, this.name, ex -> this.name + StringConstants.DOT + ex));
|
||||||
fileInfo.setBasePath(StringConstants.EMPTY);
|
fileInfo.setBasePath(StringConstants.EMPTY);
|
||||||
// 优化 path 处理
|
// 优化 path 处理
|
||||||
fileInfo.setPath(extractRelativePath(this.url, storageDO));
|
fileInfo.setPath(extractRelativePath(this.url, storageDO));
|
||||||
@@ -138,8 +138,8 @@ public class FileDO extends BaseDO {
|
|||||||
fileInfo.setPlatform(storageDO.getCode());
|
fileInfo.setPlatform(storageDO.getCode());
|
||||||
fileInfo.setThUrl(this.thumbnailUrl);
|
fileInfo.setThUrl(this.thumbnailUrl);
|
||||||
fileInfo.setThFilename(StrUtil.contains(this.thumbnailUrl, StringConstants.SLASH)
|
fileInfo.setThFilename(StrUtil.contains(this.thumbnailUrl, StringConstants.SLASH)
|
||||||
? StrUtil.subAfter(this.thumbnailUrl, StringConstants.SLASH, true)
|
? StrUtil.subAfter(this.thumbnailUrl, StringConstants.SLASH, true)
|
||||||
: this.thumbnailUrl);
|
: this.thumbnailUrl);
|
||||||
fileInfo.setThSize(this.thumbnailSize);
|
fileInfo.setThSize(this.thumbnailSize);
|
||||||
if (StrUtil.isNotBlank(this.thumbnailMetadata)) {
|
if (StrUtil.isNotBlank(this.thumbnailMetadata)) {
|
||||||
fileInfo.setThMetadata(JSONUtil.toBean(this.thumbnailMetadata, Map.class));
|
fileInfo.setThMetadata(JSONUtil.toBean(this.thumbnailMetadata, Map.class));
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package top.continew.admin.system.model.resp;
|
package top.continew.admin.system.model.resp.file;
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
@@ -68,36 +68,36 @@ public class FileResp extends BaseDetailResp {
|
|||||||
@Schema(description = "绝对路径", example = "/2025/2/25")
|
@Schema(description = "绝对路径", example = "/2025/2/25")
|
||||||
private String absPath;
|
private String absPath;
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件元数据
|
|
||||||
*/
|
|
||||||
@Schema(description = "文件元数据", example = "{width:1024,height:1024}")
|
|
||||||
private String metadata;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件md5值
|
|
||||||
*/
|
|
||||||
@Schema(description = "文件md5值", example = "abcdefghijklmnopqrstuvwxyz0123456789")
|
|
||||||
private String md5;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件类型
|
|
||||||
*/
|
|
||||||
@Schema(description = "文件md5值", example = "abcdefghijklmnopqrstuvwxyz0123456789")
|
|
||||||
private String contentType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扩展名
|
* 扩展名
|
||||||
*/
|
*/
|
||||||
@Schema(description = "扩展名", example = "jpg")
|
@Schema(description = "扩展名", example = "jpg")
|
||||||
private String extension;
|
private String extension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容类型
|
||||||
|
*/
|
||||||
|
@Schema(description = "内容类型", example = "image/jpeg")
|
||||||
|
private String contentType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类型
|
* 类型
|
||||||
*/
|
*/
|
||||||
@Schema(description = "类型", example = "2")
|
@Schema(description = "类型", example = "2")
|
||||||
private FileTypeEnum type;
|
private FileTypeEnum type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MD5 值
|
||||||
|
*/
|
||||||
|
@Schema(description = "MD5值", example = "193572f83684128a0d0f993e97100f8a")
|
||||||
|
private String md5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 元数据
|
||||||
|
*/
|
||||||
|
@Schema(description = "元数据", example = "{width:1024,height:1024}")
|
||||||
|
private String metadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缩略图大小(字节)
|
* 缩略图大小(字节)
|
||||||
*/
|
*/
|
||||||
@@ -111,7 +111,7 @@ public class FileResp extends BaseDetailResp {
|
|||||||
private String thumbnailUrl;
|
private String thumbnailUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缩略图文件元数据
|
* 缩略图元数据
|
||||||
*/
|
*/
|
||||||
@Schema(description = "缩略图文件元数据", example = "{width:100,height:100}")
|
@Schema(description = "缩略图文件元数据", example = "{width:100,height:100}")
|
||||||
private String thumbnailMetadata;
|
private String thumbnailMetadata;
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package top.continew.admin.system.model.resp;
|
package top.continew.admin.system.model.resp.file;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package top.continew.admin.system.model.resp;
|
package top.continew.admin.system.model.resp.file;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package top.continew.admin.system.model.resp;
|
package top.continew.admin.system.model.resp.message;
|
||||||
|
|
||||||
import cn.crane4j.annotation.Assemble;
|
import cn.crane4j.annotation.Assemble;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package top.continew.admin.system.model.resp;
|
package top.continew.admin.system.model.resp.message;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package top.continew.admin.system.model.resp;
|
package top.continew.admin.system.model.resp.message;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
@@ -21,8 +21,8 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import top.continew.admin.system.model.entity.FileDO;
|
import top.continew.admin.system.model.entity.FileDO;
|
||||||
import top.continew.admin.system.model.query.FileQuery;
|
import top.continew.admin.system.model.query.FileQuery;
|
||||||
import top.continew.admin.system.model.req.FileReq;
|
import top.continew.admin.system.model.req.FileReq;
|
||||||
import top.continew.admin.system.model.resp.FileResp;
|
import top.continew.admin.system.model.resp.file.FileResp;
|
||||||
import top.continew.admin.system.model.resp.FileStatisticsResp;
|
import top.continew.admin.system.model.resp.file.FileStatisticsResp;
|
||||||
import top.continew.starter.data.mp.service.IService;
|
import top.continew.starter.data.mp.service.IService;
|
||||||
import top.continew.starter.extension.crud.service.BaseService;
|
import top.continew.starter.extension.crud.service.BaseService;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package top.continew.admin.system.service;
|
|||||||
|
|
||||||
import top.continew.admin.system.model.query.MessageQuery;
|
import top.continew.admin.system.model.query.MessageQuery;
|
||||||
import top.continew.admin.system.model.req.MessageReq;
|
import top.continew.admin.system.model.req.MessageReq;
|
||||||
import top.continew.admin.system.model.resp.MessageResp;
|
import top.continew.admin.system.model.resp.message.MessageResp;
|
||||||
import top.continew.starter.extension.crud.model.query.PageQuery;
|
import top.continew.starter.extension.crud.model.query.PageQuery;
|
||||||
import top.continew.starter.extension.crud.model.resp.PageResp;
|
import top.continew.starter.extension.crud.model.resp.PageResp;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package top.continew.admin.system.service;
|
package top.continew.admin.system.service;
|
||||||
|
|
||||||
import top.continew.admin.system.model.resp.MessageUnreadResp;
|
import top.continew.admin.system.model.resp.message.MessageUnreadResp;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ import top.continew.admin.system.model.entity.FileDO;
|
|||||||
import top.continew.admin.system.model.entity.StorageDO;
|
import top.continew.admin.system.model.entity.StorageDO;
|
||||||
import top.continew.admin.system.model.query.FileQuery;
|
import top.continew.admin.system.model.query.FileQuery;
|
||||||
import top.continew.admin.system.model.req.FileReq;
|
import top.continew.admin.system.model.req.FileReq;
|
||||||
import top.continew.admin.system.model.resp.FileResp;
|
import top.continew.admin.system.model.resp.file.FileResp;
|
||||||
import top.continew.admin.system.model.resp.FileStatisticsResp;
|
import top.continew.admin.system.model.resp.file.FileStatisticsResp;
|
||||||
import top.continew.admin.system.service.FileService;
|
import top.continew.admin.system.service.FileService;
|
||||||
import top.continew.admin.system.service.StorageService;
|
import top.continew.admin.system.service.StorageService;
|
||||||
import top.continew.starter.core.constant.StringConstants;
|
import top.continew.starter.core.constant.StringConstants;
|
||||||
@@ -91,12 +91,12 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes
|
|||||||
}
|
}
|
||||||
LocalDate today = LocalDate.now();
|
LocalDate today = LocalDate.now();
|
||||||
String path = today.getYear() + StringConstants.SLASH + today.getMonthValue() + StringConstants.SLASH + today
|
String path = today.getYear() + StringConstants.SLASH + today.getMonthValue() + StringConstants.SLASH + today
|
||||||
.getDayOfMonth() + StringConstants.SLASH;
|
.getDayOfMonth() + StringConstants.SLASH;
|
||||||
UploadPretreatment uploadPretreatment = fileStorageService.of(file)
|
UploadPretreatment uploadPretreatment = fileStorageService.of(file)
|
||||||
.setPlatform(storage.getCode())
|
.setPlatform(storage.getCode())
|
||||||
.setHashCalculatorMd5(true)
|
.setHashCalculatorMd5(true)
|
||||||
.putAttr(ClassUtil.getClassName(StorageDO.class, false), storage)
|
.putAttr(ClassUtil.getClassName(StorageDO.class, false), storage)
|
||||||
.setPath(path);
|
.setPath(path);
|
||||||
// 图片文件生成缩略图
|
// 图片文件生成缩略图
|
||||||
if (FileTypeEnum.IMAGE.getExtensions().contains(FileNameUtil.extName(file.getOriginalFilename()))) {
|
if (FileTypeEnum.IMAGE.getExtensions().contains(FileNameUtil.extName(file.getOriginalFilename()))) {
|
||||||
uploadPretreatment.thumbnail(img -> img.size(100, 100));
|
uploadPretreatment.thumbnail(img -> img.size(100, 100));
|
||||||
@@ -155,7 +155,7 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes
|
|||||||
String url = URLUtil.normalize(prefix + fileResp.getUrl());
|
String url = URLUtil.normalize(prefix + fileResp.getUrl());
|
||||||
fileResp.setUrl(url);
|
fileResp.setUrl(url);
|
||||||
String thumbnailUrl = StrUtils.blankToDefault(fileResp.getThumbnailUrl(), url, thUrl -> URLUtil
|
String thumbnailUrl = StrUtils.blankToDefault(fileResp.getThumbnailUrl(), url, thUrl -> URLUtil
|
||||||
.normalize(prefix + thUrl));
|
.normalize(prefix + thUrl));
|
||||||
fileResp.setThumbnailUrl(thumbnailUrl);
|
fileResp.setThumbnailUrl(thumbnailUrl);
|
||||||
fileResp.setStorageName("%s (%s)".formatted(storage.getName(), storage.getCode()));
|
fileResp.setStorageName("%s (%s)".formatted(storage.getName(), storage.getCode()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import top.continew.admin.system.mapper.MessageMapper;
|
|||||||
import top.continew.admin.system.model.entity.MessageDO;
|
import top.continew.admin.system.model.entity.MessageDO;
|
||||||
import top.continew.admin.system.model.query.MessageQuery;
|
import top.continew.admin.system.model.query.MessageQuery;
|
||||||
import top.continew.admin.system.model.req.MessageReq;
|
import top.continew.admin.system.model.req.MessageReq;
|
||||||
import top.continew.admin.system.model.resp.MessageResp;
|
import top.continew.admin.system.model.resp.message.MessageResp;
|
||||||
import top.continew.admin.system.service.MessageService;
|
import top.continew.admin.system.service.MessageService;
|
||||||
import top.continew.admin.system.service.MessageUserService;
|
import top.continew.admin.system.service.MessageUserService;
|
||||||
import top.continew.starter.core.validation.CheckUtils;
|
import top.continew.starter.core.validation.CheckUtils;
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import org.springframework.stereotype.Service;
|
|||||||
import top.continew.admin.system.enums.MessageTypeEnum;
|
import top.continew.admin.system.enums.MessageTypeEnum;
|
||||||
import top.continew.admin.system.mapper.MessageUserMapper;
|
import top.continew.admin.system.mapper.MessageUserMapper;
|
||||||
import top.continew.admin.system.model.entity.MessageUserDO;
|
import top.continew.admin.system.model.entity.MessageUserDO;
|
||||||
import top.continew.admin.system.model.resp.MessageTypeUnreadResp;
|
import top.continew.admin.system.model.resp.message.MessageTypeUnreadResp;
|
||||||
import top.continew.admin.system.model.resp.MessageUnreadResp;
|
import top.continew.admin.system.model.resp.message.MessageUnreadResp;
|
||||||
import top.continew.admin.system.service.MessageUserService;
|
import top.continew.admin.system.service.MessageUserService;
|
||||||
import top.continew.starter.core.validation.CheckUtils;
|
import top.continew.starter.core.validation.CheckUtils;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
<mapper namespace="top.continew.admin.system.mapper.MessageMapper">
|
<mapper namespace="top.continew.admin.system.mapper.MessageMapper">
|
||||||
<select id="selectPageByUserId" resultType="top.continew.admin.system.model.resp.MessageResp">
|
<select id="selectPageByUserId" resultType="top.continew.admin.system.model.resp.message.MessageResp">
|
||||||
SELECT
|
SELECT
|
||||||
t1.*,
|
t1.*,
|
||||||
t2.user_id,
|
t2.user_id,
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import top.continew.admin.common.constant.CacheConstants;
|
import top.continew.admin.common.constant.CacheConstants;
|
||||||
import top.continew.admin.system.enums.OptionCategoryEnum;
|
import top.continew.admin.system.enums.OptionCategoryEnum;
|
||||||
import top.continew.admin.system.model.query.*;
|
import top.continew.admin.system.model.query.*;
|
||||||
import top.continew.admin.system.model.resp.FileUploadResp;
|
import top.continew.admin.system.model.resp.file.FileUploadResp;
|
||||||
import top.continew.admin.system.service.*;
|
import top.continew.admin.system.service.*;
|
||||||
import top.continew.starter.core.validation.ValidationUtils;
|
import top.continew.starter.core.validation.ValidationUtils;
|
||||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import top.continew.admin.common.controller.BaseController;
|
import top.continew.admin.common.controller.BaseController;
|
||||||
import top.continew.admin.system.model.query.FileQuery;
|
import top.continew.admin.system.model.query.FileQuery;
|
||||||
import top.continew.admin.system.model.req.FileReq;
|
import top.continew.admin.system.model.req.FileReq;
|
||||||
import top.continew.admin.system.model.resp.FileResp;
|
import top.continew.admin.system.model.resp.file.FileResp;
|
||||||
import top.continew.admin.system.model.resp.FileStatisticsResp;
|
import top.continew.admin.system.model.resp.file.FileStatisticsResp;
|
||||||
import top.continew.admin.system.service.FileService;
|
import top.continew.admin.system.service.FileService;
|
||||||
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
|
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
|
||||||
import top.continew.starter.extension.crud.enums.Api;
|
import top.continew.starter.extension.crud.enums.Api;
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import top.continew.admin.common.context.UserContextHolder;
|
import top.continew.admin.common.context.UserContextHolder;
|
||||||
import top.continew.admin.system.model.query.MessageQuery;
|
import top.continew.admin.system.model.query.MessageQuery;
|
||||||
import top.continew.admin.system.model.resp.MessageResp;
|
import top.continew.admin.system.model.resp.message.MessageResp;
|
||||||
import top.continew.admin.system.model.resp.MessageUnreadResp;
|
import top.continew.admin.system.model.resp.message.MessageUnreadResp;
|
||||||
import top.continew.admin.system.service.MessageService;
|
import top.continew.admin.system.service.MessageService;
|
||||||
import top.continew.admin.system.service.MessageUserService;
|
import top.continew.admin.system.service.MessageUserService;
|
||||||
import top.continew.starter.extension.crud.model.query.PageQuery;
|
import top.continew.starter.extension.crud.model.query.PageQuery;
|
||||||
|
|||||||
@@ -277,29 +277,29 @@ CREATE TABLE IF NOT EXISTS `sys_storage` (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='存储表';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='存储表';
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `sys_file` (
|
CREATE TABLE IF NOT EXISTS `sys_file` (
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||||
`name` varchar(255) NOT NULL COMMENT '名称',
|
`name` varchar(255) NOT NULL COMMENT '名称',
|
||||||
`size` bigint(20) NOT NULL COMMENT '大小(字节)',
|
`size` bigint(20) NOT NULL COMMENT '大小(字节)',
|
||||||
`url` varchar(512) NOT NULL COMMENT 'URL',
|
`url` varchar(512) NOT NULL COMMENT 'URL',
|
||||||
`parent_path` varchar(512) NOT NULL COMMENT '上级目录',
|
`parent_path` varchar(512) DEFAULT '/' COMMENT '上级目录',
|
||||||
`abs_path` varchar(1024) NOT NULL COMMENT '绝对路径',
|
`abs_path` varchar(1024) NOT NULL COMMENT '绝对路径',
|
||||||
`extension` varchar(100) DEFAULT NULL COMMENT '扩展名',
|
`extension` varchar(100) DEFAULT NULL COMMENT '扩展名',
|
||||||
`metadata` TEXT NOT NULL COMMENT '元数据',
|
`content_type` varchar(64) NOT NULL COMMENT '内容类型',
|
||||||
`content_type` varchar(64) NOT NULL COMMENT '文件类型',
|
`type` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '类型(0: 目录;1:其他;2:图片;3:文档;4:视频;5:音频)',
|
||||||
`md5` varchar(128) NOT NULL COMMENT '文件md5值',
|
`md5` varchar(128) NOT NULL COMMENT 'MD5值',
|
||||||
`thumbnail_size` bigint(20) DEFAULT NULL COMMENT '缩略图大小(字节)',
|
`metadata` text DEFAULT NULL COMMENT '元数据',
|
||||||
`thumbnail_url` varchar(512) DEFAULT NULL COMMENT '缩略图URL',
|
`thumbnail_size` bigint(20) DEFAULT NULL COMMENT '缩略图大小(字节)',
|
||||||
`thumbnail_metadata` TEXT COMMENT '元数据',
|
`thumbnail_url` varchar(512) DEFAULT NULL COMMENT '缩略图URL',
|
||||||
`type` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '类型(0: 目录;1:其他;2:图片;3:文档;4:视频;5:音频)',
|
`thumbnail_metadata` text DEFAULT NULL COMMENT '缩略图元数据',
|
||||||
`storage_id` bigint(20) NOT NULL COMMENT '存储ID',
|
`storage_id` bigint(20) NOT NULL COMMENT '存储ID',
|
||||||
`create_user` bigint(20) NOT NULL COMMENT '创建人',
|
`create_user` bigint(20) NOT NULL COMMENT '创建人',
|
||||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||||
`update_user` bigint(20) NOT NULL COMMENT '修改人',
|
`update_user` bigint(20) NOT NULL COMMENT '修改人',
|
||||||
`update_time` datetime NOT NULL COMMENT '修改时间',
|
`update_time` datetime NOT NULL COMMENT '修改时间',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
INDEX `idx_url`(`url`),
|
INDEX `idx_url`(`url`),
|
||||||
|
INDEX `idx_md5`(`md5`),
|
||||||
INDEX `idx_type`(`type`),
|
INDEX `idx_type`(`type`),
|
||||||
INDEX `idx_sys_file_md5`(`md5`),
|
|
||||||
INDEX `idx_create_user`(`create_user`),
|
INDEX `idx_create_user`(`create_user`),
|
||||||
INDEX `idx_update_user`(`update_user`)
|
INDEX `idx_update_user`(`update_user`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文件表';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文件表';
|
||||||
|
|||||||
@@ -463,51 +463,52 @@ COMMENT ON COLUMN "sys_storage"."update_time" IS '修改时间';
|
|||||||
COMMENT ON TABLE "sys_storage" IS '存储表';
|
COMMENT ON TABLE "sys_storage" IS '存储表';
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS "sys_file" (
|
CREATE TABLE IF NOT EXISTS "sys_file" (
|
||||||
"id" int8 NOT NULL,
|
"id" int8 NOT NULL,
|
||||||
"name" varchar(255) NOT NULL,
|
"name" varchar(255) NOT NULL,
|
||||||
"size" int8 NOT NULL,
|
"size" int8 NOT NULL,
|
||||||
"url" varchar(512) NOT NULL,
|
"url" varchar(512) NOT NULL,
|
||||||
"parent_path" varchar(512) NOT NULL default '/',
|
"parent_path" varchar(512) NOT NULL DEFAULT '/',
|
||||||
"abs_path" varchar(512) NOT NULL,
|
"abs_path" varchar(512) NOT NULL,
|
||||||
"extension" varchar(100) DEFAULT NULL,
|
"extension" varchar(100) DEFAULT NULL,
|
||||||
"metadata" varchar(10000) NOT NULL DEFAULT '',
|
"content_type" varchar(64) NOT NULL,
|
||||||
"content_type" varchar(64) NOT NULL,
|
"type" int2 NOT NULL DEFAULT 1,
|
||||||
"md5" varchar(128) NOT NULL DEFAULT '',
|
"md5" varchar(128) NOT NULL,
|
||||||
"thumbnail_size" int8 DEFAULT NULL,
|
"metadata" text DEFAULT NULL,
|
||||||
"thumbnail_url" varchar(512) DEFAULT NULL,
|
"thumbnail_size" int8 DEFAULT NULL,
|
||||||
"thumbnail_metadata" varchar(10000) DEFAULT NULL,
|
"thumbnail_url" varchar(512) DEFAULT NULL,
|
||||||
"type" int2 NOT NULL DEFAULT 1,
|
"thumbnail_metadata" text DEFAULT NULL,
|
||||||
"storage_id" int8 NOT NULL,
|
"storage_id" int8 NOT NULL,
|
||||||
"create_user" int8 NOT NULL,
|
"create_user" int8 NOT NULL,
|
||||||
"create_time" timestamp NOT NULL,
|
"create_time" timestamp NOT NULL,
|
||||||
"update_user" int8 NOT NULL,
|
"update_user" int8 NOT NULL,
|
||||||
"update_time" timestamp NOT NULL,
|
"update_time" timestamp NOT NULL,
|
||||||
PRIMARY KEY ("id")
|
PRIMARY KEY ("id")
|
||||||
);
|
);
|
||||||
CREATE INDEX "idx_file_url" ON "sys_file" ("url");
|
CREATE INDEX "idx_file_url" ON "sys_file" ("url");
|
||||||
CREATE INDEX "idx_file_type" ON "sys_file" ("type");
|
CREATE INDEX "idx_file_type" ON "sys_file" ("type");
|
||||||
|
CREATE INDEX "idx_file_md5" ON "sys_file" ("md5");
|
||||||
CREATE INDEX "idx_file_create_user" ON "sys_file" ("create_user");
|
CREATE INDEX "idx_file_create_user" ON "sys_file" ("create_user");
|
||||||
CREATE INDEX "idx_file_update_user" ON "sys_file" ("update_user");
|
CREATE INDEX "idx_file_update_user" ON "sys_file" ("update_user");
|
||||||
CREATE INDEX "idx_sys_file_md5" ON "sys_file" ("md5");
|
COMMENT ON COLUMN "sys_file"."id" IS 'ID';
|
||||||
COMMENT ON COLUMN "sys_file"."id" IS 'ID';
|
COMMENT ON COLUMN "sys_file"."name" IS '名称';
|
||||||
COMMENT ON COLUMN "sys_file"."name" IS '名称';
|
COMMENT ON COLUMN "sys_file"."size" IS '大小(字节)';
|
||||||
COMMENT ON COLUMN "sys_file"."size" IS '大小(字节)';
|
COMMENT ON COLUMN "sys_file"."url" IS 'URL';
|
||||||
COMMENT ON COLUMN "sys_file"."url" IS 'URL';
|
COMMENT ON COLUMN "sys_file"."parent_path" IS '上级目录';
|
||||||
COMMENT ON COLUMN "sys_file"."parent_path" IS '上级目录';
|
COMMENT ON COLUMN "sys_file"."abs_path" IS '绝对路径';
|
||||||
COMMENT ON COLUMN "sys_file"."abs_path" IS '绝对路径';
|
COMMENT ON COLUMN "sys_file"."extension" IS '扩展名';
|
||||||
COMMENT ON COLUMN "sys_file"."extension" IS '扩展名';
|
COMMENT ON COLUMN "sys_file"."content_type" IS '内容类型';
|
||||||
COMMENT ON COLUMN "sys_file"."thumbnail_size" IS '缩略图大小(字节)';
|
COMMENT ON COLUMN "sys_file"."type" IS '类型(0: 目录;1:其他;2:图片;3:文档;4:视频;5:音频)';
|
||||||
COMMENT ON COLUMN "sys_file"."thumbnail_url" IS '缩略图URL';
|
COMMENT ON COLUMN "sys_file"."md5" IS 'MD5值';
|
||||||
COMMENT ON COLUMN "sys_file"."type" IS '类型(0: 目录;1:其他;2:图片;3:文档;4:视频;5:音频)';
|
COMMENT ON COLUMN "sys_file"."metadata" IS '元数据';
|
||||||
COMMENT ON COLUMN "sys_file"."metadata" IS '元数据';
|
COMMENT ON COLUMN "sys_file"."thumbnail_size" IS '缩略图大小(字节)';
|
||||||
COMMENT ON COLUMN "sys_file"."content_type" IS '文件类型';
|
COMMENT ON COLUMN "sys_file"."thumbnail_url" IS '缩略图URL';
|
||||||
COMMENT ON COLUMN "sys_file"."md5" IS '文件md5值';
|
COMMENT ON COLUMN "sys_file"."thumbnail_metadata" IS '缩略图元数据';
|
||||||
COMMENT ON COLUMN "sys_file"."storage_id" IS '存储ID';
|
COMMENT ON COLUMN "sys_file"."storage_id" IS '存储ID';
|
||||||
COMMENT ON COLUMN "sys_file"."create_user" IS '创建人';
|
COMMENT ON COLUMN "sys_file"."create_user" IS '创建人';
|
||||||
COMMENT ON COLUMN "sys_file"."create_time" IS '创建时间';
|
COMMENT ON COLUMN "sys_file"."create_time" IS '创建时间';
|
||||||
COMMENT ON COLUMN "sys_file"."update_user" IS '修改人';
|
COMMENT ON COLUMN "sys_file"."update_user" IS '修改人';
|
||||||
COMMENT ON COLUMN "sys_file"."update_time" IS '修改时间';
|
COMMENT ON COLUMN "sys_file"."update_time" IS '修改时间';
|
||||||
COMMENT ON TABLE "sys_file" IS '文件表';
|
COMMENT ON TABLE "sys_file" IS '文件表';
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS "sys_client" (
|
CREATE TABLE IF NOT EXISTS "sys_client" (
|
||||||
"id" int8 NOT NULL,
|
"id" int8 NOT NULL,
|
||||||
|
|||||||
Reference in New Issue
Block a user