Merge remote-tracking branch 'base-version/main' into dev
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -46,4 +46,14 @@ public class BusinessFileWithUrlRespDTO extends BusinessFileRespDTO {
|
|||||||
*/
|
*/
|
||||||
private Integer fileSize;
|
private Integer fileSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
private String creator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人名称
|
||||||
|
*/
|
||||||
|
private String creatorName;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -40,4 +40,10 @@ public class BusinessFileRespVO {
|
|||||||
@ExcelProperty("创建时间")
|
@ExcelProperty("创建时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "创建人", example = "1024")
|
||||||
|
private String creator;
|
||||||
|
|
||||||
|
@Schema(description = "创建人名称", example = "张三")
|
||||||
|
private String creatorName;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -42,6 +42,9 @@ public class BusinessFileWithUrlRespVO extends BusinessFileRespVO {
|
|||||||
@Schema(description = "文件大小", example = "2048")
|
@Schema(description = "文件大小", example = "2048")
|
||||||
private Integer fileSize;
|
private Integer fileSize;
|
||||||
|
|
||||||
|
@Schema(description = "创建人名称", example = "张三")
|
||||||
|
private String creatorName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件 URL(参考 FileRespVO 的实现)
|
* 获取文件 URL(参考 FileRespVO 的实现)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,14 +3,18 @@ package com.zt.plat.module.infra.service.businessfile;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
|
import com.zt.plat.framework.common.util.user.UserNameEnrichUtils;
|
||||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.zt.plat.module.infra.controller.admin.businessfile.vo.BusinessFilePageReqVO;
|
import com.zt.plat.module.infra.controller.admin.businessfile.vo.BusinessFilePageReqVO;
|
||||||
|
import com.zt.plat.module.infra.controller.admin.businessfile.vo.BusinessFileRespVO;
|
||||||
import com.zt.plat.module.infra.controller.admin.businessfile.vo.BusinessFileSaveReqVO;
|
import com.zt.plat.module.infra.controller.admin.businessfile.vo.BusinessFileSaveReqVO;
|
||||||
import com.zt.plat.module.infra.controller.admin.businessfile.vo.BusinessFileWithUrlRespVO;
|
import com.zt.plat.module.infra.controller.admin.businessfile.vo.BusinessFileWithUrlRespVO;
|
||||||
import com.zt.plat.module.infra.dal.dataobject.businessfile.BusinessFileDO;
|
import com.zt.plat.module.infra.dal.dataobject.businessfile.BusinessFileDO;
|
||||||
import com.zt.plat.module.infra.dal.dataobject.file.FileDO;
|
import com.zt.plat.module.infra.dal.dataobject.file.FileDO;
|
||||||
import com.zt.plat.module.infra.dal.mysql.businessfile.BusinessFileMapper;
|
import com.zt.plat.module.infra.dal.mysql.businessfile.BusinessFileMapper;
|
||||||
import com.zt.plat.module.infra.service.file.FileService;
|
import com.zt.plat.module.infra.service.file.FileService;
|
||||||
|
import com.zt.plat.module.system.api.user.AdminUserApi;
|
||||||
|
import com.zt.plat.module.system.api.user.dto.AdminUserRespDTO;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -35,6 +39,9 @@ public class BusinessFileServiceImpl implements BusinessFileService {
|
|||||||
@Resource
|
@Resource
|
||||||
private FileService fileService;
|
private FileService fileService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AdminUserApi adminUserApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createBusinessFile(BusinessFileSaveReqVO createReqVO) {
|
public Long createBusinessFile(BusinessFileSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
@@ -97,13 +104,40 @@ public class BusinessFileServiceImpl implements BusinessFileService {
|
|||||||
PageResult<BusinessFileDO> pageResult = getBusinessFilePage(pageReqVO);
|
PageResult<BusinessFileDO> pageResult = getBusinessFilePage(pageReqVO);
|
||||||
PageResult<BusinessFileWithUrlRespVO> result = BeanUtils.toBean(pageResult, BusinessFileWithUrlRespVO.class);
|
PageResult<BusinessFileWithUrlRespVO> result = BeanUtils.toBean(pageResult, BusinessFileWithUrlRespVO.class);
|
||||||
|
|
||||||
// 批量获取文件信息并设置URL
|
if (CollUtil.isEmpty(result.getList())) {
|
||||||
List<Long> fileIds = result.getList().stream()
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量设置文件信息
|
||||||
|
setFileInfo(result.getList());
|
||||||
|
|
||||||
|
// 批量设置创建人名称
|
||||||
|
UserNameEnrichUtils.setCreatorNames(result.getList(),
|
||||||
|
BusinessFileRespVO::getCreator,
|
||||||
|
BusinessFileWithUrlRespVO::setCreatorName,
|
||||||
|
UserNameEnrichUtils.createUserNicknameProvider(
|
||||||
|
userIds -> adminUserApi.getUserMap(userIds),
|
||||||
|
AdminUserRespDTO::getNickname
|
||||||
|
));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量设置文件信息
|
||||||
|
*/
|
||||||
|
private void setFileInfo(List<BusinessFileWithUrlRespVO> voList) {
|
||||||
|
// 批量获取文件信息
|
||||||
|
List<Long> fileIds = voList.stream()
|
||||||
.map(BusinessFileWithUrlRespVO::getFileId)
|
.map(BusinessFileWithUrlRespVO::getFileId)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.distinct()
|
.distinct()
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
|
if (fileIds.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 批量查询文件信息
|
// 批量查询文件信息
|
||||||
Map<Long, FileDO> fileMap = new HashMap<>();
|
Map<Long, FileDO> fileMap = new HashMap<>();
|
||||||
for (Long fileId : fileIds) {
|
for (Long fileId : fileIds) {
|
||||||
@@ -114,7 +148,7 @@ public class BusinessFileServiceImpl implements BusinessFileService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设置文件相关信息
|
// 设置文件相关信息
|
||||||
for (BusinessFileWithUrlRespVO vo : result.getList()) {
|
voList.forEach(vo -> {
|
||||||
if (vo.getFileId() != null) {
|
if (vo.getFileId() != null) {
|
||||||
FileDO fileDO = fileMap.get(vo.getFileId());
|
FileDO fileDO = fileMap.get(vo.getFileId());
|
||||||
if (fileDO != null) {
|
if (fileDO != null) {
|
||||||
@@ -125,8 +159,7 @@ public class BusinessFileServiceImpl implements BusinessFileService {
|
|||||||
vo.setFileSize(fileDO.getSize());
|
vo.setFileSize(fileDO.getSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user