From a4aab7d02e69d919f1d1f88aa1381c0ac289c2c2 Mon Sep 17 00:00:00 2001 From: cwchen <1048842385@qq.com> Date: Fri, 17 Oct 2025 14:54:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E9=9B=86=E6=88=90=20?= =?UTF-8?q?=E4=B8=BB=E4=BD=93=E5=BA=93=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/domain/file/po/ResourceFilePo.java | 88 +++++++++++++++++++ .../bonus/file/mapper/ISourceFileMapper.java | 26 ++++++ .../bonus/file/service/FileUploadService.java | 13 +-- .../bonus/file/service/SourceFileService.java | 33 +++++++ .../resources/mapper/SourceFileMapper.xml | 42 +++++++++ 5 files changed, 190 insertions(+), 12 deletions(-) create mode 100644 bonus-common/src/main/java/com/bonus/common/domain/file/po/ResourceFilePo.java create mode 100644 bonus-file/src/main/java/com/bonus/file/mapper/ISourceFileMapper.java create mode 100644 bonus-file/src/main/java/com/bonus/file/service/SourceFileService.java create mode 100644 bonus-file/src/main/resources/mapper/SourceFileMapper.xml diff --git a/bonus-common/src/main/java/com/bonus/common/domain/file/po/ResourceFilePo.java b/bonus-common/src/main/java/com/bonus/common/domain/file/po/ResourceFilePo.java new file mode 100644 index 0000000..2f23d9b --- /dev/null +++ b/bonus-common/src/main/java/com/bonus/common/domain/file/po/ResourceFilePo.java @@ -0,0 +1,88 @@ +package com.bonus.common.domain.file.po; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 系统资源文件表 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ResourceFilePo { + + /** + * 资源文件id + */ + private Long sourceId; + + /** + * 来源表 + */ + private String sourceTable; + + /** + * 文件id/路径 + */ + private String filePath; + + /** + * 源文件名称 + */ + private String sourceFileName; + + /** + * 文件名称 + */ + private String fileName; + + /** + * 文件后缀名称 + */ + private String suffixName; + + /** + * 文件类型 + */ + private String fileType; + + /** + * 业务id + */ + private Long businessId; + + /** + * 业务类型(字典表配置) + */ + private String businessType; + + /** + * 文件大小 + */ + private BigDecimal fileSize; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 创建人 + */ + private Long createUserId; + + /** + * 创建人姓名 + */ + private String createUserName; + + /** + * 删除状态 0.未删除 1.删除 + */ + private String delFlag; + +} diff --git a/bonus-file/src/main/java/com/bonus/file/mapper/ISourceFileMapper.java b/bonus-file/src/main/java/com/bonus/file/mapper/ISourceFileMapper.java new file mode 100644 index 0000000..72932c3 --- /dev/null +++ b/bonus-file/src/main/java/com/bonus/file/mapper/ISourceFileMapper.java @@ -0,0 +1,26 @@ +package com.bonus.file.mapper; + +import com.bonus.common.domain.file.po.ResourceFilePo; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * @className:ISourceFileMapper + * @author:cwchen + * @date:2025-10-17-13:48 + * @version:1.0 + * @description:系统资源库数据库层 + */ +@Repository(value = "ISourceFileMapper") +public interface ISourceFileMapper { + + /** + * 保存系统资源文件数据 + * @param list + * @return void + * @author cwchen + * @date 2025/10/17 14:16 + */ + void saveResourceFile(List list); +} diff --git a/bonus-file/src/main/java/com/bonus/file/service/FileUploadService.java b/bonus-file/src/main/java/com/bonus/file/service/FileUploadService.java index d7b3148..9c4479a 100644 --- a/bonus-file/src/main/java/com/bonus/file/service/FileUploadService.java +++ b/bonus-file/src/main/java/com/bonus/file/service/FileUploadService.java @@ -8,7 +8,6 @@ import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; -import java.io.File; /** * @className:FileUploadService @@ -75,20 +74,10 @@ public class FileUploadService { try{ String fileUrl = minioUtil.getFileUrl(minioConfig.getBucketName(), filePath, 60 * 60 * 12); String lsUrl= fileUrl.replace(minioConfig.getEndpoint(),minioConfig.getUrl()); - String url = minioConfig.getUrl() + File.separator + filePath; log.info("临时路径:{}",lsUrl); return SysFile.builder() .name("文件名称") - .url(url).build(); - }catch (Exception e){ - log.error(e.toString(),e); - } - return null; - } - - public SysFile getFile2(String filePath) { - try{ - minioUtil.getFileUrl(null,null); + .url(lsUrl).build(); }catch (Exception e){ log.error(e.toString(),e); } diff --git a/bonus-file/src/main/java/com/bonus/file/service/SourceFileService.java b/bonus-file/src/main/java/com/bonus/file/service/SourceFileService.java new file mode 100644 index 0000000..f46c855 --- /dev/null +++ b/bonus-file/src/main/java/com/bonus/file/service/SourceFileService.java @@ -0,0 +1,33 @@ +package com.bonus.file.service; + +import com.bonus.common.domain.file.po.ResourceFilePo; +import com.bonus.file.mapper.ISourceFileMapper; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @className:SourceFileService + * @author:cwchen + * @date:2025-10-17-13:46 + * @version:1.0 + * @description:系统资源库实现类 + */ +@Service(value = "SourceFileService") +public class SourceFileService { + + @Resource(name = "ISourceFileMapper") + private ISourceFileMapper mapper; + + /** + * 保存系统文件 + * @param list + * @return void + * @author cwchen + * @date 2025/10/17 14:45 + */ + public void saveResourceFile(List list) { + mapper.saveResourceFile(list); + } +} diff --git a/bonus-file/src/main/resources/mapper/SourceFileMapper.xml b/bonus-file/src/main/resources/mapper/SourceFileMapper.xml new file mode 100644 index 0000000..802bae1 --- /dev/null +++ b/bonus-file/src/main/resources/mapper/SourceFileMapper.xml @@ -0,0 +1,42 @@ + + + + + + + INSERT INTO sys_resource_file + + source_table, + file_path, + source_file_name, + file_name, + suffix_name, + file_type, + business_id, + business_type, + file_size, + create_user_id, + create_user_name, + del_flag, + + VALUES + + + #{item.sourceTable}, + #{item.filePath}, + #{item.sourceFileName}, + #{item.fileName}, + #{item.suffixName}, + #{item.fileType}, + #{item.businessId}, + #{item.businessType}, + #{item.fileSize}, + #{item.createUserId}, + #{item.createUserName}, + #{item.delFlag}, + + + +