添加上传人

This commit is contained in:
haozq 2025-09-29 13:32:43 +08:00
parent 3b2aac8602
commit e2e93d2a5e
3 changed files with 30 additions and 18 deletions

View File

@ -66,10 +66,14 @@ public class UploadFileVo {
*/ */
private String createTime; private String createTime;
private String createUser;
/** /**
* 获取bast64文件 * 获取bast64文件
*/ */
private String bast64; private String bast64;
private String userName;
} }

View File

@ -2,6 +2,7 @@ package com.bonus.file.service.impl;
import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.file.config.MinioConfig; import com.bonus.file.config.MinioConfig;
import com.bonus.file.mapper.FileUtilMapper; import com.bonus.file.mapper.FileUtilMapper;
import com.bonus.file.utils.MinioUtil; import com.bonus.file.utils.MinioUtil;
@ -84,6 +85,7 @@ public class FileUtilsServiceImpl {
String path="/"+bucketName+"/"+filePath; String path="/"+bucketName+"/"+filePath;
vo.setPath(path); vo.setPath(path);
vo.setUrl(minioConfig.getUrl()); vo.setUrl(minioConfig.getUrl());
vo.setCreateUser(SecurityUtils.getUserId().toString());
int num=mapper.insertUploadFile(vo); int num=mapper.insertUploadFile(vo);
if(num>0){ if(num>0){
return vo; return vo;
@ -136,6 +138,7 @@ public class FileUtilsServiceImpl {
String path="/"+bucketName+"/"+filePath; String path="/"+bucketName+"/"+filePath;
vo.setPath(path); vo.setPath(path);
vo.setUrl(minioConfig.getUrl()); vo.setUrl(minioConfig.getUrl());
vo.setCreateUser(SecurityUtils.getUserId().toString());
int num=mapper.insertUploadFile(vo); int num=mapper.insertUploadFile(vo);
if(num>0){ if(num>0){
return vo; return vo;
@ -186,6 +189,7 @@ public class FileUtilsServiceImpl {
String path="/"+bucketName+"/"+filePath; String path="/"+bucketName+"/"+filePath;
vo.setPath(path); vo.setPath(path);
vo.setUrl(minioConfig.getUrl()); vo.setUrl(minioConfig.getUrl());
vo.setCreateUser(SecurityUtils.getUserId().toString());
list.add(vo); list.add(vo);
} }
int num=mapper.insertUploadFileList(list); int num=mapper.insertUploadFileList(list);
@ -242,6 +246,7 @@ public class FileUtilsServiceImpl {
String path="/"+bucketName+"/"+filePath; String path="/"+bucketName+"/"+filePath;
vo.setPath(path); vo.setPath(path);
vo.setUrl(minioConfig.getUrl()); vo.setUrl(minioConfig.getUrl());
vo.setCreateUser(SecurityUtils.getUserId().toString());
list.add(vo); list.add(vo);
} }
int num=mapper.insertUploadFileList(list); int num=mapper.insertUploadFileList(list);

View File

@ -7,16 +7,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!--文件插入--> <!--文件插入-->
<insert id="insertUploadFile" keyProperty="id" useGeneratedKeys="true"> <insert id="insertUploadFile" keyProperty="id" useGeneratedKeys="true">
insert into bm_files( insert into bm_files(
source_table, source_id, source_type, file_name, file_key,bucket_name, create_time, update_time, is_active, origin_file_name,file_url,file_path source_table, source_id, source_type, file_name, file_key,bucket_name, create_time, update_time, is_active, origin_file_name,file_url,file_path,create_user
)values (#{sourceTable},#{sourceId},#{sourceType},#{fileName},#{filePath},#{bucketName},now(),now(),1,#{originFileName},#{url},#{path}) )values (#{sourceTable},#{sourceId},#{sourceType},#{fileName},#{filePath},#{bucketName},now(),now(),1,#{originFileName},#{url},#{path},#{createUser})
</insert> </insert>
<!--多文件上传--> <!--多文件上传-->
<insert id="insertUploadFileList" keyProperty="id" useGeneratedKeys="true"> <insert id="insertUploadFileList" keyProperty="id" useGeneratedKeys="true">
insert into bm_files ( source_table, source_id, source_type, file_name, file_key,bucket_name, create_time, update_time, is_active, origin_file_name,file_url,file_path insert into bm_files ( source_table, source_id, source_type, file_name, file_key,bucket_name, create_time,
update_time, is_active, origin_file_name,file_url,file_path,create_user
) values ) values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.sourceTable},#{item.sourceId},#{item.sourceType},#{item.fileName},#{item.filePath}, (#{item.sourceTable},#{item.sourceId},#{item.sourceType},#{item.fileName},#{item.filePath},
#{item.bucketName},now(),now(),1,#{item.originFileName},#{item.url},#{item.path}) #{item.bucketName},now(),now(),1,#{item.originFileName},#{item.url},#{item.path},#{item.createUser})
</foreach> </foreach>
</insert> </insert>
<!--删除文件--> <!--删除文件-->
@ -48,30 +49,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update> </update>
<select id="getFileList" resultType="com.bonus.system.api.model.UploadFileVo"> <select id="getFileList" resultType="com.bonus.system.api.model.UploadFileVo">
select id, source_table sourceTable, source_id sourceId, source_type sourceType, file_name fileName, select file.id, file.source_table sourceTable, file.source_id sourceId, file.source_type sourceType, file.file_name fileName,
file_key filePath, bucket_name bucketName, create_time createTime, file.file_key filePath, file.bucket_name bucketName, file.create_time createTime,
origin_file_name originFileName, file_path path, file_url url file.origin_file_name originFileName, file.file_path path, file.file_url url,su.user_name userName
from bm_files from bm_files file
where is_active=1 left join sys_user su on su.user_id=file.create_user
where file.is_active=1
<if test="id!=null and id!=''"> <if test="id!=null and id!=''">
and id=#{id} and file.id=#{id}
</if> </if>
<if test="sourceId !=null and sourceId!=''"> <if test="sourceId !=null and sourceId!=''">
and source_id=#{sourceId} and file.source_id=#{sourceId}
</if> </if>
<if test="sourceType !=null and sourceType!=''"> <if test="sourceType !=null and sourceType!=''">
and source_type=#{sourceType} and file.source_type=#{sourceType}
</if> </if>
<if test="sourceTable !=null and sourceTable!=''"> <if test="sourceTable !=null and sourceTable!=''">
and source_table=#{sourceTable} and file.source_table=#{sourceTable}
</if> </if>
</select> </select>
<select id="getFileListByIds" resultType="com.bonus.system.api.model.UploadFileVo"> <select id="getFileListByIds" resultType="com.bonus.system.api.model.UploadFileVo">
select id, source_table sourceTable, source_id sourceId, source_type sourceType, file_name fileName, select file.id, file.source_table sourceTable, file.source_id sourceId, file.source_type sourceType, file.file_name fileName,
file_key filePath, bucket_name bucketName, create_time createTime, file.file_key filePath, file.bucket_name bucketName, file.create_time createTime,
origin_file_name originFileName, file_path path, file_url url file.origin_file_name originFileName, file.file_path path, file.file_url url,su.user_name userName
from bm_files from bm_files file
where id in left join sys_user su on su.user_id=file.create_user
where file.id in
<foreach collection="ids" item="item" open="(" close=")" separator="," > <foreach collection="ids" item="item" open="(" close=")" separator="," >
#{item} #{item}
</foreach> </foreach>