mirror of https://gitee.com/stylefeng/roses
【8.0】【file】更新查询文件列表
parent
ae39ce3777
commit
71a37d8df3
|
@ -29,7 +29,6 @@ import cn.stylefeng.roses.kernel.file.api.FileInfoApi;
|
|||
import cn.stylefeng.roses.kernel.file.api.constants.FileConstants;
|
||||
import cn.stylefeng.roses.kernel.file.api.pojo.AntdvFileInfo;
|
||||
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 cn.stylefeng.roses.kernel.file.modular.service.SysFileInfoService;
|
||||
|
@ -265,7 +264,7 @@ public class SysFileInfoController {
|
|||
* @since 2020/11/29 11:29
|
||||
*/
|
||||
@GetResource(name = "分页查询文件信息表", path = "/sysFileInfo/fileInfoListPage")
|
||||
public ResponseData<PageResult<SysFileInfoListResponse>> fileInfoListPage(SysFileInfoRequest sysFileInfoRequest) {
|
||||
public ResponseData<PageResult<SysFileInfo>> fileInfoListPage(SysFileInfoRequest sysFileInfoRequest) {
|
||||
return new SuccessResponseData<>(this.sysFileInfoService.fileInfoListPage(sysFileInfoRequest));
|
||||
}
|
||||
|
||||
|
|
|
@ -144,4 +144,15 @@ public class SysFileInfo extends BaseEntity {
|
|||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
//-------------------------------非实体字段-------------------------------
|
||||
//-------------------------------非实体字段-------------------------------
|
||||
//-------------------------------非实体字段-------------------------------
|
||||
|
||||
/**
|
||||
* 文件访问的url
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@ChineseDescription("文件访问的url")
|
||||
private String fileUrl;
|
||||
|
||||
}
|
||||
|
|
|
@ -24,14 +24,8 @@
|
|||
*/
|
||||
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.modular.entity.SysFileInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -43,12 +37,4 @@ import java.util.List;
|
|||
*/
|
||||
public interface SysFileInfoMapper extends BaseMapper<SysFileInfo> {
|
||||
|
||||
/**
|
||||
* 附件列表(有分页)
|
||||
*
|
||||
* @author majianguo
|
||||
* @since 2020/12/27 12:57
|
||||
*/
|
||||
List<SysFileInfoListResponse> fileInfoList(@Param("page") Page<SysFileInfoListResponse> page, @Param("sysFileInfoRequest") SysFileInfoRequest sysFileInfoRequest);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,68 +2,4 @@
|
|||
<!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">
|
||||
|
||||
<!--文件列表sql-->
|
||||
<sql id="file_list_mysql">
|
||||
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 CONCAT('%', #{sysFileInfoRequest.fileOriginName}, '%')
|
||||
</if>
|
||||
<if test="sysFileInfoRequest.fileLocation != null and sysFileInfoRequest.fileLocation != '' ">
|
||||
AND fileinfo.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版本、pgsql、sqlserver -->
|
||||
<select id="fileInfoList" resultType="cn.stylefeng.roses.kernel.file.api.pojo.response.SysFileInfoListResponse">
|
||||
<include refid="file_list_mysql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 附件列表 oracle -->
|
||||
<select id="fileInfoList" resultType="cn.stylefeng.roses.kernel.file.api.pojo.response.SysFileInfoListResponse" databaseId="oracle">
|
||||
<include refid="file_list_oracle"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -27,7 +27,6 @@ package cn.stylefeng.roses.kernel.file.modular.service;
|
|||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.file.api.FileInfoApi;
|
||||
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.extension.service.IService;
|
||||
|
@ -93,7 +92,7 @@ public interface SysFileInfoService extends IService<SysFileInfo>, FileInfoApi {
|
|||
* @author fengshuonan
|
||||
* @since 2020/11/29 14:09
|
||||
*/
|
||||
PageResult<SysFileInfoListResponse> fileInfoListPage(SysFileInfoRequest sysFileInfoRequest);
|
||||
PageResult<SysFileInfo> fileInfoListPage(SysFileInfoRequest sysFileInfoRequest);
|
||||
|
||||
/**
|
||||
* 打包下载文件
|
||||
|
|
|
@ -33,6 +33,7 @@ import cn.hutool.core.util.StrUtil;
|
|||
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.file.api.FileOperatorApi;
|
||||
import cn.stylefeng.roses.kernel.file.api.constants.FileConstants;
|
||||
|
@ -43,7 +44,6 @@ import cn.stylefeng.roses.kernel.file.api.exception.enums.FileExceptionEnum;
|
|||
import cn.stylefeng.roses.kernel.file.api.expander.FileConfigExpander;
|
||||
import cn.stylefeng.roses.kernel.file.api.pojo.AntdvFileInfo;
|
||||
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.api.util.DownloadUtil;
|
||||
import cn.stylefeng.roses.kernel.file.api.util.PdfFileTypeUtil;
|
||||
|
@ -250,19 +250,36 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
|
|||
}
|
||||
|
||||
@Override
|
||||
public PageResult<SysFileInfoListResponse> fileInfoListPage(SysFileInfoRequest sysFileInfoRequest) {
|
||||
Page<SysFileInfoListResponse> page = PageFactory.defaultPage();
|
||||
List<SysFileInfoListResponse> list = this.baseMapper.fileInfoList(page, sysFileInfoRequest);
|
||||
public PageResult<SysFileInfo> fileInfoListPage(SysFileInfoRequest sysFileInfoRequest) {
|
||||
|
||||
LambdaQueryWrapper<SysFileInfo> fileWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 根据文件名进行查询
|
||||
if (ObjectUtil.isNotEmpty(sysFileInfoRequest.getFileOriginName())) {
|
||||
fileWrapper.like(SysFileInfo::getFileOriginName, sysFileInfoRequest.getFileOriginName());
|
||||
}
|
||||
// 根据文件存储路径进行查询
|
||||
if (ObjectUtil.isNotEmpty(sysFileInfoRequest.getFileLocation())) {
|
||||
fileWrapper.eq(SysFileInfo::getFileLocation, sysFileInfoRequest.getFileLocation());
|
||||
}
|
||||
|
||||
// 查询必要字段
|
||||
fileWrapper.select(SysFileInfo::getFileId, SysFileInfo::getFileCode, SysFileInfo::getSecretFlag, SysFileInfo::getFileBucket,
|
||||
SysFileInfo::getFileObjectName, SysFileInfo::getFileLocation, SysFileInfo::getFileOriginName, SysFileInfo::getFileSuffix,
|
||||
SysFileInfo::getFileSizeInfo, SysFileInfo::getFileVersion, BaseEntity::getCreateTime);
|
||||
|
||||
Page<SysFileInfo> page = this.page(PageFactory.defaultPage(), fileWrapper);
|
||||
List<SysFileInfo> records = page.getRecords();
|
||||
|
||||
// 排除defaultAvatar.png这个图片,这个是默认头像
|
||||
List<SysFileInfoListResponse> newList = list.stream()
|
||||
List<SysFileInfo> newList = records.stream()
|
||||
.filter(i -> !i.getFileOriginName().equals(FileConstants.DEFAULT_AVATAR_FILE_OBJ_NAME)).collect(Collectors.toList());
|
||||
|
||||
// 拼接图片url地址
|
||||
for (SysFileInfoListResponse sysFileInfoListResponse : newList) {
|
||||
for (SysFileInfo sysFileInfo : newList) {
|
||||
// 判断是否是可以预览的文件
|
||||
if (PicFileTypeUtil.getFileImgTypeFlag(sysFileInfoListResponse.getFileSuffix())) {
|
||||
sysFileInfoListResponse.setFileUrl(this.getFileAuthUrl(sysFileInfoListResponse.getFileId()));
|
||||
if (PicFileTypeUtil.getFileImgTypeFlag(sysFileInfo.getFileSuffix())) {
|
||||
sysFileInfo.setFileUrl(this.getFileAuthUrl(sysFileInfo.getFileId()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -582,7 +599,7 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
|
|||
*/
|
||||
private SysFileInfo querySysFileInfo(SysFileInfoRequest sysFileInfoRequest) {
|
||||
SysFileInfo sysFileInfo = this.getById(sysFileInfoRequest.getFileId());
|
||||
if (ObjectUtil.isEmpty(sysFileInfo) || sysFileInfo.getDelFlag().equals(YesOrNotEnum.Y.getCode())) {
|
||||
if (ObjectUtil.isEmpty(sysFileInfo)) {
|
||||
throw new FileException(FileExceptionEnum.NOT_EXISTED, sysFileInfoRequest.getFileId());
|
||||
}
|
||||
return sysFileInfo;
|
||||
|
|
Loading…
Reference in New Issue