Ver código fonte

文件上传信息存储

车车 1 ano atrás
pai
commit
14ee0f99ca

+ 59 - 59
ktg-admin/src/main/java/com/ktg/web/controller/common/CommonController.java

@@ -1,11 +1,14 @@
 package com.ktg.web.controller.common;
 
-import java.util.ArrayList;
-import java.util.List;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 import com.ktg.common.config.RuoYiConfig;
+import com.ktg.common.constant.Constants;
+import com.ktg.common.core.domain.AjaxResult;
+import com.ktg.common.utils.StringUtils;
+import com.ktg.common.utils.file.FileUploadUtils;
+import com.ktg.common.utils.file.FileUtils;
+import com.ktg.framework.config.ServerConfig;
+import com.ktg.system.domain.SysUploadFile;
+import com.ktg.system.service.ISysUploadFileService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -15,42 +18,39 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
-import com.ktg.common.constant.Constants;
-import com.ktg.common.core.domain.AjaxResult;
-import com.ktg.common.utils.StringUtils;
-import com.ktg.common.utils.file.FileUploadUtils;
-import com.ktg.common.utils.file.FileUtils;
-import com.ktg.framework.config.ServerConfig;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * 通用请求处理
- * 
+ *
  * @author ruoyi
  */
 @RestController
 @RequestMapping("/common")
-public class CommonController
-{
+public class CommonController {
     private static final Logger log = LoggerFactory.getLogger(CommonController.class);
 
     @Autowired
     private ServerConfig serverConfig;
+    @Autowired
+    private ISysUploadFileService iSysUploadFileService;
 
     private static final String FILE_DELIMETER = ",";
 
     /**
      * 通用下载请求
-     * 
+     *
      * @param fileName 文件名称
-     * @param delete 是否删除
+     * @param delete   是否删除
      */
     @GetMapping("/download")
-    public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
-    {
-        try
-        {
-            if (!FileUtils.checkAllowDownload(fileName))
-            {
+    public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) {
+        try {
+            if (!FileUtils.checkAllowDownload(fileName)) {
                 throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
             }
             String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
@@ -59,13 +59,10 @@ public class CommonController
             response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
             FileUtils.setAttachmentResponseHeader(response, realFileName);
             FileUtils.writeBytes(filePath, response.getOutputStream());
-            if (delete)
-            {
+            if (delete) {
                 FileUtils.deleteFile(filePath);
             }
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("下载文件失败", e);
         }
     }
@@ -74,10 +71,8 @@ public class CommonController
      * 通用上传请求(单个)
      */
     @PostMapping("/upload")
-    public AjaxResult uploadFile(MultipartFile file) throws Exception
-    {
-        try
-        {
+    public AjaxResult uploadFile(MultipartFile file) throws Exception {
+        try {
             // 上传文件路径
             String filePath = RuoYiConfig.getUploadPath();
             // 上传并返回新文件名称
@@ -88,10 +83,17 @@ public class CommonController
             ajax.put("fileName", fileName);
             ajax.put("newFileName", FileUtils.getName(fileName));
             ajax.put("originalFilename", file.getOriginalFilename());
+
+            // 2.开始新增文件上传信息
+            SysUploadFile sysFile = new SysUploadFile();
+            sysFile.setName(fileName);
+            sysFile.setPath(filePath);
+            sysFile.setUrl(url);
+            sysFile.setType(file.getContentType());
+            sysFile.setSize(file.getSize());
+            iSysUploadFileService.insertSysUploadFile(sysFile);
             return ajax;
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             return AjaxResult.error(e.getMessage());
         }
     }
@@ -100,18 +102,15 @@ public class CommonController
      * 通用上传请求(多个)
      */
     @PostMapping("/uploads")
-    public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception
-    {
-        try
-        {
+    public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception {
+        try {
             // 上传文件路径
             String filePath = RuoYiConfig.getUploadPath();
             List<String> urls = new ArrayList<String>();
             List<String> fileNames = new ArrayList<String>();
             List<String> newFileNames = new ArrayList<String>();
             List<String> originalFilenames = new ArrayList<String>();
-            for (MultipartFile file : files)
-            {
+            for (MultipartFile file : files) {
                 // 上传并返回新文件名称
                 String fileName = FileUploadUtils.upload(filePath, file);
                 String url = serverConfig.getUrl() + fileName;
@@ -119,6 +118,14 @@ public class CommonController
                 fileNames.add(fileName);
                 newFileNames.add(FileUtils.getName(fileName));
                 originalFilenames.add(file.getOriginalFilename());
+                // 2.开始新增文件上传信息
+                SysUploadFile sysFile = new SysUploadFile();
+                sysFile.setName(fileName);
+                sysFile.setPath(filePath);
+                sysFile.setUrl(url);
+                sysFile.setType(file.getContentType());
+                sysFile.setSize(file.getSize());
+                iSysUploadFileService.insertSysUploadFile(sysFile);
             }
             AjaxResult ajax = AjaxResult.success();
             ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
@@ -126,9 +133,7 @@ public class CommonController
             ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
             ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
             return ajax;
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             return AjaxResult.error(e.getMessage());
         }
     }
@@ -138,12 +143,9 @@ public class CommonController
      */
     @GetMapping("/download/resource")
     public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
-            throws Exception
-    {
-        try
-        {
-            if (!FileUtils.checkAllowDownload(resource))
-            {
+            throws Exception {
+        try {
+            if (!FileUtils.checkAllowDownload(resource)) {
                 throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
             }
             // 本地资源路径
@@ -155,24 +157,22 @@ public class CommonController
             response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
             FileUtils.setAttachmentResponseHeader(response, downloadName);
             FileUtils.writeBytes(downloadPath, response.getOutputStream());
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("下载文件失败", e);
         }
     }
 
     @PostMapping("/uploadMinio")
-    public AjaxResult uploadFileMinio(MultipartFile file) throws Exception{
-        try{
+    public AjaxResult uploadFileMinio(MultipartFile file) throws Exception {
+        try {
             String fileName = FileUploadUtils.uploadMinio(file);
             AjaxResult rt = AjaxResult.success();
-            rt.put("url",fileName);
-            rt.put("fileName",fileName);
-            rt.put("newFileName",FileUtils.getName(fileName));
-            rt.put("originalFileName",file.getOriginalFilename());
+            rt.put("url", fileName);
+            rt.put("fileName", fileName);
+            rt.put("newFileName", FileUtils.getName(fileName));
+            rt.put("originalFileName", file.getOriginalFilename());
             return rt;
-        }catch (Exception e){
+        } catch (Exception e) {
             return AjaxResult.error(e.getMessage());
         }
     }

+ 21 - 11
ktg-admin/src/main/java/com/ktg/web/controller/system/SysProfileController.java

@@ -1,15 +1,5 @@
 package com.ktg.web.controller.system;
 
-import java.io.IOException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
 import com.ktg.common.annotation.Log;
 import com.ktg.common.config.RuoYiConfig;
 import com.ktg.common.constant.UserConstants;
@@ -21,12 +11,20 @@ import com.ktg.common.enums.BusinessType;
 import com.ktg.common.utils.SecurityUtils;
 import com.ktg.common.utils.StringUtils;
 import com.ktg.common.utils.file.FileUploadUtils;
+import com.ktg.framework.config.ServerConfig;
 import com.ktg.framework.web.service.TokenService;
+import com.ktg.system.domain.SysUploadFile;
+import com.ktg.system.service.ISysUploadFileService;
 import com.ktg.system.service.ISysUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
 
 /**
  * 个人信息 业务处理
- * 
+ *
  * @author ruoyi
  */
 @RestController
@@ -38,6 +36,10 @@ public class SysProfileController extends BaseController
 
     @Autowired
     private TokenService tokenService;
+    @Autowired
+    private ServerConfig serverConfig;
+    @Autowired
+    private ISysUploadFileService iSysUploadFileService;
 
     /**
      * 个人信息
@@ -134,6 +136,14 @@ public class SysProfileController extends BaseController
                 // 更新缓存用户头像
                 loginUser.getUser().setAvatar(avatar);
                 tokenService.setLoginUser(loginUser);
+                // 2.开始新增文件上传信息
+                SysUploadFile sysFile = new SysUploadFile();
+                sysFile.setName(avatar);
+                sysFile.setPath(RuoYiConfig.getAvatarPath());
+                sysFile.setUrl(serverConfig.getUrl() + avatar);
+                sysFile.setType(file.getContentType());
+                sysFile.setSize(file.getSize());
+                iSysUploadFileService.insertSysUploadFile(sysFile);
                 return ajax;
             }
         }

+ 116 - 0
ktg-admin/src/main/java/com/ktg/web/controller/system/SysUploadFileController.java

@@ -0,0 +1,116 @@
+package com.ktg.web.controller.system;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ktg.common.annotation.Log;
+import com.ktg.common.core.controller.BaseController;
+import com.ktg.common.enums.BusinessType;
+import com.ktg.common.pojo.CommonResult;
+import com.ktg.common.utils.poi.ExcelUtil;
+import com.ktg.system.domain.SysUploadFile;
+import com.ktg.system.service.ISysUploadFileService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Parameters;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 文件Controller
+ *
+ * @author cgj
+ * @date 2024-10-22
+ */
+@Api(tags = "文件")
+@RestController
+@RequestMapping("/system/file")
+public class SysUploadFileController extends BaseController
+{
+    @Autowired
+    private ISysUploadFileService sysUploadFileService;
+
+    /**
+     * 查询文件分页
+     */
+    @ApiOperation("查询文件-分页")
+    @Parameters({
+            @Parameter(name = "page", description = "Page"),
+            @Parameter(name = "sysUploadFile", description = "实体参数")
+    })
+    @PreAuthorize("@ss.hasPermi('system:file:list')")
+    @GetMapping("/getSysUploadFilePage")
+    public CommonResult<Page<SysUploadFile>> getSysUploadFilePage(Page<SysUploadFile> page, SysUploadFile sysUploadFile)
+    {
+        Page<SysUploadFile> result = sysUploadFileService.page(page, Wrappers.<SysUploadFile>lambdaQuery()
+                .orderByDesc(SysUploadFile::getId));
+        return CommonResult.success(result);
+    }
+
+    /**
+     * 导出文件列表
+     */
+    @ApiOperation("导出文件列表")
+    @Parameter(name = "sysUploadFile", description = "实体参数")
+    @PreAuthorize("@ss.hasPermi('system:file:export')")
+    @Log(title = "文件", businessType = BusinessType.EXPORT)
+    @PostMapping("/exportSysUploadFile")
+    public void exportSysUploadFile(HttpServletResponse response, SysUploadFile sysUploadFile)
+    {
+        List<SysUploadFile> list = sysUploadFileService.selectSysUploadFileList(sysUploadFile);
+        ExcelUtil<SysUploadFile> util = new ExcelUtil<SysUploadFile>(SysUploadFile.class);
+        util.exportExcel(response, list, "文件数据");
+    }
+
+    /**
+     * 获取文件详细信息
+     */
+    @ApiOperation("获取文件详细信息")
+    @Parameter(name = "id", description = "id")
+    @PreAuthorize("@ss.hasPermi('system:file:query')")
+    @GetMapping(value = "/selectSysUploadFileById")
+    public CommonResult<SysUploadFile> selectSysUploadFileById(Long id)
+    {
+        return CommonResult.success(sysUploadFileService.selectSysUploadFileById(id));
+    }
+
+    /**
+     * 新增文件
+     */
+    @ApiOperation("新增文件")
+    @PreAuthorize("@ss.hasPermi('system:file:add')")
+    @Log(title = "文件", businessType = BusinessType.INSERT)
+    @PostMapping("/insertSysUploadFile")
+    public CommonResult<Boolean> insertSysUploadFile(@RequestBody @Parameter(name = "sysUploadFile", description = "新增数据类,放到body") SysUploadFile sysUploadFile)
+    {
+        return CommonResult.success(sysUploadFileService.insertSysUploadFile(sysUploadFile) == 1);
+    }
+
+    /**
+     * 修改文件
+     */
+    @ApiOperation("修改文件")
+    @PreAuthorize("@ss.hasPermi('system:file:edit')")
+    @Log(title = "文件", businessType = BusinessType.UPDATE)
+    @PostMapping("/updateSysUploadFile")
+    public CommonResult<Boolean> updateSysUploadFile(@RequestBody @Parameter(name = "sysUploadFile", description = "修改数据类,放到body") SysUploadFile sysUploadFile)
+    {
+        return CommonResult.success(sysUploadFileService.updateSysUploadFile(sysUploadFile) == 1);
+    }
+
+    /**
+     * 删除文件
+     */
+    @ApiOperation("删除文件")
+    @PreAuthorize("@ss.hasPermi('system:file:remove')")
+    @Log(title = "文件", businessType = BusinessType.DELETE)
+	@PostMapping("/deleteSysUploadFileByIds")
+    public CommonResult<Boolean> deleteSysUploadFileByIds(String ids)
+    {
+        return CommonResult.success(sysUploadFileService.deleteSysUploadFileByIds(ids) != 0);
+    }
+}

+ 55 - 0
ktg-system/src/main/java/com/ktg/system/domain/SysUploadFile.java

@@ -0,0 +1,55 @@
+package com.ktg.system.domain;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import io.swagger.v3.oas.annotations.media.Schema;
+import com.ktg.common.annotation.Excel;
+import com.ktg.common.core.domain.model.BaseBean;
+
+/**
+ * 文件对象 sys_upload_file
+ *
+ * @author cgj
+ * @date 2024-10-22
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class SysUploadFile extends BaseBean
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 文件编号 */
+    @Schema(description = "文件编号")
+    private Long id;
+
+    /** 文件名 */
+    @Schema(description = "文件名")
+    @Excel(name = "文件名")
+    private String name;
+
+    /** 文件路径 */
+    @Schema(description = "文件路径")
+    @Excel(name = "文件路径")
+    private String path;
+
+    /** 文件 URL */
+    @Schema(description = "文件 URL")
+    @Excel(name = "文件 URL")
+    private String url;
+
+    /** 文件类型 */
+    @Schema(description = "文件类型")
+    @Excel(name = "文件类型")
+    private String type;
+
+    /** 文件大小 */
+    @Schema(description = "文件大小")
+    @Excel(name = "文件大小")
+    private Long size;
+
+    /** 删除标志(0代表存在 2代表删除) */
+    @Schema(description = "删除标志(0代表存在 2代表删除)")
+    private String delFlag;
+
+
+}

+ 65 - 0
ktg-system/src/main/java/com/ktg/system/mapper/SysUploadFileMapper.java

@@ -0,0 +1,65 @@
+package com.ktg.system.mapper;
+
+import com.ktg.common.mapper.BaseMapperX;
+import com.ktg.system.domain.SysUploadFile;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * 文件Mapper接口
+ *
+ * @author cgj
+ * @date 2024-10-22
+ */
+@Mapper
+public interface SysUploadFileMapper extends BaseMapperX<SysUploadFile>
+{
+    /**
+     * 查询文件
+     *
+     * @param id 文件主键
+     * @return 文件
+     */
+    SysUploadFile selectSysUploadFileById(Long id);
+
+    /**
+     * 查询文件列表
+     *
+     * @param sysUploadFile 文件
+     * @return 文件集合
+     */
+    List<SysUploadFile> selectSysUploadFileList(SysUploadFile sysUploadFile);
+
+    /**
+     * 新增文件
+     *
+     * @param sysUploadFile 文件
+     * @return 结果
+     */
+    int insertSysUploadFile(SysUploadFile sysUploadFile);
+
+    /**
+     * 修改文件
+     *
+     * @param sysUploadFile 文件
+     * @return 结果
+     */
+    int updateSysUploadFile(SysUploadFile sysUploadFile);
+
+    /**
+     * 删除文件
+     *
+     * @param id 文件主键
+     * @return 结果
+     */
+    int deleteSysUploadFileById(Long id);
+
+    /**
+     * 批量删除文件
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    int deleteSysUploadFileByIds(Long[] ids);
+}

+ 63 - 0
ktg-system/src/main/java/com/ktg/system/service/ISysUploadFileService.java

@@ -0,0 +1,63 @@
+package com.ktg.system.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ktg.system.domain.SysUploadFile;
+
+import java.util.List;
+
+/**
+ * 文件Service接口
+ *
+ * @author cgj
+ * @date 2024-10-22
+ */
+public interface ISysUploadFileService extends IService<SysUploadFile>
+{
+    /**
+     * 查询文件
+     *
+     * @param id 文件主键
+     * @return 文件
+     */
+    SysUploadFile selectSysUploadFileById(Long id);
+
+    /**
+     * 查询文件列表
+     *
+     * @param sysUploadFile 文件
+     * @return 文件集合
+     */
+    List<SysUploadFile> selectSysUploadFileList(SysUploadFile sysUploadFile);
+
+    /**
+     * 新增文件
+     *
+     * @param sysUploadFile 文件
+     * @return 结果
+     */
+    int insertSysUploadFile(SysUploadFile sysUploadFile);
+
+    /**
+     * 修改文件
+     *
+     * @param sysUploadFile 文件
+     * @return 结果
+     */
+    int updateSysUploadFile(SysUploadFile sysUploadFile);
+
+    /**
+     * 批量删除文件
+     *
+     * @param ids 需要删除的文件主键集合
+     * @return 结果
+     */
+    int deleteSysUploadFileByIds(String ids);
+
+    /**
+     * 删除文件信息
+     *
+     * @param id 文件主键
+     * @return 结果
+     */
+    int deleteSysUploadFileById(Long id);
+}

+ 102 - 0
ktg-system/src/main/java/com/ktg/system/service/impl/SysUploadFileServiceImpl.java

@@ -0,0 +1,102 @@
+package com.ktg.system.service.impl;
+
+import cn.hutool.core.lang.Assert;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ktg.common.core.text.Convert;
+import com.ktg.common.utils.DateUtils;
+import com.ktg.system.domain.SysUploadFile;
+import com.ktg.system.mapper.SysUploadFileMapper;
+import com.ktg.system.service.ISysUploadFileService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 文件Service业务层处理
+ *
+ * @author cgj
+ * @date 2024-10-22
+ */
+@Service
+public class SysUploadFileServiceImpl extends ServiceImpl<SysUploadFileMapper, SysUploadFile> implements ISysUploadFileService
+{
+    @Autowired
+    private SysUploadFileMapper sysUploadFileMapper;
+
+    /**
+     * 查询文件
+     *
+     * @param id 文件主键
+     * @return 文件
+     */
+    @Override
+    public SysUploadFile selectSysUploadFileById(Long id)
+    {
+        return sysUploadFileMapper.selectSysUploadFileById(id);
+    }
+
+    /**
+     * 查询文件列表
+     *
+     * @param sysUploadFile 文件
+     * @return 文件
+     */
+    @Override
+    public List<SysUploadFile> selectSysUploadFileList(SysUploadFile sysUploadFile)
+    {
+        return sysUploadFileMapper.selectSysUploadFileList(sysUploadFile);
+    }
+
+    /**
+     * 新增文件
+     *
+     * @param sysUploadFile 文件
+     * @return 结果
+     */
+    @Override
+    public int insertSysUploadFile(SysUploadFile sysUploadFile)
+    {
+        sysUploadFile.setCreateTime(DateUtils.getNowDate());
+        return sysUploadFileMapper.insertSysUploadFile(sysUploadFile);
+    }
+
+    /**
+     * 修改文件
+     *
+     * @param sysUploadFile 文件
+     * @return 结果
+     */
+    @Override
+    public int updateSysUploadFile(SysUploadFile sysUploadFile)
+    {
+        sysUploadFile.setUpdateTime(DateUtils.getNowDate());
+        return sysUploadFileMapper.updateSysUploadFile(sysUploadFile);
+    }
+
+    /**
+     * 批量删除文件
+     *
+     * @param ids 需要删除的文件主键
+     * @return 结果
+     */
+    @Override
+    public int deleteSysUploadFileByIds(String ids)
+    {
+        Assert.notBlank(ids, "请选择需要删除的数据!");
+        Long[] longIds = Convert.toLongArray(ids);
+        return sysUploadFileMapper.deleteSysUploadFileByIds(longIds);
+    }
+
+    /**
+     * 删除文件信息
+     *
+     * @param id 文件主键
+     * @return 结果
+     */
+    @Override
+    public int deleteSysUploadFileById(Long id)
+    {
+        return sysUploadFileMapper.deleteSysUploadFileById(id);
+    }
+}

+ 100 - 0
ktg-system/src/main/resources/mapper/system/SysUploadFileMapper.xml

@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ktg.system.mapper.SysUploadFileMapper">
+    
+    <resultMap type="SysUploadFile" id="SysUploadFileResult">
+        <result property="id"    column="id"    />
+        <result property="name"    column="name"    />
+        <result property="path"    column="path"    />
+        <result property="url"    column="url"    />
+        <result property="type"    column="type"    />
+        <result property="size"    column="size"    />
+        <result property="delFlag"    column="del_flag"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="remark"    column="remark"    />
+    </resultMap>
+
+    <sql id="selectSysUploadFileVo">
+        select id, name, path, url, type, size, del_flag, create_by, create_time, update_time, update_by, remark from sys_upload_file
+    </sql>
+
+    <select id="selectSysUploadFileList" parameterType="SysUploadFile" resultMap="SysUploadFileResult">
+        <include refid="selectSysUploadFileVo"/>
+        <where>  
+            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
+            <if test="path != null  and path != ''"> and path = #{path}</if>
+            <if test="url != null  and url != ''"> and url = #{url}</if>
+            <if test="type != null  and type != ''"> and type = #{type}</if>
+            <if test="size != null "> and size = #{size}</if>
+        </where>
+    </select>
+    
+    <select id="selectSysUploadFileById" parameterType="Long" resultMap="SysUploadFileResult">
+        <include refid="selectSysUploadFileVo"/>
+        where id = #{id}
+    </select>
+        
+    <insert id="insertSysUploadFile" parameterType="SysUploadFile" useGeneratedKeys="true" keyProperty="id">
+        insert into sys_upload_file
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="name != null">name,</if>
+            <if test="path != null and path != ''">path,</if>
+            <if test="url != null and url != ''">url,</if>
+            <if test="type != null">type,</if>
+            <if test="size != null">size,</if>
+            <if test="delFlag != null">del_flag,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="remark != null">remark,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="name != null">#{name},</if>
+            <if test="path != null and path != ''">#{path},</if>
+            <if test="url != null and url != ''">#{url},</if>
+            <if test="type != null">#{type},</if>
+            <if test="size != null">#{size},</if>
+            <if test="delFlag != null">#{delFlag},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="remark != null">#{remark},</if>
+         </trim>
+    </insert>
+
+    <update id="updateSysUploadFile" parameterType="SysUploadFile">
+        update sys_upload_file
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="name != null">name = #{name},</if>
+            <if test="path != null and path != ''">path = #{path},</if>
+            <if test="url != null and url != ''">url = #{url},</if>
+            <if test="type != null">type = #{type},</if>
+            <if test="size != null">size = #{size},</if>
+            <if test="delFlag != null">del_flag = #{delFlag},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteSysUploadFileById" parameterType="Long">
+        delete from sys_upload_file where id = #{id}
+    </delete>
+
+    <delete id="deleteSysUploadFileByIds" parameterType="String">
+        delete from sys_upload_file where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>