From deb977cfae04e5aca02d465cdea4cbc23f22af32 Mon Sep 17 00:00:00 2001
From: liyj <1003249715@qq.com>
Date: Sat, 31 Aug 2024 17:38:28 +0800
Subject: [PATCH] 1、附件管理模块修改2

---
 dyh-service/dyh-sys/src/main/java/cn/huge/module/file/service/FileRelateService.java |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/dyh-service/dyh-sys/src/main/java/cn/huge/module/file/service/FileRelateService.java b/dyh-service/dyh-sys/src/main/java/cn/huge/module/file/service/FileRelateService.java
index 0bf31e4..1e9f06d 100644
--- a/dyh-service/dyh-sys/src/main/java/cn/huge/module/file/service/FileRelateService.java
+++ b/dyh-service/dyh-sys/src/main/java/cn/huge/module/file/service/FileRelateService.java
@@ -5,7 +5,10 @@
 import cn.huge.base.common.utils.IdUtils;
 import cn.huge.module.client.api.impl.UtilsClientImpl;
 import cn.huge.module.file.dao.mapper.FileRelateMapper;
+import cn.huge.module.file.domain.dto.UploaderDTO;
+import cn.huge.module.file.domain.po.FileInfo;
 import cn.huge.module.file.domain.po.FileRelate;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -130,4 +133,44 @@
         }
     }
 
+    /**
+     * 根据所属业务编号和类型统计
+     * @param ownerId 所属业务编号
+     * @param ownerType 所属业务类型
+     * @return int 统计数
+     */
+    public int countByOwnerIdAndType(String ownerId, String ownerType){
+        QueryWrapper<FileRelate> fileRelateQueryWrapper = new QueryWrapper<>();
+        fileRelateQueryWrapper.eq("owner_id", ownerId).eq("owner_type", ownerType);
+        return mapper.selectCount(fileRelateQueryWrapper);
+    }
+
+    /**
+     * 根据附件信息新增附件业务关系
+     * @param fileInfo 附件信息
+     */
+    public void saveByFileInfo(FileInfo fileInfo) {
+        try {
+            // 保存业务关系
+            FileRelate fileRelate = new FileRelate();
+            fileRelate.setId(utilsClient.getNewTimeId());
+            fileRelate.setFileId(fileInfo.getId());
+            fileRelate.setMainId(fileInfo.getMainId());
+            fileRelate.setOwnerId(fileInfo.getOwnerId());
+            fileRelate.setOwnerCat(fileInfo.getOwnerCat());
+            fileRelate.setOwnerType(fileInfo.getOwnerType());
+            fileRelate.setUploaderId(fileInfo.getUploaderId());
+            fileRelate.setUploaderName(fileInfo.getUploaderName());
+            fileRelate.setUploaderType(fileInfo.getUploaderType());
+            fileRelate.setCustId(fileInfo.getCustId());
+            Date nowDate = DateUtils.getNowDate();
+            fileRelate.setCreateTime(nowDate);
+            fileRelate.setUpdateTime(nowDate);
+            mapper.insert(fileRelate);
+        } catch (Exception e) {
+            log.error("service方法[FileRelateService.uploadFile]调用失败,异常信息:"+e, e);
+            throw new ServiceException("FileRelateService.uploadFile", e);
+        }
+    }
+
 }

--
Gitblit v1.8.0