zss
2026-04-23 5033c375a3ee6a63bcb600d5b9f4b8d549d089e2
Merge remote-tracking branch 'origin/dev_New_pro' into dev_New_pro
已添加2个文件
已修改1个文件
已删除4个文件
191 ■■■■■ 文件已修改
src/main/java/com/ruoyi/basic/constant/ApplicationType.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/constant/RecordType.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/constant/fileType/ApplicationTypeImage.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/constant/fileType/FileTypeApplication.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/enums/ApplicationTypeEnum.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/enums/RecordTypeEnum.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/utils/FileUtil.java 121 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/constant/ApplicationType.java
ÎļþÒÑɾ³ý
src/main/java/com/ruoyi/basic/constant/RecordType.java
ÎļþÒÑɾ³ý
src/main/java/com/ruoyi/basic/constant/fileType/ApplicationTypeImage.java
ÎļþÒÑɾ³ý
src/main/java/com/ruoyi/basic/constant/fileType/FileTypeApplication.java
ÎļþÒÑɾ³ý
src/main/java/com/ruoyi/basic/enums/ApplicationTypeEnum.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,10 @@
package com.ruoyi.basic.enums;
public enum ApplicationTypeEnum {
    IMAGE("image"),
    FILE("file");
    private final String type;
    ApplicationTypeEnum(String type) { this.type = type; }
    public String getType() { return type; }
}
src/main/java/com/ruoyi/basic/enums/RecordTypeEnum.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,9 @@
package com.ruoyi.basic.enums;
public enum RecordTypeEnum {
    FILE("file");
    private final String type;
    RecordTypeEnum(String type) { this.type = type; }
    public String getType() { return type; }
}
src/main/java/com/ruoyi/basic/utils/FileUtil.java
@@ -2,12 +2,14 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.ruoyi.basic.constant.ApplicationType;
import com.ruoyi.basic.constant.RecordType;
import com.ruoyi.basic.dto.StorageAttachmentDTO;
import com.ruoyi.basic.dto.StorageBlobVO;
import com.ruoyi.basic.enums.ApplicationTypeEnum;
import com.ruoyi.basic.enums.RecordTypeEnum;
import com.ruoyi.basic.mapper.StorageAttachmentMapper;
import com.ruoyi.basic.mapper.StorageBlobMapper;
import com.ruoyi.basic.pojo.StorageAttachment;
import com.ruoyi.basic.pojo.StorageBlob;
import com.ruoyi.common.config.FileProperties;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.security.Keys;
@@ -34,6 +36,7 @@
    private final FileProperties properties;
    private final StorageAttachmentMapper storageAttachmentMapper;
    private final StringRedisTemplate stringRedisTemplate;
    private final StorageBlobMapper storageBlobMapper;
    private static final String TOKEN_USAGE_KEY_PREFIX = "file:token:usage:";
    private static final DateTimeFormatter YEAR_PATH_FORMATTER = DateTimeFormatter.ofPattern("yyyy");
@@ -47,14 +50,14 @@
     * @param recordId        å…³è”记录id
     * @param storageBlobVOS æ–‡ä»¶ä¿¡æ¯
     */
    public void saveStorageAttachment(ApplicationType application, RecordType recordType, Long recordId, List<StorageBlobVO> storageBlobVOS) {
    public void saveStorageAttachment(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId, List<StorageBlobVO> storageBlobVOS) {
        if (CollectionUtils.isEmpty(storageBlobVOS)) {
            throw new RuntimeException("文件信息不能为空");
        }
        if (!application.isValid()) {
        if (application == null) {
            throw new RuntimeException("文件用途不能为空");
        }
        if (!recordType.isValid()) {
        if (recordType == null) {
            throw new RuntimeException("关联记录类型不能为空");
        }
        if (recordId == null || recordId <= 0) {
@@ -71,8 +74,7 @@
            storageAttachment.setStorageBlobId(storageBlobVO.getId());
            storageAttachment.setDeleted(0L);
        }
        // todo fileChange
//        storageAttachmentMapper.insert(storageAttachments);
        storageAttachmentMapper.insert(storageAttachments);
    }
    /**
@@ -81,8 +83,7 @@
     * @param storageBlobIds æ–‡ä»¶id
     */
    public void deleteStorageBlobs(List<Long> storageBlobIds) {
        // todo fileChange
//        storageBlobMapper.deleteByIds(storageBlobIds);
        storageBlobMapper.deleteByIds(storageBlobIds);
    }
    /**
@@ -91,10 +92,9 @@
     * @param storageAttachmentIds æ–‡ä»¶id
     */
    public void deleteStorageBlobsByStorageAttachmentIds(List<Long> storageAttachmentIds) {
        // todo fileChange
//        List<StorageAttachment> storageAttachments = storageAttachmentMapper.selectByIds(storageAttachmentIds);
//        List<Long> storageBlobIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId).collect(Collectors.toList());
//        deleteStorageBlobs(storageBlobIds);
        List<StorageAttachment> storageAttachments = storageAttachmentMapper.selectByIds(storageAttachmentIds);
        List<Long> storageBlobIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId).collect(Collectors.toList());
        deleteStorageBlobs(storageBlobIds);
    }
    /**
@@ -104,15 +104,15 @@
     * @param recordType  å…³è”记录类型
     * @param recordId    å…³è”记录id
     */
    public void deleteStorageBlobsByApplicationAndRecordTypeAndRecordId(ApplicationType application, RecordType recordType, Long recordId) {
        if (!application.isValid()) {
            throw new RuntimeException("文件用途不能为空");
        }
        if (!recordType.isValid()) {
            throw new RuntimeException("关联记录类型不能为空");
        }
    public void deleteStorageBlobsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId) {
        if (recordId == null || recordId <= 0) {
            throw new RuntimeException("关联记录id不能为空");
        }
        if (application == null) {
            throw new RuntimeException("文件用途不能为空");
        }
        if (recordType == null) {
            throw new RuntimeException("关联记录类型不能为空");
        }
        List<StorageAttachment> storageAttachments = storageAttachmentMapper.selectList(new LambdaQueryWrapper<StorageAttachment>()
                .eq(StorageAttachment::getRecordType, recordType.getType())
@@ -132,19 +132,18 @@
     */
    public void deleteStorageAttachmentsByStorageAttachmentIds(List<Long> storageAttachmentIds) {
        deleteStorageBlobsByStorageAttachmentIds(storageAttachmentIds);
        // todo fileChange
//        storageAttachmentMapper.deleteByIds(storageAttachmentIds);
        storageAttachmentMapper.deleteByIds(storageAttachmentIds);
    }
    public void deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordId(ApplicationType application, RecordType recordType, Long recordId) {
        if (!application.isValid()) {
            throw new RuntimeException("文件用途不能为空");
        }
        if (!recordType.isValid()) {
            throw new RuntimeException("关联记录类型不能为空");
        }
    public void deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId) {
        if (recordId == null || recordId <= 0) {
            throw new RuntimeException("关联记录id不能为空");
        }
        if (application == null) {
            throw new RuntimeException("文件用途不能为空");
        }
        if (recordType == null) {
            throw new RuntimeException("关联记录类型不能为空");
        }
        deleteStorageBlobsByApplicationAndRecordTypeAndRecordId(application, recordType, recordId);
        storageAttachmentMapper.delete(new LambdaQueryWrapper<StorageAttachment>()
@@ -162,9 +161,7 @@
        if (CollectionUtils.isEmpty(storageAttachmentIds)) {
            throw new RuntimeException("文件id不能为空");
        }
        // todo fileChange
//        return storageAttachmentMapper.selectByIds(storageAttachmentIds);
        return new ArrayList<>();
        return storageAttachmentMapper.selectByIds(storageAttachmentIds);
    }
    /**
@@ -174,15 +171,14 @@
     * @param recordType  å…³è”记录类型
     * @param recordId    å…³è”记录id
     */
    public List<StorageAttachment> getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(ApplicationType application, RecordType recordType, Long recordId) {
        if (!application.isValid()) {
            throw new RuntimeException("文件用途不能为空");
        }
        if (!recordType.isValid()) {
            throw new RuntimeException("关联记录类型不能为空");
        }
    public List<StorageAttachment> getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId) {
        if (recordId == null || recordId <= 0) {
            throw new RuntimeException("关联记录id不能为空");
        }        if (application == null) {
            throw new RuntimeException("文件用途不能为空");
        }
        if (recordType == null) {
            throw new RuntimeException("关联记录类型不能为空");
        }
        return storageAttachmentMapper.selectList(new LambdaQueryWrapper<StorageAttachment>()
                .eq(StorageAttachment::getRecordType, recordType.getType())
@@ -201,17 +197,16 @@
            return null;
        }
        List<Long> storageBlobIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId).collect(Collectors.toList());
        // todo fileChange
//        List<StorageBlob> storageBlobs = storageBlobMapper.selectByIds(storageBlobIds);
//        List<StorageBlobDTO> storageBlobDTOS = new ArrayList<>();
//        for (StorageBlob storageBlob : storageBlobs) {
//            StorageBlobDTO storageBlobDTO = new StorageBlobDTO();
//            BeanUtils.copyProperties(storageBlob, storageBlobDTO);
//            storageBlobDTO.setPreviewURL(buildSignedPreviewUrl(storageBlobDTO));
//            storageBlobDTO.setDownloadURL(buildSignedDownloadUrl(storageBlobDTO));
//            storageBlobDTOS.add(storageBlobDTO);
//        }
        return new ArrayList<>();
        List<StorageBlob> storageBlobs = storageBlobMapper.selectByIds(storageBlobIds);
        List<StorageBlobVO> storageBlobDTOS = new ArrayList<>();
        for (StorageBlob storageBlob : storageBlobs) {
            StorageBlobVO storageBlobVO = new StorageBlobVO();
            BeanUtils.copyProperties(storageBlob, storageBlobVO);
            storageBlobVO.setPreviewURL(buildSignedPreviewUrl(storageBlobVO));
            storageBlobVO.setDownloadURL(buildSignedDownloadUrl(storageBlobVO));
            storageBlobDTOS.add(storageBlobVO);
        }
        return storageBlobDTOS;
    }
    /**
@@ -226,18 +221,16 @@
            return null;
        }
        List<Long> storageBlobIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId).collect(Collectors.toList());
        // todo fileChange
//        List<StorageBlob> storageBlobs = storageBlobMapper.selectByIds(storageBlobIds);
//        List<StorageBlobDTO> storageBlobDTOS = new ArrayList<>();
//        for (StorageBlob storageBlob : storageBlobs) {
//            StorageBlobDTO storageBlobDTO = new StorageBlobDTO();
//            BeanUtils.copyProperties(storageBlob, storageBlobDTO);
//            storageBlobDTO.setPreviewURL(buildSignedUrl(storageBlobDTO, "/preview/", expired));
//            storageBlobDTO.setDownloadURL(buildSignedUrl(storageBlobDTO, "/download/", expired));
//            storageBlobDTOS.add(storageBlobDTO);
//        }
//        return storageBlobDTOS;
        return new ArrayList<>();
        List<StorageBlob> storageBlobs = storageBlobMapper.selectByIds(storageBlobIds);
        List<StorageBlobVO> storageBlobDTOS = new ArrayList<>();
        for (StorageBlob storageBlob : storageBlobs) {
            StorageBlobVO storageBlobVO = new StorageBlobVO();
            BeanUtils.copyProperties(storageBlob, storageBlobVO);
            storageBlobVO.setPreviewURL(buildSignedUrl(storageBlobVO, "/preview/", expired));
            storageBlobVO.setDownloadURL(buildSignedUrl(storageBlobVO, "/download/", expired));
            storageBlobDTOS.add(storageBlobVO);
        }
        return storageBlobDTOS;
    }
    /**
@@ -298,7 +291,7 @@
     * @param recordType  è®°å½•类型
     * @param recordId    è®°å½•id
     */
    public List<StorageAttachmentDTO> getStorageAttachmentDTOsByApplicationAndRecordTypeAndRecordId(ApplicationType application, RecordType recordType, Long recordId) {
    public List<StorageAttachmentDTO> getStorageAttachmentDTOsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId) {
        List<StorageAttachment> storageAttachments = getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(application, recordType, recordId);
        if (CollectionUtils.isEmpty(storageAttachments)) {
            return new ArrayList<>();
@@ -326,7 +319,7 @@
     * @param recordId    è®°å½•id
     * @param expired     è¿‡æœŸæ—¶é—´
     */
    public List<StorageAttachmentDTO> getStorageAttachmentDTOsByApplicationAndRecordTypeAndRecordId(ApplicationType application, RecordType recordType, Long recordId, BigDecimal expired) {
    public List<StorageAttachmentDTO> getStorageAttachmentDTOsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId, BigDecimal expired) {
        List<StorageAttachment> storageAttachments = getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(application, recordType, recordId);
        if (CollectionUtils.isEmpty(storageAttachments)) {
            return new ArrayList<>();