xiexiang 2 năm trước cách đây
mục cha
commit
3ea3f819b3

+ 21 - 10
src/main/java/com/example/fms/controller/FileMangerController.java

@@ -1,15 +1,21 @@
 package com.example.fms.controller;
 
-import com.example.fms.common.model.dto.DownloadFileDTO;
 import com.example.fms.common.utils.Response;
-import com.example.fms.service.IFileManagerService;
+import com.example.fms.domain.SystemFile;
+import com.example.fms.service.FileMangerService;
+import com.example.fms.service.SystemFileService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.core.io.InputStreamResource;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.ByteArrayInputStream;
 import java.util.List;
 
 /**
@@ -22,21 +28,26 @@ import java.util.List;
 @RequiredArgsConstructor
 @RequestMapping("/fileManager")
 public class FileMangerController {
-    private final IFileManagerService fileManagerService;
-
+    private final FileMangerService fileManagerService;
+    private final SystemFileService systemFileService;
 
     @PostMapping("/uploadSystemFile")
     @Operation(summary = "上传文件")
     public String upload(@RequestBody List<MultipartFile> files, Integer sourceId) {
-        //sourceId为1,是FSS
-        fileManagerService.add(files, sourceId);
-        return Response.success("上传系统文件成功");
+        List<Integer> insertIds = fileManagerService.add(files, sourceId);
+        return Response.success(insertIds);
     }
 
-    @PostMapping("/downloadSystemFile")
+    @GetMapping("/downloadSystemFile")
     @Operation(summary = "取出文件")
-    public String download(@RequestBody DownloadFileDTO downloadFileDTO) throws Exception {
-        return fileManagerService.download(downloadFileDTO);
+    public ResponseEntity<InputStreamResource> download(Integer fileId) throws Exception {
+        byte[] fileData = fileManagerService.download(fileId);
+        SystemFile systemFile = systemFileService.getById(fileId);
+        String fileName = systemFile.getFileName();
+        return ResponseEntity.ok().contentLength(fileData.length)
+                .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + fileName + "\"")
+                .contentType(MediaType.parseMediaType("application/octet-stream"))
+                .body(new InputStreamResource(new ByteArrayInputStream(fileData)));
     }
 
     @PostMapping("/deleteSystemFile")

+ 15 - 7
src/main/java/com/example/fms/domain/SystemFile.java

@@ -1,7 +1,9 @@
 package com.example.fms.domain;
 
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.example.fms.common.model.BaseEntity;
 import lombok.Data;
-import lombok.experimental.Accessors;
 
 import java.util.Date;
 
@@ -11,62 +13,68 @@ import java.util.Date;
  * @Author xiexiang
  * @Date 2023/6/1
  */
-@Accessors(chain = true)
 @Data
-public class SystemFile {
-    /**
-     * 主键id
-     */
-    private Integer id;
+@TableName("SYSTEM_FILE")
+public class SystemFile extends BaseEntity<SystemFile> {
 
     /**
      * 唯一标识id
      */
+    @TableField("GUID")
     private String GUID;
 
     /**
      * 存储位置
      */
+    @TableField("P_TYPE")
     private Integer pType;
 
     /**
      * 文件路径
      */
+    @TableField("FILE_PATH")
     private String filePath;
 
     /**
      * 文件名称
      */
+    @TableField("FILE_NAME")
     private String fileName;
 
     /**
      * 原始名称
      */
+    @TableField("ORIGINAL_NAME")
     private String originalName;
 
     /**
      * 文件大小
      */
+    @TableField("FILE_LENGTH")
     private String fileLength;
 
     /**
      * 创建人id
      */
+    @TableField("CREATE_ID")
     private Integer createId;
 
     /**
      * 更新时间
      */
+    @TableField("UPDATE_TIME")
     private Date updateTime;
 
     /**
      * 创建时间
      */
+    @TableField("CREATE_TIME")
     private Date createTime;
 
     /**
      * 是否删除
      */
+    @TableField("IS_DELETE")
     private Integer isDelete;
 
 }

+ 2 - 25
src/main/java/com/example/fms/mapper/SystemFileMapper.java

@@ -1,11 +1,11 @@
 package com.example.fms.mapper;
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.example.fms.common.model.vo.SystemFileVO;
 import com.example.fms.domain.SystemFile;
 import org.apache.ibatis.annotations.Mapper;
 import org.springframework.stereotype.Repository;
 
-import java.util.List;
 
 /**
  * 系统文件的Mapper层接口
@@ -15,14 +15,7 @@ import java.util.List;
  */
 @Repository
 @Mapper
-public interface SystemFileMapper {
-    /**
-     * 新增系统文件
-     *
-     * @param systemFile
-     * @return 受影响的行数
-     */
-    int add(SystemFile systemFile);
+public interface SystemFileMapper extends BaseMapper<SystemFile> {
 
     /**
      * 更新系统文件
@@ -41,22 +34,6 @@ public interface SystemFileMapper {
     SystemFileVO query(Integer id);
 
     /**
-     * 删除系统文件
-     *
-     * @param ids
-     * @return
-     */
-    int deleteByIds(List<Integer> ids);
-
-    /**
-     * 删除系统文件
-     *
-     * @param id
-     * @return
-     */
-    int deleteById(Integer id);
-
-    /**
      * 根据文件名查询
      * @param fileName
      * @return

+ 12 - 26
src/main/java/com/example/fms/service/FileFactoryService.java

@@ -1,17 +1,14 @@
 package com.example.fms.service;
 
-import cn.hutool.core.util.IdUtil;
+
 import com.example.fms.common.model.dto.DownloadSysFileDTO;
 import com.example.fms.common.model.dto.SystemFileDTO;
 import com.example.fms.common.model.vo.ConfigSettingVO;
-import com.example.fms.common.model.vo.SystemFileVO;
 import com.example.fms.common.utils.ExcuteConfigUtils;
 import com.example.fms.common.utils.FileUtils;
-import com.example.fms.common.utils.SFTP;
 import com.example.fms.exception.XiaoShiException;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -28,7 +25,6 @@ import java.util.*;
 @RequiredArgsConstructor
 public class FileFactoryService {
     private final FileUtils fileUtils;
-    private final ISystemFileService systemFileService;
 
     /**
      * 上传文件
@@ -46,9 +42,7 @@ public class FileFactoryService {
                 return null;
             }
             String sourceName = configSettingVO.getSourceName();
-            if (sourceName.equals("OSS")) {
-                return this.uploadToOSS(files, configSettingVO);
-            } else if (sourceName.equals("FSS")) {
+            if(sourceName.equals("FSS")) {
                 return this.uploadToFSS(files, configSettingVO);
             }
             return null;
@@ -81,23 +75,13 @@ public class FileFactoryService {
         return systemFileDTOS;
     }
 
-    /**
-     * 上传到OSS阿里云
-     *
-     * @param files
-     * @param configSettingVO
-     * @return
-     */
-    public List<SystemFileDTO> uploadToOSS(List<MultipartFile> files, ConfigSettingVO configSettingVO){
-        return null;
-    }
 
     /**
      * 下载文件
      * @param downloadSysFileDTO
      * @throws Exception
      */
-    public void download(DownloadSysFileDTO downloadSysFileDTO) throws Exception {
+    public byte[] download(DownloadSysFileDTO downloadSysFileDTO) throws Exception {
         Integer sourceId = downloadSysFileDTO.getSourceId();
         //调用解析配置方法,获取配置信息
         List<ConfigSettingVO> configSettingVOS = ExcuteConfigUtils.excuteConfigVO();
@@ -108,9 +92,10 @@ public class FileFactoryService {
         }
         String sourceName = configSettingVO.getSourceName();
         if (sourceName.equals("FSS")) {
-            this.downloadFromFSS(downloadSysFileDTO, configSettingVO);
-        } else if(sourceName.equals("OSS")) {
-
+            byte[] file = this.downloadFromFSS(downloadSysFileDTO, configSettingVO);
+            return file;
+        } else {
+            return null;
         }
     }
     /**
@@ -118,7 +103,7 @@ public class FileFactoryService {
      * @param //downloadFile 下载的文件
      * @param //saveFile 存在本地的路径
      */
-    public void downloadFromFSS(DownloadSysFileDTO downloadSysFileDTO, ConfigSettingVO configSettingVO) throws Exception {
+    public byte[] downloadFromFSS(DownloadSysFileDTO downloadSysFileDTO, ConfigSettingVO configSettingVO) throws Exception {
         //下载目录,也是存储路径
         String filePath = downloadSysFileDTO.getFilePath();
         int index = filePath.lastIndexOf("/");
@@ -126,8 +111,10 @@ public class FileFactoryService {
         //下载的文件,也就是文件名
         String downloadFile = downloadSysFileDTO.getFileName();
         //存在本地的路径,随机生成
-        String saveFile = "C:\\Users\\Admin\\Desktop\\downloadFile" + downloadFile;
-        SftpService.download(directory, downloadFile, saveFile, configSettingVO);
+//        String saveFile = "C:\\Users\\Admin\\Desktop\\downloadFile";
+//        byte[] fileData = SftpService.download(directory, downloadFile, saveFile, configSettingVO);
+        byte[] fileData = SftpService.download(directory, downloadFile, configSettingVO);
+        return fileData;
     }
     /**
      * 删除文件
@@ -157,7 +144,6 @@ public class FileFactoryService {
         } else if(pType.equals(2)){//类型为2,则为阿里云OSS
             int sourceId = 2;
             ConfigSettingVO configSettingVO = configSettingVOS.stream().filter(item -> item.getSourceId().equals(sourceId)).findFirst().orElse(null);
-
         }
     }
 

+ 16 - 63
src/main/java/com/example/fms/service/impl/FileManagerServiceImpl.java

@@ -1,24 +1,14 @@
-package com.example.fms.service.impl;
+package com.example.fms.service;
 
-import com.example.fms.common.model.dto.DownloadFileDTO;
 import com.example.fms.common.model.dto.DownloadSysFileDTO;
 import com.example.fms.common.model.dto.SystemFileDTO;
-import com.example.fms.common.model.vo.ConfigSettingVO;
 import com.example.fms.common.model.vo.SystemFileVO;
-import com.example.fms.common.utils.ExcuteConfigUtils;
-import com.example.fms.common.utils.Response;
 import com.example.fms.domain.SystemFile;
 import com.example.fms.exception.XiaoShiException;
 import com.example.fms.mapper.SystemFileMapper;
-import com.example.fms.service.FileFactoryService;
-import com.example.fms.service.IFileManagerService;
-import com.example.fms.service.ISystemFileService;
-import com.example.fms.service.SftpService;
-
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
-import org.springframework.context.annotation.Bean;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
@@ -26,17 +16,15 @@ import org.springframework.web.multipart.MultipartFile;
 import java.util.List;
 
 /**
- * service层实现类
- *
  * @Author xiexiang
- * @Date 2023/6/7
+ * @Date 2023/8/9
  */
+@RequiredArgsConstructor
 @Slf4j
 @Service
-@RequiredArgsConstructor
-public class FileManagerServiceImpl implements IFileManagerService {
+public class FileMangerService {
     private final FileFactoryService fileFactoryService;
-    private final ISystemFileService systemFileService;
+    private final SystemFileService systemFileService;
     private final SystemFileMapper systemFileMapper;
 
     /**
@@ -45,14 +33,14 @@ public class FileManagerServiceImpl implements IFileManagerService {
      * @param files
      * @param sourceId
      */
-    @Override
-    public void add(List<MultipartFile> files, Integer sourceId){
+    public List<Integer> add(List<MultipartFile> files, Integer sourceId){
         if(files != null && files.size() != 0){
             //1.获取文件上传到服务器,调用FileFactory的uploadFile
             List<SystemFileDTO> systemFileDTOS = fileFactoryService.uploadFiles(files, sourceId);
             //2.根据上传后的返回实体类信息,将实体类信息入库,调用systemFileService add
             if(systemFileDTOS != null && systemFileDTOS.size() != 0 ) {
-                systemFileService.add(systemFileDTOS);
+                List<Integer> insertIds = systemFileService.add(systemFileDTOS);
+                return insertIds;
             } else {
                 throw new XiaoShiException("入表信息为空");
             }
@@ -62,58 +50,27 @@ public class FileManagerServiceImpl implements IFileManagerService {
     }
 
     //取系统文件
-    @Override
-    public String download(DownloadFileDTO downloadFileDTO) throws Exception {
-        Integer fileId = downloadFileDTO.getFileId();
-        String fileName = downloadFileDTO.getFileName();
-        Integer sourceId = downloadFileDTO.getSourceId();
+    public byte[] download(Integer fileId) throws Exception {
         DownloadSysFileDTO downloadSysFileDTO = new DownloadSysFileDTO();
-        SystemFileVO systemFileVO = new SystemFileVO();
-        if(fileId != null && fileName == null){
-            systemFileVO = systemFileService.query(fileId);
-            if(systemFileVO.getIsDelete().equals(1)){
-                return Response.error("文件已被删除");
-            } else {
-                BeanUtils.copyProperties(systemFileVO,downloadSysFileDTO);
-                downloadSysFileDTO.setSourceId(sourceId);
-                fileFactoryService.download(downloadSysFileDTO);
-                return Response.success("下载成功");
-            }
-        } else if(fileId == null && fileName != null) {
-            systemFileVO = systemFileMapper.getSystemFile(fileName);
+        if(fileId != null){
+            SystemFileVO systemFileVO = systemFileService.query(fileId);
             if(systemFileVO.getIsDelete().equals(1)){
-                return Response.error("文件已被删除");
+                return null;
             } else {
                 BeanUtils.copyProperties(systemFileVO,downloadSysFileDTO);
-                downloadSysFileDTO.setSourceId(sourceId);
-                fileFactoryService.download(downloadSysFileDTO);
-                return Response.success("下载成功");
-            }
-        } else if(fileId != null && fileName != null){
-            systemFileVO = systemFileService.query(fileId);
-            if(fileName.equals(systemFileVO.getFileName())){
-                if(systemFileVO.getIsDelete().equals(1)){
-                    return Response.error("文件已被删除");
-                } else {
-                    BeanUtils.copyProperties(systemFileVO,downloadSysFileDTO);
-                    downloadSysFileDTO.setSourceId(sourceId);
-                    fileFactoryService.download(downloadSysFileDTO);
-                    return Response.success("下载成功");
-                }
-            } else {
-                return Response.error("错误数据");
+                downloadSysFileDTO.setSourceId(systemFileVO.getPType());
+                return fileFactoryService.download(downloadSysFileDTO);
             }
-        } else {
-            return Response.error("参数错误");
         }
+        return null;
     }
+
     /**
      * 删除系统文件
      *
      * @param ids
      * @param type
      */
-    @Override
     public void delete(List<Integer> ids, Integer type){
         //首先判断传入的需要删除的id集合不能为空
         if(CollectionUtils.isEmpty(ids)){
@@ -160,8 +117,4 @@ public class FileManagerServiceImpl implements IFileManagerService {
             }
         }
     }
-    //系统文件是否存在
 }
-
-
-

+ 0 - 37
src/main/java/com/example/fms/service/IFileManagerService.java

@@ -1,37 +0,0 @@
-package com.example.fms.service;
-
-import com.example.fms.common.model.dto.DownloadFileDTO;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.util.List;
-
-/**
- * @Author xiexiang
- * @Date 2023/6/7
- */
-public interface IFileManagerService {
-    /**
-     * 上传系统文件
-     *
-     * @param files
-     * @param sourceId
-     */
-    @Transactional
-    void add(List<MultipartFile> files, Integer sourceId);
-
-    /**
-     * 删除系统文件
-     *
-     * @param ids
-     * @param type
-     */
-    @Transactional
-    void delete(List<Integer> ids, Integer type);
-
-    /**
-     * 下载系统文件
-     *
-     */
-    String download(DownloadFileDTO downloadFileDTO) throws Exception;
-}

+ 0 - 57
src/main/java/com/example/fms/service/ISystemFileService.java

@@ -1,57 +0,0 @@
-package com.example.fms.service;
-
-import com.example.fms.common.model.dto.SystemFileDTO;
-import com.example.fms.common.model.dto.SystemFileUpdateDTO;
-import com.example.fms.common.model.vo.SystemFileVO;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.List;
-
-/**
- * @Author xiexiang
- * @Date 2023/6/1
- */
-public interface ISystemFileService {
-
-    /**
-     * 新增系统文件
-     *
-     * @param systemFiles
-     */
-    @Transactional
-    void add(List<SystemFileDTO> systemFiles);
-
-    /**
-     * 更新系统文件
-     *
-     * @param systemFiles
-     */
-    @Transactional
-    void update(List<SystemFileUpdateDTO> systemFiles);
-
-    /**
-     * 查询系统文件
-     *
-     * @param id
-     * @return
-     */
-    SystemFileVO query(Integer id);
-
-    /**
-     * 删除系统文件
-     *
-     * @param id
-     * @return
-     */
-    @Transactional
-    void deleteById(Integer id);
-
-    /**
-     * 批量删除系统文件
-     *
-     * @param ids
-     * @return
-     */
-    @Transactional
-    void deleteByIds(List<Integer> ids);
-}

+ 24 - 15
src/main/java/com/example/fms/service/SftpService.java

@@ -7,11 +7,14 @@ import com.example.fms.common.model.vo.ConfigSettingVO;
 import com.example.fms.common.utils.FileUtils;
 import com.example.fms.common.utils.SFTP;
 import com.jcraft.jsch.*;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.util.IOUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
+
 import java.io.*;
-import java.util.List;
 import java.util.Properties;
 
 /**
@@ -20,6 +23,8 @@ import java.util.Properties;
  * @Author xiexiang
  * @Date 2023/6/7
  */
+@RequiredArgsConstructor
+@Slf4j
 @Service
 public class SftpService {
 
@@ -167,11 +172,11 @@ public class SftpService {
      * 下载文件
      * @param directory 下载目录 根据SFTP设置的根目录来进行传输
      * @param downloadFile 下载的文件名
-     * @param saveFile 存在本地的路径
+//     * @param saveFile 存在本地的路径
      * @param configSettingVO
      * @throws Exception
      */
-    public static void download(String directory, String downloadFile, String saveFile, ConfigSettingVO configSettingVO) throws Exception {
+    public static byte[] download(String directory, String downloadFile, ConfigSettingVO configSettingVO) throws Exception {
         SFTP s = new SFTP();
         //建立连接
         getConnect(s, configSettingVO);
@@ -182,18 +187,22 @@ public class SftpService {
         try {
             //进入目录
             sftp.cd(directory);
-            File file = new File(saveFile);
-            boolean bFile;
-            bFile = false;
-            bFile = file.exists();
-            if (!bFile) {
-                //创建目录
-                bFile = file.mkdirs();
-            }
-            OutputStream out = new FileOutputStream(new File(saveFile, downloadFile));
-            sftp.get(downloadFile, out);
-            out.flush();
-            out.close();
+//            File file = new File(saveFile);
+//            boolean bFile;
+//            bFile = false;
+//            bFile = file.exists();
+//            if (!bFile) {
+//                //创建目录
+//                bFile = file.mkdirs();
+//            }
+            InputStream is = sftp.get(downloadFile);
+            byte[] fileData = IOUtils.toByteArray(is);
+//            OutputStream out = new FileOutputStream(new File(saveFile, downloadFile));
+//            sftp.get(downloadFile, out);
+//            out.flush();
+//            out.close();
+            is.close();
+            return fileData;
         } catch (Exception e) {
             throw new Exception(e.getMessage(), e);
         } finally {

+ 99 - 0
src/main/java/com/example/fms/service/SystemFileService.java

@@ -0,0 +1,99 @@
+package com.example.fms.service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.fms.common.model.dto.SystemFileDTO;
+import com.example.fms.common.model.dto.SystemFileUpdateDTO;
+import com.example.fms.common.model.vo.SystemFileVO;
+import com.example.fms.domain.SystemFile;
+import com.example.fms.exception.XiaoShiException;
+import com.example.fms.mapper.SystemFileMapper;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Author xiexiang
+ * @Date 2023/8/9
+ */
+@Slf4j
+@Service
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
+public class SystemFileService extends ServiceImpl<SystemFileMapper, SystemFile> {
+
+    /**
+     * 新增系统文件(批量)
+     *
+     * @param systemFileDTOS
+     */
+    public List<Integer> add(List<SystemFileDTO> systemFileDTOS){
+        //判断传入列表不为空
+        if(systemFileDTOS != null && systemFileDTOS.size() > 0){
+            List<Integer> insertIds = new ArrayList<>();
+            //遍历传入列表
+            for(int i = 0; i < systemFileDTOS.size(); i++) {
+                SystemFile systemFile = new SystemFile();
+                //取集合中的dto对象,并赋值给实体类
+                SystemFileDTO systemFileDTO = systemFileDTOS.get(i);
+                BeanUtils.copyProperties(systemFileDTO, systemFile);
+                //获取当前登陆人的信息
+//                PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+                //给实体类赋值登陆人id
+//                systemFile.setCreateId(personnelVO.getId());
+                systemFile.setCreateId(1);
+                //插入数据
+                systemFile.insert();
+                insertIds.add(systemFile.getId());
+            }
+            return insertIds;
+        } else {
+            throw new XiaoShiException("传入数据不能为空");
+        }
+    }
+
+    /**
+     * 更新系统文件(批量)
+     * @param systemFileUpdateDTOS
+     */
+    public void update(List<SystemFileUpdateDTO> systemFileUpdateDTOS){
+        //判断传入对象不为空
+        if(systemFileUpdateDTOS != null && systemFileUpdateDTOS.size() > 0){
+            //遍历传入列表
+            for(int i = 0; i < systemFileUpdateDTOS.size(); i++){
+                //取集合中的dto对象,并赋值给实体类
+                SystemFileUpdateDTO systemFileUpdateDTO = systemFileUpdateDTOS.get(i);
+                SystemFile systemFile = this.getById(systemFileUpdateDTO.getId());
+                BeanUtils.copyProperties(systemFileUpdateDTO, systemFile);
+                //数据入表
+                systemFile.updateById();
+            }
+        } else {
+            throw new XiaoShiException("传入数据不能为空");
+        }
+    }
+
+    /**
+     * 查询系统文件
+     *
+     * @param id
+     * @return
+     */
+    public SystemFileVO query(Integer id){
+        //id不为空且id不等于0
+        if(id != null && id != 0){
+            SystemFileVO systemFileVO = new SystemFileVO();
+            SystemFile systemFile = this.getById(id);
+            BeanUtils.copyProperties(systemFile, systemFileVO);
+            return systemFileVO;
+        } else {
+            String mes = "传入id不可以为空";
+            throw new XiaoShiException(mes);
+        }
+    }
+
+
+}

+ 0 - 137
src/main/java/com/example/fms/service/impl/SystemFileServiceImpl.java

@@ -1,137 +0,0 @@
-package com.example.fms.service.impl;
-
-import com.example.fms.common.model.dto.SystemFileDTO;
-import com.example.fms.common.model.dto.SystemFileUpdateDTO;
-import com.example.fms.common.model.vo.PersonnelVO;
-import com.example.fms.common.model.vo.SystemFileVO;
-import com.example.fms.common.utils.CacheUtils;
-import com.example.fms.common.utils.SecurityUtils.LoginUtils;
-import com.example.fms.domain.SystemFile;
-import com.example.fms.exception.XiaoShiException;
-import com.example.fms.mapper.SystemFileMapper;
-import com.example.fms.service.ISystemFileService;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.BeanUtils;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-/**
- * 系统文件的Service层实现类
- *
- * @Author xiexiang
- * @Date 2023/6/1
- */
-@Slf4j
-@Service
-@RequiredArgsConstructor
-public class SystemFileServiceImpl implements ISystemFileService {
-    private final SystemFileMapper systemFileMapper;
-    private final CacheUtils cacheUtils;
-    private final LoginUtils loginUtils;
-
-    /**
-     * 新增系统文件(批量)
-     *
-     * @param systemFileDTOS
-     */
-    @Override
-    public void add(List<SystemFileDTO> systemFileDTOS){
-        //判断传入列表不为空
-        if(systemFileDTOS != null && systemFileDTOS.size() > 0){
-            SystemFile systemFile = new SystemFile();
-            //遍历传入列表
-            for(int i = 0; i < systemFileDTOS.size(); i++){
-                //取集合中的dto对象,并赋值给实体类
-                SystemFileDTO systemFileDTO = systemFileDTOS.get(i);
-                BeanUtils.copyProperties(systemFileDTO, systemFile);
-                //获取当前登陆人的信息
-//                PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
-                //给实体类赋值登陆人id
-//                systemFile.setCreateId(personnelVO.getId());
-                systemFile.setCreateId(1);
-                //插入数据
-                int row = systemFileMapper.add(systemFile);
-                //判断正确性
-                if(row != 1){
-                    String mes = "新增系统文件第" + i + "条失败";
-                    log.info("新增失败,{}", mes);
-                    throw new XiaoShiException(mes);
-                }
-            }log.info("新增系统文件成功");
-        }
-    }
-
-    /**
-     * 更新系统文件(批量)
-     * @param systemFiles
-     */
-    @Override
-    public void update(List<SystemFileUpdateDTO> systemFiles){
-        //判断传入对象不为空
-        if(systemFiles != null && systemFiles.size() > 0){
-            SystemFile systemFile = new SystemFile();
-            //遍历传入列表
-            for(int i = 0; i < systemFiles.size(); i++){
-                //取集合中的dto对象,并赋值给实体类
-                SystemFileUpdateDTO systemFileUpdateDTO = systemFiles.get(i);
-                BeanUtils.copyProperties(systemFileUpdateDTO, systemFile);
-                //数据入表
-                int row = systemFileMapper.update(systemFile);
-                //判断正确性
-                if(row != 1){
-                    String mes = "更新系统文件第" + i + "条失败";
-                    log.info("更新失败,{}", mes);
-                    throw new XiaoShiException(mes);
-                }
-            }log.info("更新系统文件成功");
-        }
-    }
-
-    /**
-     * 查询系统文件
-     *
-     * @param id
-     * @return
-     */
-    @Override
-    public SystemFileVO query(Integer id){
-        //id不为空且id不等于0
-        if(id != null && id != 0){
-            return systemFileMapper.query(id);
-        } else {
-            String mes = "传入id不可以为空";
-            throw new XiaoShiException(mes);
-        }
-    }
-
-
-    /**
-     * 删除
-     *
-     * @param id
-     */
-    @Override
-    public void deleteById(Integer id){
-        if (id != null) {
-            systemFileMapper.deleteById(id);
-        } else {
-            throw new XiaoShiException("需要删除的id不能为空");
-        }
-    }
-
-    /**
-     * 批量删除
-     *
-     * @param ids
-     */
-    @Override
-    public void deleteByIds(List<Integer> ids) {
-        if (ids != null) {
-            systemFileMapper.deleteByIds(ids);
-        } else {
-            throw new XiaoShiException("需要删除的ids不能为空");
-        }
-    }
-}