mirror of https://gitee.com/stylefeng/roses
【7.0.4】适配文件列表sql
parent
8cd14e900e
commit
c2474c4722
|
@ -26,7 +26,6 @@ package cn.stylefeng.roses.kernel.file.modular.mapper;
|
|||
|
||||
import cn.stylefeng.roses.kernel.file.api.pojo.request.SysFileInfoRequest;
|
||||
import cn.stylefeng.roses.kernel.file.api.pojo.response.SysFileInfoListResponse;
|
||||
import cn.stylefeng.roses.kernel.file.api.pojo.response.SysFileInfoResponse;
|
||||
import cn.stylefeng.roses.kernel.file.modular.entity.SysFileInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
@ -44,15 +43,6 @@ import java.util.List;
|
|||
*/
|
||||
public interface SysFileInfoMapper extends BaseMapper<SysFileInfo> {
|
||||
|
||||
/**
|
||||
* 根据附件IDS查询附件信息
|
||||
*
|
||||
* @param fileIdList 文件ID列表
|
||||
* @author majianguo
|
||||
* @date 2020/12/27 12:57
|
||||
*/
|
||||
List<SysFileInfoResponse> getFileInfoListByFileIds(@Param("fileIdList") List<Long> fileIdList);
|
||||
|
||||
/**
|
||||
* 附件列表(有分页)
|
||||
*
|
||||
|
|
|
@ -2,53 +2,66 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.stylefeng.roses.kernel.file.modular.mapper.SysFileInfoMapper">
|
||||
|
||||
<!-- 根据附件IDS查询附件信息 -->
|
||||
<select id="getFileInfoListByFileIds"
|
||||
resultType="cn.stylefeng.roses.kernel.file.api.pojo.response.SysFileInfoResponse">
|
||||
SELECT file.file_id AS fileId,
|
||||
file.file_code AS fileCode,
|
||||
file.file_version AS fileVersion,
|
||||
file.file_status AS fileStatus,
|
||||
file.file_origin_name AS fileOriginName,
|
||||
file.file_suffix AS fileSuffix,
|
||||
file.file_size_kb AS fileSizeKb,
|
||||
file.file_size_info AS fileSizeInfo,
|
||||
file.secret_flag AS secretFlag,
|
||||
file.file_object_name AS fileObjectName,
|
||||
file.create_time AS createTime
|
||||
FROM sys_file_info file
|
||||
WHERE file.del_flag = "N"
|
||||
AND file.file_id IN
|
||||
<foreach collection="fileIdList" separator="," open="(" close=")" item="fileId">
|
||||
#{fileId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- 附件列表 -->
|
||||
<select id="fileInfoList" resultType="cn.stylefeng.roses.kernel.file.api.pojo.response.SysFileInfoListResponse">
|
||||
<!--文件列表sql-->
|
||||
<sql id="file_list_mysql">
|
||||
SELECT file.file_id AS fileId,
|
||||
file.file_code AS fileCode,
|
||||
file.secret_flag AS secretFlag,
|
||||
file.file_bucket AS fileBucket,
|
||||
file.file_object_name AS fileObjectName,
|
||||
file.file_object_name AS fileObjectName,
|
||||
file.file_location AS fileLocation,
|
||||
file.file_origin_name AS fileOriginName,
|
||||
file.file_suffix AS fileSuffix,
|
||||
file.file_size_info AS fileSizeInfo,
|
||||
file.file_version AS fileVersion,
|
||||
user.real_name AS createUserName,
|
||||
user.real_name AS createUserName,
|
||||
file.create_time AS createTime,
|
||||
file.del_flag AS delFlag
|
||||
FROM sys_file_info file
|
||||
LEFT JOIN sys_user user ON user.user_id = file.create_user
|
||||
<where>
|
||||
<if test="sysFileInfoRequest.fileOriginName != null and sysFileInfoRequest.fileOriginName != '' ">
|
||||
AND file.file_origin_name LIKE CONCAT('%',#{sysFileInfoRequest.fileOriginName},'%')
|
||||
AND file.file_origin_name LIKE CONCAT('%', #{sysFileInfoRequest.fileOriginName}, '%')
|
||||
</if>
|
||||
<if test="sysFileInfoRequest.fileLocation != null and sysFileInfoRequest.fileLocation != '' ">
|
||||
AND file.file_location = #{sysFileInfoRequest.fileLocation}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!--文件列表sql oracle版本-->
|
||||
<sql id="file_list_oracle">
|
||||
SELECT fileinfo.file_id AS fileId,
|
||||
fileinfo.file_code AS fileCode,
|
||||
fileinfo.secret_flag AS secretFlag,
|
||||
fileinfo.file_bucket AS fileBucket,
|
||||
fileinfo.file_object_name AS fileObjectName,
|
||||
fileinfo.file_location AS fileLocation,
|
||||
fileinfo.file_origin_name AS fileOriginName,
|
||||
fileinfo.file_suffix AS fileSuffix,
|
||||
fileinfo.file_size_info AS fileSizeInfo,
|
||||
fileinfo.file_version AS fileVersion,
|
||||
suser.real_name AS createUserName,
|
||||
fileinfo.create_time AS createTime,
|
||||
fileinfo.del_flag AS delFlag
|
||||
FROM sys_file_info fileinfo
|
||||
LEFT JOIN sys_user suser ON suser.user_id = fileinfo.create_user
|
||||
<where>
|
||||
<if test="sysFileInfoRequest.fileOriginName != null and sysFileInfoRequest.fileOriginName != '' ">
|
||||
AND fileinfo.file_origin_name like '%' || #{sysFileInfoRequest.fileOriginName} || '%'
|
||||
</if>
|
||||
<if test="sysFileInfoRequest.fileLocation != null and sysFileInfoRequest.fileLocation != '' ">
|
||||
AND fileinfo.file_location = #{sysFileInfoRequest.fileLocation}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 附件列表 mysql版本 -->
|
||||
<select id="fileInfoList" resultType="cn.stylefeng.roses.kernel.file.api.pojo.response.SysFileInfoListResponse">
|
||||
<include refid="file_list_mysql"></include>
|
||||
</select>
|
||||
<select id="fileInfoList" resultType="cn.stylefeng.roses.kernel.file.api.pojo.response.SysFileInfoListResponse" databaseId="oracle">
|
||||
<include refid="file_list_oracle"></include>
|
||||
</select>
|
||||
|
||||
<!-- 获取所有附件信息的code集合 -->
|
||||
|
|
|
@ -168,4 +168,13 @@ public interface SysFileInfoService extends IService<SysFileInfo> {
|
|||
*/
|
||||
SysFileInfo detail(SysFileInfoRequest sysFileInfoRequest);
|
||||
|
||||
/**
|
||||
* 根据附件IDS查询附件信息
|
||||
*
|
||||
* @param fileIdList 文件ID列表
|
||||
* @author majianguo
|
||||
* @date 2020/12/27 12:57
|
||||
*/
|
||||
List<SysFileInfoResponse> getFileInfoListByFileIds(List<Long> fileIdList);
|
||||
|
||||
}
|
||||
|
|
|
@ -208,7 +208,11 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
|
|||
public PageResult<SysFileInfoListResponse> fileInfoListPage(SysFileInfoRequest sysFileInfoRequest) {
|
||||
Page<SysFileInfoListResponse> page = PageFactory.defaultPage();
|
||||
List<SysFileInfoListResponse> list = this.baseMapper.fileInfoList(page, sysFileInfoRequest);
|
||||
return PageResultFactory.createPageResult(page.setRecords(list));
|
||||
|
||||
// 排除defaultAvatar.png这个图片,这个是默认头像
|
||||
List<SysFileInfoListResponse> newList = list.stream().filter(i -> !i.getFileOriginName().equals("defaultAvatar.png")).collect(Collectors.toList());
|
||||
|
||||
return PageResultFactory.createPageResult(page.setRecords(newList));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -216,7 +220,7 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
|
|||
|
||||
// 获取文件信息
|
||||
List<Long> fileIdList = Arrays.stream(fileIds.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
|
||||
List<SysFileInfoResponse> fileInfoResponseList = this.baseMapper.getFileInfoListByFileIds(fileIdList);
|
||||
List<SysFileInfoResponse> fileInfoResponseList = this.getFileInfoListByFileIds(fileIdList);
|
||||
|
||||
// 输出流等信息
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
|
@ -260,7 +264,7 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
|
|||
@Override
|
||||
public List<SysFileInfoResponse> getFileInfoListByFileIds(String fileIds) {
|
||||
List<Long> fileIdList = Arrays.stream(fileIds.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
|
||||
return this.baseMapper.getFileInfoListByFileIds(fileIdList);
|
||||
return this.getFileInfoListByFileIds(fileIdList);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -367,6 +371,20 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
|
|||
return this.querySysFileInfo(sysFileInfoRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysFileInfoResponse> getFileInfoListByFileIds(List<Long> fileIdList) {
|
||||
LambdaQueryWrapper<SysFileInfo> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(SysFileInfo::getFileId, fileIdList);
|
||||
List<SysFileInfo> list = this.list(wrapper);
|
||||
|
||||
// bean转化
|
||||
return list.stream().map(i -> {
|
||||
SysFileInfoResponse sysFileInfoResponse = new SysFileInfoResponse();
|
||||
BeanUtil.copyProperties(i, sysFileInfoResponse);
|
||||
return sysFileInfoResponse;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysFileInfoResponse getFileInfoWithoutContent(Long fileId) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue