diff --git a/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/framework/file/core/client/db/DBFileClient.java b/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/framework/file/core/client/db/DBFileClient.java index 8e8efa4..78e2ba7 100644 --- a/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/framework/file/core/client/db/DBFileClient.java +++ b/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/framework/file/core/client/db/DBFileClient.java @@ -29,9 +29,6 @@ public class DBFileClient extends AbstractFileClient { @Override 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); } diff --git a/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/service/file/FileServiceImpl.java b/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/service/file/FileServiceImpl.java index 02d17d3..a9ebc94 100644 --- a/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/service/file/FileServiceImpl.java +++ b/rdms-system/rdms-system-boot/src/main/java/com/njcn/rdms/module/system/service/file/FileServiceImpl.java @@ -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.FilePageReqVO; 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.mysql.file.FileContentMapper; 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.utils.FileTypeUtils; @@ -36,13 +38,13 @@ public class FileServiceImpl implements FileService { /** * 上传文件的前缀,是否包含日期(yyyyMMdd) - * + *

* 目的:按照日期,进行分目录 */ static boolean PATH_PREFIX_DATE_ENABLE = true; /** * 上传文件的后缀,是否包含时间戳 - * + *

* 目的:保证文件的唯一性,避免覆盖 * 定制:可按需调整成 UUID、或者其他方式 */ @@ -54,6 +56,9 @@ public class FileServiceImpl implements FileService { @Resource private FileMapper fileMapper; + @Resource + private FileContentMapper fileContentMapper; + @Override public PageResult getFilePage(FilePageReqVO pageReqVO) { return fileMapper.selectPage(pageReqVO); @@ -90,6 +95,9 @@ public class FileServiceImpl implements FileService { .setName(name).setPath(path).setUrl(url) .setType(type).setSize((long) content.length); fileMapper.insert(file); + FileContentDO contentDO = new FileContentDO().setConfigId(file.getId()) + .setPath(path).setContent(content); + fileContentMapper.insert(contentDO); return file; }