ltkj-admin/src/main/java/com/ltkj/web/config/captcha/CommonController.java
@@ -3,12 +3,20 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ltkj.common.core.domain.R; import com.ltkj.common.core.domain.entity.SysDictData; import com.ltkj.common.utils.SnowFlake; import com.ltkj.common.utils.uuid.UUID; import com.ltkj.hosp.domain.SysAttachment; import com.ltkj.hosp.service.ISysAttachmentService; import com.ltkj.system.service.ISysDictDataService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -51,6 +59,10 @@ @Value("${ltkj.profile}") String path; @Autowired private ISysAttachmentService sysAttachmentService; @Autowired private ISysDictDataService sysDictDataService; /** @@ -132,6 +144,55 @@ } } @PostMapping("/uploadImgExe") @ApiOperation(value = "EXE程序循环读取图片上传") public AjaxResult uploadImgExe(@RequestPart("file") MultipartFile file,@RequestParam("val")String dictVal,@RequestParam("ip")String ip){ try { // 上传文件路径 String filePath = ltkjConfig.getUploadPath(); // 上传并返回新文件名称 String fileName = FileUploadUtils.upload(filePath, file); String url = serverConfig.getUrl() + fileName; AjaxResult ajax = AjaxResult.success(); ajax.put("url", url); //ajax.put("filePath", path+fileName); ajax.put("fileName", fileName); final String newFileName = FileUtils.getName(fileName); ajax.put("newFileName", newFileName); ajax.put("originalFilename", file.getOriginalFilename()); SysAttachment sysAttachment = new SysAttachment(); sysAttachment.setId(SnowFlake.getInstance().nextId()); sysAttachment.setFileName(newFileName); sysAttachment.setFilePath(fileName); sysAttachment.setUrl(url); sysAttachment.setSysDictVal(dictVal); sysAttachment.setIp(ip); final Map<String, String> map = FileUploadUtils.getFileSize(file); sysAttachment.setFileSize(map.get("fileSizeBytes")); sysAttachment.setFileSizeMb(map.get("fileSizeMB")); sysAttachment.setFileSizeGb(map.get("fileSizeGB")); sysAttachmentService.insertSysAttachment(sysAttachment); return ajax; } catch (Exception e) { e.printStackTrace(); return AjaxResult.error(e.getMessage()); } } @GetMapping("/listExeVal") public AjaxResult listExeDictVal(){ LambdaQueryWrapper<SysDictData> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(SysDictData::getDictType,"sys_exe_img_type"); final List<SysDictData> list = sysDictDataService.list(queryWrapper); ArrayList<HashMap<String, String>> hashMaps = new ArrayList<>(); for (SysDictData sysDictData : list) { HashMap<String, String> hashMap = new HashMap<>(); hashMap.put("label",sysDictData.getDictLabel()); hashMap.put("value",sysDictData.getDictValue()); hashMaps.add(hashMap); } return AjaxResult.success().put("data",hashMaps); } @GetMapping("/uploadFile") @ApiOperation(value = "通用文件上传base64") ltkj-admin/src/main/java/com/ltkj/web/controller/system/SysAttachmentController.java
New file @@ -0,0 +1,98 @@ package com.ltkj.web.controller.system; import java.util.List; import javax.servlet.http.HttpServletResponse; import com.ltkj.hosp.service.ISysAttachmentService; import org.springframework.security.access.prepost.PreAuthorize; 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.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ltkj.common.annotation.Log; import com.ltkj.common.core.controller.BaseController; import com.ltkj.common.core.domain.AjaxResult; import com.ltkj.common.enums.BusinessType; import com.ltkj.hosp.domain.SysAttachment; import com.ltkj.common.utils.poi.ExcelUtil; import com.ltkj.common.core.page.TableDataInfo; /** * 文件上传记录Controller * * @author ltkj_赵佳豪&李格 * @date 2024-05-21 */ @RestController @RequestMapping("/attachment/attachment") public class SysAttachmentController extends BaseController { @Autowired private ISysAttachmentService sysAttachmentService; /** * 查询文件上传记录列表 */ @PreAuthorize("@ss.hasPermi('attachment:attachment:list')") @GetMapping("/list") public TableDataInfo list(SysAttachment sysAttachment) { startPage(); List<SysAttachment> list = sysAttachmentService.selectSysAttachmentList(sysAttachment); return getDataTable(list); } /** * 导出文件上传记录列表 */ @PreAuthorize("@ss.hasPermi('attachment:attachment:export')") @Log(title = "文件上传记录", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, SysAttachment sysAttachment) { List<SysAttachment> list = sysAttachmentService.selectSysAttachmentList(sysAttachment); ExcelUtil<SysAttachment> util = new ExcelUtil<SysAttachment>(SysAttachment. class); util.exportExcel(response, list, "文件上传记录数据"); } /** * 获取文件上传记录详细信息 */ @PreAuthorize("@ss.hasPermi('attachment:attachment:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { return success(sysAttachmentService.selectSysAttachmentById(id)); } /** * 新增文件上传记录 */ @PreAuthorize("@ss.hasPermi('attachment:attachment:add')") @Log(title = "文件上传记录", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody SysAttachment sysAttachment) { return toAjax(sysAttachmentService.insertSysAttachment(sysAttachment)); } /** * 修改文件上传记录 */ @PreAuthorize("@ss.hasPermi('attachment:attachment:edit')") @Log(title = "文件上传记录", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody SysAttachment sysAttachment) { return toAjax(sysAttachmentService.updateSysAttachment(sysAttachment)); } /** * 删除文件上传记录 */ @PreAuthorize("@ss.hasPermi('attachment:attachment:remove')") @Log(title = "文件上传记录", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(sysAttachmentService.deleteSysAttachmentByIds(ids)); } } ltkj-common/src/main/java/com/ltkj/common/utils/SnowFlake.java
New file @@ -0,0 +1,137 @@ package com.ltkj.common.utils; import java.util.concurrent.locks.ReentrantLock; /** * 描述: Twitter的分布式自增ID雪花算法snowflake (Java版) * * Twitter_Snowflake<br> * SnowFlake的结构如下(每部分用-分开):<br> * 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000 <br> * 1位标识,由于long基本类型在Java中是带符号的,最高位是符号位,正数是0,负数是1,所以id一般是正数,最高位是0<br> * 41位时间截(毫秒级),注意,41位时间截不是存储当前时间的时间截,而是存储时间截的差值(当前时间截 - 开始时间截) * 得到的值),这里的的开始时间截,一般是我们的id生成器开始使用的时间,由我们程序来指定的(如下下面程序IdWorker类的startTime属性)。41位的时间截,可以使用69年,年T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69<br> * 10位的数据机器位,可以部署在1024个节点,包括5位datacenterId和5位workerId<br> * 12位序列,毫秒内的计数,12位的计数顺序号支持每个节点每毫秒(同一机器,同一时间截)产生4096个ID序号<br> * 加起来刚好64位,为一个Long型。<br> * SnowFlake的优点是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由数据中心ID和机器ID作区分),并且效率较高,经测试,SnowFlake每秒能够产生26万ID左右。 * @author Administrator * */ public class SnowFlake { private static SnowFlake snowFlake; private static ReentrantLock lock = new ReentrantLock(); public static SnowFlake getInstance() { if (snowFlake == null) { lock.lock(); if (snowFlake == null) {; datacenterId = Long.valueOf(StringUtils.nvl(null, "1")); machineId = Long.valueOf(StringUtils.nvl(null, "1")); snowFlake = new SnowFlake(datacenterId,machineId); } lock.unlock(); } return snowFlake; } /** * 起始的时间戳 */ private final static long START_STMP = 1480166465631L; /** * 每一部分占用的位数 */ private final static long SEQUENCE_BIT = 12; //序列号占用的位数 private final static long MACHINE_BIT = 5; //机器标识占用的位数 private final static long DATACENTER_BIT = 5;//数据中心占用的位数 /** * 每一部分的最大值 */ private final static long MAX_DATACENTER_NUM = -1L ^ (-1L << DATACENTER_BIT); private final static long MAX_MACHINE_NUM = -1L ^ (-1L << MACHINE_BIT); private final static long MAX_SEQUENCE = -1L ^ (-1L << SEQUENCE_BIT); /** * 每一部分向左的位移 */ private final static long MACHINE_LEFT = SEQUENCE_BIT; private final static long DATACENTER_LEFT = SEQUENCE_BIT + MACHINE_BIT; private final static long TIMESTMP_LEFT = DATACENTER_LEFT + DATACENTER_BIT; private static long machineId; //机器标识(0~31) private static long datacenterId; //数据中心(0~31) private long sequence = 0L; //序列号 private long lastStmp = -1L;//上一次时间戳 public SnowFlake(long datacenterId, long machineId) { if (datacenterId > MAX_DATACENTER_NUM || datacenterId < 0) { throw new IllegalArgumentException("datacenterId can't be greater than MAX_DATACENTER_NUM or less than 0"); } if (machineId > MAX_MACHINE_NUM || machineId < 0) { throw new IllegalArgumentException("machineId can't be greater than MAX_MACHINE_NUM or less than 0"); } SnowFlake.datacenterId = datacenterId; SnowFlake.machineId = machineId; } /** * 产生下一个ID * * @return */ public synchronized long nextId() { long currStmp = getNewstmp(); //如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常 if (currStmp < lastStmp) { throw new RuntimeException("Clock moved backwards. Refusing to generate id"); } //如果是同一时间生成的,则进行毫秒内序列 if (currStmp == lastStmp) { //相同毫秒内,序列号自增 sequence = (sequence + 1) & MAX_SEQUENCE; //同一毫秒的序列数已经达到最大 if (sequence == 0L) { currStmp = getNextMill(); } } else { //不同毫秒内,序列号置为0 sequence = 0L; } //上次生成ID的时间截 lastStmp = currStmp; //移位并通过或运算拼到一起组成64位的ID return (currStmp - START_STMP) << TIMESTMP_LEFT //时间戳部分 | datacenterId << DATACENTER_LEFT //数据中心部分 | machineId << MACHINE_LEFT //机器标识部分 | sequence; //序列号部分 } private long getNextMill() { long mill = getNewstmp(); while (mill <= lastStmp) { mill = getNewstmp(); } return mill; } private long getNewstmp() { return System.currentTimeMillis(); } public static void main(String[] args) { SnowFlake snowFlake = new SnowFlake(1, 1); long start = System.currentTimeMillis(); for (int i = 0; i < 10; i++) { System.out.println(snowFlake.nextId()); } System.out.println(System.currentTimeMillis() - start); } } ltkj-common/src/main/java/com/ltkj/common/utils/file/FileUploadUtils.java
@@ -3,6 +3,8 @@ import java.io.File; import java.io.IOException; import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import java.util.Objects; import com.ltkj.common.config.ltkjConfig; @@ -196,4 +198,17 @@ } return extension; } public static Map<String, String> getFileSize(MultipartFile file) throws IOException { long fileSizeBytes = file.getSize(); double fileSizeMB = fileSizeBytes / (1024.0 * 1024.0); double fileSizeGB = fileSizeBytes / (1024.0 * 1024.0 * 1024.0); String fileSizeMBStr = String.format("%.2f MB", fileSizeMB); String fileSizeGBStr = String.format("%.2f GB", fileSizeGB); Map<String, String> result = new HashMap<>(); result.put("fileSizeBytes", fileSizeBytes + " Bytes"); result.put("fileSizeMB", fileSizeMBStr); result.put("fileSizeGB", fileSizeGBStr); return result; } } ltkj-framework/src/main/java/com/ltkj/framework/config/SecurityConfig.java
@@ -109,6 +109,7 @@ .authorizeRequests() // 对于登录login 注册register 验证码captchaImage 允许匿名访问 .antMatchers("/login", "/register", "/captchaImage","/cus/**","/getCaptchaConfigKey","/report/jmreport/**","/sqlserver/getdata/**").permitAll() .antMatchers("/common/uploadImgExe","/common/listExeVal").permitAll() // 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() ltkj-hosp/src/main/java/com/ltkj/hosp/domain/SysAttachment.java
New file @@ -0,0 +1,164 @@ package com.ltkj.hosp.domain; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; import com.ltkj.common.annotation.Excel; import com.ltkj.common.core.domain.BaseEntity; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; /** * 文件上传记录对象 sys_attachment * * @author ltkj_赵佳豪&李格 * @date 2024-05-21 */ public class SysAttachment extends BaseEntity { private static final long serialVersionUID=1L; /** 编号 */ private Long id; /** 字典键值 */ @Excel(name = "字典键值") private String sysDictVal; /** 文件保存路径 */ @Excel(name = "文件保存路径") private String filePath; /** 文件名 */ @Excel(name = "文件名") private String fileName; /** 文件大小 */ @Excel(name = "文件大小") private String fileSize; /** 文件大小-mb */ @Excel(name = "文件大小-mb") private String fileSizeMb; /** 文件大小-gb */ @Excel(name = "文件大小-gb") private String fileSizeGb; /** 文件上传时间 */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "文件上传时间", width = 30, dateFormat = "yyyy-MM-dd") private Date uploadTime; /** 上传人ip */ @Excel(name = "上传人ip") private String ip; /** 上传后的访问链接 */ @Excel(name = "上传后的访问链接") private String url; public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public void setId(Long id) { this.id = id; } public Long getId() { return id; } public void setSysDictVal(String sysDictVal) { this.sysDictVal = sysDictVal; } public String getSysDictVal() { return sysDictVal; } public void setFilePath(String filePath) { this.filePath = filePath; } public String getFilePath() { return filePath; } public void setFileName(String fileName) { this.fileName = fileName; } public String getFileName() { return fileName; } public void setFileSize(String fileSize) { this.fileSize = fileSize; } public String getFileSize() { return fileSize; } public void setFileSizeMb(String fileSizeMb) { this.fileSizeMb = fileSizeMb; } public String getFileSizeMb() { return fileSizeMb; } public void setFileSizeGb(String fileSizeGb) { this.fileSizeGb = fileSizeGb; } public String getFileSizeGb() { return fileSizeGb; } public void setUploadTime(Date uploadTime) { this.uploadTime = uploadTime; } public Date getUploadTime() { return uploadTime; } public void setIp(String ip) { this.ip = ip; } public String getIp() { return ip; } @Override public String toString(){ return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) .append("id",getId()) .append("sysDictVal",getSysDictVal()) .append("filePath",getFilePath()) .append("fileName",getFileName()) .append("fileSize",getFileSize()) .append("fileSizeMb",getFileSizeMb()) .append("fileSizeGb",getFileSizeGb()) .append("uploadTime",getUploadTime()) .append("ip",getIp()) .append("url",getUrl()) .toString(); } } ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/SysAttachmentMapper.java
New file @@ -0,0 +1,61 @@ package com.ltkj.hosp.mapper; import java.util.List; import com.ltkj.hosp.domain.SysAttachment; /** * 文件上传记录Mapper接口 * * @author ltkj_赵佳豪&李格 * @date 2024-05-21 */ public interface SysAttachmentMapper { /** * 查询文件上传记录 * * @param id 文件上传记录主键 * @return 文件上传记录 */ public SysAttachment selectSysAttachmentById(Long id); /** * 查询文件上传记录列表 * * @param sysAttachment 文件上传记录 * @return 文件上传记录集合 */ public List<SysAttachment> selectSysAttachmentList(SysAttachment sysAttachment); /** * 新增文件上传记录 * * @param sysAttachment 文件上传记录 * @return 结果 */ public int insertSysAttachment(SysAttachment sysAttachment); /** * 修改文件上传记录 * * @param sysAttachment 文件上传记录 * @return 结果 */ public int updateSysAttachment(SysAttachment sysAttachment); /** * 删除文件上传记录 * * @param id 文件上传记录主键 * @return 结果 */ public int deleteSysAttachmentById(Long id); /** * 批量删除文件上传记录 * * @param ids 需要删除的数据主键集合 * @return 结果 */ public int deleteSysAttachmentByIds(Long[] ids); } ltkj-hosp/src/main/java/com/ltkj/hosp/service/ISysAttachmentService.java
New file @@ -0,0 +1,61 @@ package com.ltkj.hosp.service; import java.util.List; import com.ltkj.hosp.domain.SysAttachment; /** * 文件上传记录Service接口 * * @author ltkj_赵佳豪&李格 * @date 2024-05-21 */ public interface ISysAttachmentService { /** * 查询文件上传记录 * * @param id 文件上传记录主键 * @return 文件上传记录 */ public SysAttachment selectSysAttachmentById(Long id); /** * 查询文件上传记录列表 * * @param sysAttachment 文件上传记录 * @return 文件上传记录集合 */ public List<SysAttachment> selectSysAttachmentList(SysAttachment sysAttachment); /** * 新增文件上传记录 * * @param sysAttachment 文件上传记录 * @return 结果 */ public int insertSysAttachment(SysAttachment sysAttachment); /** * 修改文件上传记录 * * @param sysAttachment 文件上传记录 * @return 结果 */ public int updateSysAttachment(SysAttachment sysAttachment); /** * 批量删除文件上传记录 * * @param ids 需要删除的文件上传记录主键集合 * @return 结果 */ public int deleteSysAttachmentByIds(Long[] ids); /** * 删除文件上传记录信息 * * @param id 文件上传记录主键 * @return 结果 */ public int deleteSysAttachmentById(Long id); } ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/SysAttachmentServiceImpl.java
New file @@ -0,0 +1,86 @@ package com.ltkj.hosp.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ltkj.hosp.mapper.SysAttachmentMapper; import com.ltkj.hosp.domain.SysAttachment; import com.ltkj.hosp.service.ISysAttachmentService; /** * 文件上传记录Service业务层处理 * * @author ltkj_赵佳豪&李格 * @date 2024-05-21 */ @Service public class SysAttachmentServiceImpl implements ISysAttachmentService { @Autowired private SysAttachmentMapper sysAttachmentMapper; /** * 查询文件上传记录 * * @param id 文件上传记录主键 * @return 文件上传记录 */ @Override public SysAttachment selectSysAttachmentById(Long id) { return sysAttachmentMapper.selectSysAttachmentById(id); } /** * 查询文件上传记录列表 * * @param sysAttachment 文件上传记录 * @return 文件上传记录 */ @Override public List<SysAttachment> selectSysAttachmentList(SysAttachment sysAttachment) { return sysAttachmentMapper.selectSysAttachmentList(sysAttachment); } /** * 新增文件上传记录 * * @param sysAttachment 文件上传记录 * @return 结果 */ @Override public int insertSysAttachment(SysAttachment sysAttachment) { return sysAttachmentMapper.insertSysAttachment(sysAttachment); } /** * 修改文件上传记录 * * @param sysAttachment 文件上传记录 * @return 结果 */ @Override public int updateSysAttachment(SysAttachment sysAttachment) { return sysAttachmentMapper.updateSysAttachment(sysAttachment); } /** * 批量删除文件上传记录 * * @param ids 需要删除的文件上传记录主键 * @return 结果 */ @Override public int deleteSysAttachmentByIds(Long[] ids) { return sysAttachmentMapper.deleteSysAttachmentByIds(ids); } /** * 删除文件上传记录信息 * * @param id 文件上传记录主键 * @return 结果 */ @Override public int deleteSysAttachmentById(Long id) { return sysAttachmentMapper.deleteSysAttachmentById(id); } } ltkj-hosp/src/main/resources/mapper/hosp/SysAttachmentMapper.xml
New file @@ -0,0 +1,157 @@ <?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.ltkj.hosp.mapper.SysAttachmentMapper"> <resultMap type="SysAttachment" id="SysAttachmentResult"> <result property="id" column="id"/> <result property="sysDictVal" column="sys_dict_val"/> <result property="filePath" column="file_path"/> <result property="fileName" column="file_name"/> <result property="fileSize" column="file_size"/> <result property="fileSizeMb" column="file_size_mb"/> <result property="fileSizeGb" column="file_size_gb"/> <result property="uploadTime" column="upload_time"/> <result property="ip" column="ip"/> <result property="url" column="url"/> </resultMap> <sql id="selectSysAttachmentVo"> select id, sys_dict_val, file_path, file_name, file_size, file_size_mb, file_size_gb, upload_time, ip,url from sys_attachment </sql> <select id="selectSysAttachmentList" parameterType="SysAttachment" resultMap="SysAttachmentResult"> <include refid="selectSysAttachmentVo"/> <where> <if test="sysDictVal != null and sysDictVal != ''"> and sys_dict_val = #{sysDictVal} </if> <if test="filePath != null and filePath != ''"> and file_path = #{filePath} </if> <if test="fileName != null and fileName != ''"> and file_name like concat('%', #{fileName}, '%') </if> <if test="fileSize != null and fileSize != ''"> and file_size = #{fileSize} </if> <if test="fileSizeMb != null and fileSizeMb != ''"> and file_size_mb = #{fileSizeMb} </if> <if test="fileSizeGb != null and fileSizeGb != ''"> and file_size_gb = #{fileSizeGb} </if> <if test="uploadTime != null "> and upload_time = #{uploadTime} </if> <if test="ip != null and ip != ''"> and ip = #{ip} </if> <if test="url != null and url != ''"> and url = #{url} </if> </where> </select> <select id="selectSysAttachmentById" parameterType="Long" resultMap="SysAttachmentResult"> <include refid="selectSysAttachmentVo"/> where id = #{id} </select> <insert id="insertSysAttachment" parameterType="SysAttachment"> insert into sys_attachment <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null">id, </if> <if test="sysDictVal != null">sys_dict_val, </if> <if test="filePath != null and filePath != ''">file_path, </if> <if test="fileName != null and fileName != ''">file_name, </if> <if test="fileSize != null and fileSize != ''">file_size, </if> <if test="fileSizeMb != null and fileSizeMb != ''">file_size_mb, </if> <if test="fileSizeGb != null and fileSizeGb != ''">file_size_gb, </if> <if test="uploadTime != null">upload_time, </if> <if test="ip != null and ip != ''">ip, </if> <if test="url != null and url != ''">url, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id}, </if> <if test="sysDictVal != null">#{sysDictVal}, </if> <if test="filePath != null and filePath != ''">#{filePath}, </if> <if test="fileName != null and fileName != ''">#{fileName}, </if> <if test="fileSize != null and fileSize != ''">#{fileSize}, </if> <if test="fileSizeMb != null and fileSizeMb != ''">#{fileSizeMb}, </if> <if test="fileSizeGb != null and fileSizeGb != ''">#{fileSizeGb}, </if> <if test="uploadTime != null">#{uploadTime}, </if> <if test="ip != null and ip != ''">#{ip}, </if> <if test="url != null and url != ''">#{url}, </if> </trim> </insert> <update id="updateSysAttachment" parameterType="SysAttachment"> update sys_attachment <trim prefix="SET" suffixOverrides=","> <if test="sysDictVal != null">sys_dict_val = #{sysDictVal}, </if> <if test="filePath != null and filePath != ''">file_path = #{filePath}, </if> <if test="fileName != null and fileName != ''">file_name = #{fileName}, </if> <if test="fileSize != null and fileSize != ''">file_size = #{fileSize}, </if> <if test="fileSizeMb != null and fileSizeMb != ''">file_size_mb = #{fileSizeMb}, </if> <if test="fileSizeGb != null and fileSizeGb != ''">file_size_gb = #{fileSizeGb}, </if> <if test="uploadTime != null">upload_time = #{uploadTime}, </if> <if test="ip != null and ip != ''">ip = #{ip}, </if> <if test="url != null and url != ''">ip = #{url}, </if> </trim> where id = #{id} </update> <delete id="deleteSysAttachmentById" parameterType="Long"> delete from sys_attachment where id = #{id} </delete> <delete id="deleteSysAttachmentByIds" parameterType="String"> delete from sys_attachment where id in <foreach item="id" collection="array" open="(" separator="," close=")"> #{id} </foreach> </delete> </mapper>