From e55c8b0a92eb9715edd90c31dfd4de51a47b588b Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期五, 04 十一月 2022 17:40:08 +0800
Subject: [PATCH] changes

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedSFileService.java |   66 +++++++++++++++++++++++++-------
 1 files changed, 51 insertions(+), 15 deletions(-)

diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedSFileService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedSFileService.java
index 33e6d89..b16fbe5 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedSFileService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedSFileService.java
@@ -1,12 +1,16 @@
 package com.sandu.ximon.admin.service;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.github.pagehelper.PageHelper;
 import com.sandu.common.execption.BusinessException;
 import com.sandu.common.file.FileUploadDto;
 import com.sandu.common.file.impl.AliOssFileServiceImpl;
+import com.sandu.common.object.BaseConditionVO;
 import com.sandu.common.service.impl.BaseServiceImpl;
 import com.sandu.ximon.admin.security.SecurityUtils;
+import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
 import com.sandu.ximon.dao.domain.FileOperationRecord;
 import com.sandu.ximon.dao.domain.LedSFile;
 import com.sandu.ximon.dao.mapper.LedSFileMapper;
@@ -14,6 +18,8 @@
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
 
 /**
  * @Author liuhaonan
@@ -42,34 +48,64 @@
         LedSFile sFile = new LedSFile();
         BeanUtils.copyProperties(fileUploadDto, sFile);
         sFile.setCilentId(SecurityUtils.getClientId());
-        if (SecurityUtils.getClientId() != null) {
-            sFile.setUserId(SecurityUtils.getUserId());
-            sFile.setUserName(SecurityUtils.getUsername());
-            if (clientService.findClientId()) {
-                sFile.setCilentId(clientService.getClientId());
-            }
+        sFile.setUserId(SecurityUtils.getUserId());
+        sFile.setUserName(SecurityUtils.getUsername());
+        if (clientService.findClientId()) {
+            sFile.setCilentId(clientService.getClientId());
         }
+        /**
+         * 鐔欐睕鏂囦欢涓婁紶 鏃ュ織璁板綍寮�濮�
+         */
+        String content = "鏂囦欢鍐呭:" + JSON.toJSONString(fileUploadDto);
+        StoreOperationRecordsUtils.storeOperationData(null, null, "鐔欐睕鏂囦欢涓婁紶", content);
+        /**
+         * 鐔欐睕鏂囦欢涓婁紶 鏃ュ織璁板綍缁撴潫
+         */
         return save(sFile);
     }
 
-    public boolean deleteFile(Long id) {
-        LedSFile byId = getById(id);
-        if (byId == null) {
+    public boolean deleteFile(List<Long> fileIds) {
+        if (fileIds.isEmpty()) {
+            throw new BusinessException("鏂囦欢id涓嶈兘涓虹┖");
+        }
+        List<LedSFile> ledSFiles = listByIds(fileIds);
+        if (ledSFiles.isEmpty()) {
             throw new BusinessException("鏈壘鍒拌鑺傜洰");
         }
-        return removeById(id);
+
+        /**
+         * 鐔欐睕鏂囦欢鍒犻櫎 鏃ュ織璁板綍寮�濮�
+         */
+        String content = "鏂囦欢鍐呭id:" + fileIds + "鏂囦欢鍐呭:" + JSON.toJSONString(ledSFiles);
+        StoreOperationRecordsUtils.storeOperationData(null, null, "鐔欐睕鏂囦欢鍒犻櫎", content);
+        /**
+         * 鐔欐睕鏂囦欢鍒犻櫎 鏃ュ織璁板綍缁撴潫
+         */
+        return removeByIds(fileIds);
     }
 
-    public LambdaQueryWrapper<LedSFile> listFile() {
-        LambdaQueryWrapper<LedSFile> ledProgramFileLambdaQueryWrapper = Wrappers.lambdaQuery(LedSFile.class);
+
+    /**
+     * 鍒楄〃
+     *
+     * @param baseConditionVO
+     * @param keyword
+     * @return
+     */
+    public List<LedSFile> listfile(BaseConditionVO baseConditionVO, String keyword) {
+        LambdaQueryWrapper<LedSFile> wrapper = Wrappers.lambdaQuery(LedSFile.class);
         if (SecurityUtils.getClientId() != null) {
-            return ledProgramFileLambdaQueryWrapper.eq(LedSFile::getCilentId, SecurityUtils.getUserId()).or(w -> {
+            wrapper.eq(LedSFile::getCilentId, SecurityUtils.getUserId()).or(w -> {
                 w.eq(LedSFile::getUserId, SecurityUtils.getUserId());
             });
-        } else {
-            return ledProgramFileLambdaQueryWrapper;
         }
 
+        if (keyword != null && !keyword.isEmpty()) {
+            wrapper.like(LedSFile::getOriginName, keyword);
+        }
+
+        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
+        return list(wrapper);
     }
 
 }

--
Gitblit v1.9.3