fix(file): 上传文件微调

This commit is contained in:
caozehui
2026-05-19 14:48:18 +08:00
parent b6d31ab156
commit 3199c876c3
2 changed files with 10 additions and 5 deletions

View File

@@ -29,9 +29,6 @@ public class DBFileClient extends AbstractFileClient<DBFileClientConfig> {
@Override @Override
public String upload(byte[] content, String path, String type) { public String upload(byte[] content, String path, String type) {
FileContentDO contentDO = new FileContentDO().setConfigId(getId())
.setPath(path).setContent(content);
fileContentMapper.insert(contentDO);
// 拼接返回路径 // 拼接返回路径
return super.formatFileUrl(config.getDomain(), path); return super.formatFileUrl(config.getDomain(), path);
} }

View File

@@ -12,7 +12,9 @@ import com.njcn.rdms.framework.common.util.object.BeanUtils;
import com.njcn.rdms.module.system.controller.admin.file.vo.file.FileCreateReqVO; import com.njcn.rdms.module.system.controller.admin.file.vo.file.FileCreateReqVO;
import com.njcn.rdms.module.system.controller.admin.file.vo.file.FilePageReqVO; import com.njcn.rdms.module.system.controller.admin.file.vo.file.FilePageReqVO;
import com.njcn.rdms.module.system.controller.admin.file.vo.file.FilePresignedUrlRespVO; import com.njcn.rdms.module.system.controller.admin.file.vo.file.FilePresignedUrlRespVO;
import com.njcn.rdms.module.system.dal.dataobject.file.FileContentDO;
import com.njcn.rdms.module.system.dal.dataobject.file.FileDO; import com.njcn.rdms.module.system.dal.dataobject.file.FileDO;
import com.njcn.rdms.module.system.dal.mysql.file.FileContentMapper;
import com.njcn.rdms.module.system.dal.mysql.file.FileMapper; import com.njcn.rdms.module.system.dal.mysql.file.FileMapper;
import com.njcn.rdms.module.system.framework.file.core.client.FileClient; import com.njcn.rdms.module.system.framework.file.core.client.FileClient;
import com.njcn.rdms.module.system.framework.file.core.utils.FileTypeUtils; import com.njcn.rdms.module.system.framework.file.core.utils.FileTypeUtils;
@@ -36,13 +38,13 @@ public class FileServiceImpl implements FileService {
/** /**
* 上传文件的前缀是否包含日期yyyyMMdd * 上传文件的前缀是否包含日期yyyyMMdd
* * <p>
* 目的:按照日期,进行分目录 * 目的:按照日期,进行分目录
*/ */
static boolean PATH_PREFIX_DATE_ENABLE = true; static boolean PATH_PREFIX_DATE_ENABLE = true;
/** /**
* 上传文件的后缀,是否包含时间戳 * 上传文件的后缀,是否包含时间戳
* * <p>
* 目的:保证文件的唯一性,避免覆盖 * 目的:保证文件的唯一性,避免覆盖
* 定制:可按需调整成 UUID、或者其他方式 * 定制:可按需调整成 UUID、或者其他方式
*/ */
@@ -54,6 +56,9 @@ public class FileServiceImpl implements FileService {
@Resource @Resource
private FileMapper fileMapper; private FileMapper fileMapper;
@Resource
private FileContentMapper fileContentMapper;
@Override @Override
public PageResult<FileDO> getFilePage(FilePageReqVO pageReqVO) { public PageResult<FileDO> getFilePage(FilePageReqVO pageReqVO) {
return fileMapper.selectPage(pageReqVO); return fileMapper.selectPage(pageReqVO);
@@ -90,6 +95,9 @@ public class FileServiceImpl implements FileService {
.setName(name).setPath(path).setUrl(url) .setName(name).setPath(path).setUrl(url)
.setType(type).setSize((long) content.length); .setType(type).setSize((long) content.length);
fileMapper.insert(file); fileMapper.insert(file);
FileContentDO contentDO = new FileContentDO().setConfigId(file.getId())
.setPath(path).setContent(content);
fileContentMapper.insert(contentDO);
return file; return file;
} }