From 4d9450919dccd9b20d4fc21f9288148c9257da61 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 28 四月 2026 10:19:25 +0800
Subject: [PATCH] feat(ai): 添加审批待办助手功能

---
 src/main/java/com/ruoyi/basic/service/impl/StorageAttachmentServiceImpl.java |   86 ++++++++++++-------------------------------
 1 files changed, 24 insertions(+), 62 deletions(-)

diff --git a/src/main/java/com/ruoyi/basic/service/impl/StorageAttachmentServiceImpl.java b/src/main/java/com/ruoyi/basic/service/impl/StorageAttachmentServiceImpl.java
index 1682d90..e645380 100644
--- a/src/main/java/com/ruoyi/basic/service/impl/StorageAttachmentServiceImpl.java
+++ b/src/main/java/com/ruoyi/basic/service/impl/StorageAttachmentServiceImpl.java
@@ -1,17 +1,22 @@
 package com.ruoyi.basic.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.basic.dto.StorageAttachmentDTO;
+import com.ruoyi.basic.dto.StorageAttachmentVO;
+import com.ruoyi.basic.dto.StorageBlobDTO;
+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.service.StorageAttachmentService;
 import com.ruoyi.basic.service.StorageBlobService;
-import com.ruoyi.common.constant.StorageAttachmentConstants;
-import com.ruoyi.common.enums.StorageAttachmentRecordType;
-import com.ruoyi.common.utils.MinioUtils;
+import com.ruoyi.basic.utils.FileUtil;
 import lombok.RequiredArgsConstructor;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
@@ -26,71 +31,22 @@
 @Service
 @RequiredArgsConstructor
 public class StorageAttachmentServiceImpl extends ServiceImpl<StorageAttachmentMapper, StorageAttachment> implements StorageAttachmentService {
-    @Autowired
-    private StorageBlobMapper storageBlobMapper;
+    private final StorageBlobMapper storageBlobMapper;
 
-    @Autowired
-    private StorageAttachmentMapper storageAttachmentMapper;
+    private final StorageAttachmentMapper storageAttachmentMapper;
 
-    @Autowired
-    private StorageBlobService storageBlobService;
-
-    @Autowired
-    private MinioUtils minioUtils;
+    private final StorageBlobService storageBlobService;
+    private final FileUtil fileUtil;
 
     @Override
-    public List<StorageAttachment> selectStorageAttachments(Long recordId, StorageAttachmentRecordType recordType, String fileType) {
-        // todo fileChange
-//        List<StorageAttachment> storageAttachments = storageAttachmentMapper.selectList(new LambdaQueryWrapper<StorageAttachment>()
-//                .eq(StorageAttachment::getRecordId, recordId)
-//                .eq(StorageAttachment::getRecordType, recordType.ordinal())
-//                .eq(StorageAttachment::getName, fileType));
-//        if (storageAttachments != null) {
-//            for (StorageAttachment storageAttachment : storageAttachments) {
-//                StorageBlob storageBlob = storageBlobMapper.selectById(storageAttachment.getStorageBlobId());
-//                StorageBlobDTO storageBlobDTO = new StorageBlobDTO();
-//                BeanUtils.copyProperties(storageBlob, storageBlobDTO);
-//                storageBlobDTO.setUrl(minioUtils.getPreviewUrl(storageBlob.getBucketName(), storageBlob.getBucketName(), true));
-//                storageAttachment.setStorageBlobDTO(storageBlobDTO);
-//            }
-//        }
-
-//        return storageAttachments;
-        return null;
+    @Transactional(rollbackFor = Exception.class)
+    public void saveStorageAttachment(StorageAttachmentDTO storageAttachmentDTO) {
+        fileUtil.saveStorageAttachmentByRecordTypeAndRecordId(storageAttachmentDTO.getApplication(), RecordTypeEnum.getByType(storageAttachmentDTO.getRecordType()), storageAttachmentDTO.getRecordId(), storageAttachmentDTO.getStorageBlobDTOs());
     }
 
     @Override
-    public void saveStorageAttachment(List<StorageAttachment> attachments, Long recordId, StorageAttachmentRecordType recordType, StorageAttachmentConstants fileType) {
-        // 鍒犻櫎鏃у浘
-        // todo fileChange
-//        deleteStorageAttachment(new StorageAttachment(fileType.toString(), (long) recordType.ordinal(), recordId));
-//        for (StorageAttachment attachment : attachments) {
-//            // 鑾峰彇鍏宠仈璁板綍
-//            StorageBlob storageBlob = attachment.getStorageBlobDTO();
-//            attachment.setName(fileType.toString());
-//            attachment.setRecordType((long) recordType.ordinal());
-//            attachment.setRecordId(recordId);
-//            attachment.setStorageBlobId(storageBlob.getId());
-//            storageAttachmentMapper.insert(attachment);
-//        }
-
-    }
-
-    @Override
-    public void saveStorageAttachment(List<StorageAttachment> attachments, Long recordId, StorageAttachmentRecordType recordType, String fileType) {
-        // 鍒犻櫎鏃у浘
-//        deleteStorageAttachment(new StorageAttachment(fileType, (long) recordType.ordinal(), recordId));
-        // todo fileChange
-//        for (StorageAttachment attachment : attachments) {
-//            // 鑾峰彇鍏宠仈璁板綍
-//            StorageBlob storageBlob = attachment.getStorageBlobDTO();
-//            attachment.setName(fileType);
-//            attachment.setRecordType((long) recordType.ordinal());
-//            attachment.setRecordId(recordId);
-//            attachment.setStorageBlobId(storageBlob.getId());
-//            storageAttachmentMapper.insert(attachment);
-//        }
-
+    public IPage<StorageAttachmentVO> listPage(Page page, StorageAttachmentDTO storageAttachmentDTO) {
+        return fileUtil.getStorageAttachmentVosPageListByApplicationAndRecordTypeAndRecordId(page, storageAttachmentDTO);
     }
 
     @Override
@@ -107,4 +63,10 @@
 //    }
         return 0;
     }
+
+    @Override
+    public int batchDeleteStorageAttachment(List<Long> ids) {
+        fileUtil.deleteStorageAttachmentsByStorageAttachmentIds(ids);
+        return 1;
+    }
 }

--
Gitblit v1.9.3