From dd69bfc1fb8e5e28dde754fab7f23bfb1a18faa5 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期五, 05 六月 2026 16:58:07 +0800
Subject: [PATCH] config(dev): 更新开发环境配置和文件上传功能 - 调整文件上传路径配置 - 修复OA环境文件链接前缀配置 - 在审批实例服务中添加报销相关数据删除逻辑 - 实现申请人姓名自动填充功能 - 添加文件下载预览路由的正则表达式支持 - 为企业新闻VO添加附件列表兼容别名 - 完善员工入职服务的异常处理 - 新增账户附件管理控制器 - 实现文件上传接口并返回完整文件信息

---
 src/main/java/com/ruoyi/account/controller/AccountFileController.java |  129 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 129 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/ruoyi/account/controller/AccountFileController.java b/src/main/java/com/ruoyi/account/controller/AccountFileController.java
new file mode 100644
index 0000000..2a76e21
--- /dev/null
+++ b/src/main/java/com/ruoyi/account/controller/AccountFileController.java
@@ -0,0 +1,129 @@
+package com.ruoyi.account.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.basic.dto.StorageBlobVO;
+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.basic.utils.FileUtil;
+import com.ruoyi.framework.web.domain.R;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@RestController
+@RequiredArgsConstructor
+@Tag(name = "璐︽埛闄勪欢绠$悊")
+@RequestMapping("/account/accountFile")
+public class AccountFileController {
+
+    private final StorageAttachmentMapper storageAttachmentMapper;
+    private final StorageBlobMapper storageBlobMapper;
+    private final FileUtil fileUtil;
+
+    @GetMapping("/listPage")
+    @Operation(summary = "鍒嗛〉鏌ヨ闄勪欢鍒楄〃")
+    public R listPage(
+            @RequestParam Long accountId,
+            @RequestParam String accountType,
+            @RequestParam(defaultValue = "1") Long current,
+            @RequestParam(defaultValue = "10") Long size) {
+
+        Page<StorageBlobVO> page = new Page<>(current, size);
+
+        LambdaQueryWrapper<StorageAttachment> queryWrapper = new LambdaQueryWrapper<StorageAttachment>()
+                .eq(StorageAttachment::getRecordType, accountType)
+                .eq(StorageAttachment::getRecordId, accountId);
+
+        Long total = storageAttachmentMapper.selectCount(queryWrapper);
+        page.setTotal(total);
+
+        if (total == 0) {
+            page.setRecords(new ArrayList<>());
+            return R.ok(page);
+        }
+
+        List<StorageAttachment> storageAttachments = storageAttachmentMapper.selectList(queryWrapper);
+        Map<Long, Long> blobIdToAttachmentIdMap = storageAttachments.stream()
+                .collect(Collectors.toMap(StorageAttachment::getStorageBlobId, StorageAttachment::getId));
+
+        List<Long> storageBlobIds = storageAttachments.stream()
+                .map(StorageAttachment::getStorageBlobId)
+                .collect(Collectors.toList());
+
+        List<StorageBlob> storageBlobs = storageBlobMapper.selectByIds(storageBlobIds);
+        List<StorageBlobVO> storageBlobVOS = new ArrayList<>();
+        for (StorageBlob storageBlob : storageBlobs) {
+            StorageBlobVO storageBlobVO = new StorageBlobVO();
+            BeanUtils.copyProperties(storageBlob, storageBlobVO);
+            storageBlobVO.setPreviewURL(fileUtil.buildSignedPreviewUrl(storageBlobVO));
+            storageBlobVO.setUrl(fileUtil.buildSignedPreviewUrl(storageBlobVO));
+            storageBlobVO.setName(storageBlob.getOriginalFilename());
+            storageBlobVO.setDownloadURL(fileUtil.buildSignedDownloadUrl(storageBlobVO));
+            storageBlobVO.setStorageAttachmentId(blobIdToAttachmentIdMap.get(storageBlob.getId()));
+            storageBlobVOS.add(storageBlobVO);
+        }
+
+        page.setRecords(storageBlobVOS);
+        return R.ok(page);
+    }
+
+    @PostMapping("/add")
+    @Operation(summary = "淇濆瓨闄勪欢")
+    public R add(@RequestBody Map<String, Object> params) {
+        Long accountId = params.get("accountId") != null ? Long.valueOf(params.get("accountId").toString()) : null;
+        String accountType = params.get("accountType") != null ? params.get("accountType").toString() : null;
+
+        Long storageBlobId = null;
+        if (params.get("id") != null) {
+            storageBlobId = Long.valueOf(params.get("id").toString());
+        } else if (params.get("url") != null) {
+            String url = params.get("url").toString();
+            int previewIdx = url.indexOf("/preview/");
+            if (previewIdx >= 0) {
+                String afterPreview = url.substring(previewIdx + "/preview/".length());
+                int queryIdx = afterPreview.indexOf("?");
+                String uidFilename = queryIdx >= 0 ? afterPreview.substring(0, queryIdx) : afterPreview;
+                StorageBlob blob = storageBlobMapper.selectOne(new LambdaQueryWrapper<StorageBlob>()
+                        .eq(StorageBlob::getUidFilename, uidFilename).last("limit 1"));
+                if (blob != null) {
+                    storageBlobId = blob.getId();
+                }
+            }
+        }
+
+        if (accountId == null || accountType == null || storageBlobId == null) {
+            return R.fail("鍙傛暟涓嶅畬鏁�");
+        }
+
+        StorageAttachment storageAttachment = new StorageAttachment();
+        storageAttachment.setRecordType(accountType);
+        storageAttachment.setRecordId(accountId);
+        storageAttachment.setStorageBlobId(storageBlobId);
+        storageAttachment.setDeleted(0L);
+        storageAttachmentMapper.insert(storageAttachment);
+
+        return R.ok();
+    }
+
+    @DeleteMapping("/del")
+    @Operation(summary = "鍒犻櫎闄勪欢")
+    public R del(@RequestBody List<Long> ids) {
+        if (CollectionUtils.isEmpty(ids)) {
+            return R.fail("鍙傛暟涓嶈兘涓虹┖");
+        }
+        fileUtil.deleteStorageAttachmentsByStorageAttachmentIds(ids);
+        return R.ok();
+    }
+}

--
Gitblit v1.9.3