1. 升级 3.0.38
补全业务附件表缺失的 api 支持 api 获取附件二进制数据 新增业务附件表状态信息 补全部分存在嵌套结构的 bpm api 缺失数据
This commit is contained in:
@@ -67,4 +67,19 @@ public interface BusinessFileApi {
|
||||
CommonResult<Boolean> deleteBusinessFileByBusinessIdAndSource(@RequestParam("businessId") Long businessId,
|
||||
@RequestParam("source") String source);
|
||||
|
||||
@PutMapping(PREFIX + "/enable")
|
||||
@Operation(summary = "启用业务附件关联")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
CommonResult<Boolean> enableBusinessFile(@RequestParam("id") Long id);
|
||||
|
||||
@PutMapping(PREFIX + "/disable")
|
||||
@Operation(summary = "禁用业务附件关联")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
CommonResult<Boolean> disableBusinessFile(@RequestParam("id") Long id);
|
||||
|
||||
@PutMapping(PREFIX + "/update-status")
|
||||
@Operation(summary = "批量更新业务附件状态")
|
||||
CommonResult<Boolean> updateBusinessFileStatus(@RequestParam("ids") List<Long> ids,
|
||||
@RequestParam("status") Integer status);
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,11 @@ public class BusinessFilePageReqDTO extends PageParam implements Serializable {
|
||||
*/
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* 状态(1-正常,0-禁用)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
||||
@@ -49,6 +49,11 @@ public class BusinessFileRespDTO implements Serializable {
|
||||
*/
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* 状态(1-正常,0-禁用)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
||||
@@ -25,5 +25,7 @@ public class BusinessFileSaveReqDTO implements Serializable {
|
||||
private Long fileId;
|
||||
/** 业务来源 */
|
||||
private String source;
|
||||
/** 状态(1-正常,0-禁用) */
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,18 @@ package com.zt.plat.module.infra.api.file;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.module.infra.api.file.dto.FileCreateReqDTO;
|
||||
import com.zt.plat.module.infra.api.file.dto.FileRespDTO;
|
||||
import com.zt.plat.module.infra.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - 文件")
|
||||
@@ -17,43 +21,19 @@ public interface FileApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/file";
|
||||
|
||||
/**
|
||||
* 保存文件,并返回文件的访问路径
|
||||
*
|
||||
* @param content 文件内容
|
||||
* @return 文件路径
|
||||
*/
|
||||
default String createFile(byte[] content) {
|
||||
return createFile(content, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存文件,并返回文件的访问路径
|
||||
*
|
||||
* @param content 文件内容
|
||||
* @param name 文件名称,允许空
|
||||
* @return 文件路径
|
||||
*/
|
||||
default String createFile(byte[] content, String name) {
|
||||
return createFile(content, name, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存文件,并返回文件的访问路径
|
||||
*
|
||||
* @param content 文件内容
|
||||
* @param name 文件名称,允许空
|
||||
* @param directory 目录,允许空
|
||||
* @param type 文件的 MIME 类型,允许空
|
||||
* @return 文件路径
|
||||
*/
|
||||
default String createFile(@NotEmpty(message = "文件内容不能为空") byte[] content,
|
||||
String name, String directory, String type) {
|
||||
return createFile(new FileCreateReqDTO().setName(name).setDirectory(directory).setType(type).setContent(content)).getCheckedData();
|
||||
}
|
||||
|
||||
@PostMapping(PREFIX + "/create")
|
||||
@Operation(summary = "保存文件,并返回文件的访问路径")
|
||||
CommonResult<String> createFile(@Valid @RequestBody FileCreateReqDTO createReqDTO);
|
||||
|
||||
/**
|
||||
* 根据文件编号获取文件信息和二进制内容
|
||||
*
|
||||
* @param fileId 文件编号
|
||||
* @return 文件信息,包含二进制数据
|
||||
*/
|
||||
@GetMapping(PREFIX + "/get")
|
||||
@Operation(summary = "根据文件编号获取文件信息和二进制内容")
|
||||
CommonResult<FileRespDTO> getFile(@Parameter(description = "文件编号", required = true, example = "1024")
|
||||
@RequestParam("fileId") @NotNull(message = "文件编号不能为空") Long fileId);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.zt.plat.module.infra.api.file.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "RPC 服务 - 文件信息 Response DTO")
|
||||
@Data
|
||||
public class FileRespDTO {
|
||||
|
||||
@Schema(description = "文件编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "原文件名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "xxx.png")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "文件目录", example = "xxx")
|
||||
private String directory;
|
||||
|
||||
@Schema(description = "文件的 MIME 类型", example = "image/png")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "文件大小", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer size;
|
||||
|
||||
@Schema(description = "文件内容", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private byte[] content;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.zt.plat.module.infra.enums.businessfile;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 业务附件状态枚举
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum BusinessFileStatusEnum {
|
||||
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
NORMAL(1, "正常"),
|
||||
/**
|
||||
* 禁用
|
||||
*/
|
||||
DISABLED(0, "禁用");
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private final Integer status;
|
||||
/**
|
||||
* 状态名
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
}
|
||||
@@ -84,4 +84,22 @@ public class BusinessFileApiImpl implements BusinessFileApi {
|
||||
businessFileService.deleteBusinessFileByBusinessIdAndSource(businessId, source);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> enableBusinessFile(Long id) {
|
||||
businessFileService.enableBusinessFile(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> disableBusinessFile(Long id) {
|
||||
businessFileService.disableBusinessFile(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateBusinessFileStatus(List<Long> ids, Integer status) {
|
||||
businessFileService.updateBusinessFileStatus(ids, status);
|
||||
return success(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.zt.plat.module.infra.api.file;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.module.infra.api.file.dto.FileCreateReqDTO;
|
||||
import com.zt.plat.module.infra.api.file.dto.FileRespDTO;
|
||||
import com.zt.plat.module.infra.dal.dataobject.file.FileDO;
|
||||
import com.zt.plat.module.infra.service.file.FileService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -22,4 +24,40 @@ public class FileApiImpl implements FileApi {
|
||||
createReqDTO.getDirectory(), createReqDTO.getType(), false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<FileRespDTO> getFile(Long fileId) {
|
||||
try {
|
||||
// 获取文件信息
|
||||
FileDO fileDO = fileService.getActiveFileById(fileId);
|
||||
if (fileDO == null) {
|
||||
return CommonResult.error(404, "文件不存在");
|
||||
}
|
||||
|
||||
// 获取文件内容
|
||||
byte[] content = fileService.getFileContent(fileId);
|
||||
if (content == null) {
|
||||
return CommonResult.error(500, "文件内容读取失败");
|
||||
}
|
||||
|
||||
// 构建响应对象
|
||||
FileRespDTO respDTO = new FileRespDTO();
|
||||
respDTO.setId(fileDO.getId());
|
||||
respDTO.setName(fileDO.getName());
|
||||
respDTO.setType(fileDO.getType());
|
||||
respDTO.setSize(fileDO.getSize());
|
||||
respDTO.setContent(content);
|
||||
|
||||
// 从文件路径或URL中提取目录信息
|
||||
String path = fileDO.getPath();
|
||||
if (path != null && path.contains("/")) {
|
||||
String directory = path.substring(0, path.lastIndexOf("/"));
|
||||
respDTO.setDirectory(directory);
|
||||
}
|
||||
|
||||
return success(respDTO);
|
||||
} catch (Exception e) {
|
||||
return CommonResult.error(500, "获取文件失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -129,4 +129,31 @@ public class BusinessFileController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/enable")
|
||||
@Operation(summary = "启用业务附件关联")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:business-file:update')")
|
||||
public CommonResult<Boolean> enableBusinessFile(@RequestParam("id") Long id) {
|
||||
businessFileService.enableBusinessFile(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/disable")
|
||||
@Operation(summary = "禁用业务附件关联")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:business-file:update')")
|
||||
public CommonResult<Boolean> disableBusinessFile(@RequestParam("id") Long id) {
|
||||
businessFileService.disableBusinessFile(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/update-status")
|
||||
@Operation(summary = "批量更新业务附件状态")
|
||||
@PreAuthorize("@ss.hasPermission('infra:business-file:update')")
|
||||
public CommonResult<Boolean> updateBusinessFileStatus(@RequestParam("ids") List<Long> ids,
|
||||
@RequestParam("status") Integer status) {
|
||||
businessFileService.updateBusinessFileStatus(ids, status);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,6 +28,9 @@ public class BusinessFilePageReqVO extends PageParam {
|
||||
@Schema(description = "附件来源")
|
||||
private String source;
|
||||
|
||||
@Schema(description = "状态(1-正常,0-禁用)", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@@ -36,6 +36,10 @@ public class BusinessFileRespVO {
|
||||
@ExcelProperty("附件来源")
|
||||
private String source;
|
||||
|
||||
@Schema(description = "状态(1-正常,0-禁用)", example = "1")
|
||||
@ExcelProperty("状态")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
@@ -43,7 +47,4 @@ public class BusinessFileRespVO {
|
||||
@Schema(description = "创建人", example = "1024")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "创建人名称", example = "张三")
|
||||
private String creatorName;
|
||||
|
||||
}
|
||||
@@ -25,4 +25,7 @@ public class BusinessFileSaveReqVO {
|
||||
@Schema(description = "附件来源")
|
||||
private String source;
|
||||
|
||||
@Schema(description = "状态(1-正常,0-禁用)", example = "1")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@@ -48,6 +48,11 @@ public class BusinessFileDO extends BaseDO {
|
||||
*/
|
||||
@TableField("SRC")
|
||||
private String source;
|
||||
/**
|
||||
* 状态(1-正常,0-禁用)
|
||||
*/
|
||||
@TableField("STATUS")
|
||||
private Integer status;
|
||||
|
||||
|
||||
}
|
||||
@@ -24,6 +24,7 @@ public interface BusinessFileMapper extends BaseMapperX<BusinessFileDO> {
|
||||
.eqIfPresent(BusinessFileDO::getFileId, reqVO.getFileId())
|
||||
.likeIfPresent(BusinessFileDO::getFileName, reqVO.getFileName())
|
||||
.eqIfPresent(BusinessFileDO::getSource, reqVO.getSource())
|
||||
.eqIfPresent(BusinessFileDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(BusinessFileDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(BusinessFileDO::getId));
|
||||
}
|
||||
|
||||
@@ -72,4 +72,27 @@ public interface BusinessFileService {
|
||||
* @param source 业务来源
|
||||
*/
|
||||
void deleteBusinessFileByBusinessIdAndSource(Long businessId, String source);
|
||||
|
||||
/**
|
||||
* 启用业务附件关联
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void enableBusinessFile(Long id);
|
||||
|
||||
/**
|
||||
* 禁用业务附件关联
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void disableBusinessFile(Long id);
|
||||
|
||||
/**
|
||||
* 批量更新业务附件状态
|
||||
*
|
||||
* @param ids 编号列表
|
||||
* @param status 状态
|
||||
*/
|
||||
void updateBusinessFileStatus(List<Long> ids, Integer status);
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import com.zt.plat.module.infra.controller.admin.businessfile.vo.BusinessFileWit
|
||||
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.mysql.businessfile.BusinessFileMapper;
|
||||
import com.zt.plat.module.infra.enums.businessfile.BusinessFileStatusEnum;
|
||||
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;
|
||||
@@ -46,6 +47,10 @@ public class BusinessFileServiceImpl implements BusinessFileService {
|
||||
public Long createBusinessFile(BusinessFileSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
BusinessFileDO businessFile = BeanUtils.toBean(createReqVO, BusinessFileDO.class);
|
||||
// 设置默认状态为正常
|
||||
if (businessFile.getStatus() == null) {
|
||||
businessFile.setStatus(BusinessFileStatusEnum.NORMAL.getStatus());
|
||||
}
|
||||
businessFileMapper.insert(businessFile);
|
||||
// 返回
|
||||
return businessFile.getId();
|
||||
@@ -167,6 +172,10 @@ public class BusinessFileServiceImpl implements BusinessFileService {
|
||||
List<BusinessFileDO> businessFileList = BeanUtils.toBean(createReqVOList, BusinessFileDO.class);
|
||||
List<Long> ids = new ArrayList<>();
|
||||
for (BusinessFileDO businessFile : businessFileList) {
|
||||
// 设置默认状态为正常
|
||||
if (businessFile.getStatus() == null) {
|
||||
businessFile.setStatus(BusinessFileStatusEnum.NORMAL.getStatus());
|
||||
}
|
||||
businessFileMapper.insert(businessFile);
|
||||
ids.add(businessFile.getId());
|
||||
}
|
||||
@@ -179,4 +188,39 @@ public class BusinessFileServiceImpl implements BusinessFileService {
|
||||
.eq(BusinessFileDO::getBusinessId, businessId)
|
||||
.eq(BusinessFileDO::getSource, source));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableBusinessFile(Long id) {
|
||||
// 校验存在
|
||||
validateBusinessFileExists(id);
|
||||
// 更新状态为正常
|
||||
BusinessFileDO updateObj = new BusinessFileDO();
|
||||
updateObj.setId(id);
|
||||
updateObj.setStatus(BusinessFileStatusEnum.NORMAL.getStatus());
|
||||
businessFileMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableBusinessFile(Long id) {
|
||||
// 校验存在
|
||||
validateBusinessFileExists(id);
|
||||
// 更新状态为禁用
|
||||
BusinessFileDO updateObj = new BusinessFileDO();
|
||||
updateObj.setId(id);
|
||||
updateObj.setStatus(BusinessFileStatusEnum.DISABLED.getStatus());
|
||||
businessFileMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBusinessFileStatus(List<Long> ids, Integer status) {
|
||||
// 校验存在
|
||||
validateBusinessFileExists(ids);
|
||||
// 批量更新状态
|
||||
for (Long id : ids) {
|
||||
BusinessFileDO updateObj = new BusinessFileDO();
|
||||
updateObj.setId(id);
|
||||
updateObj.setStatus(status);
|
||||
businessFileMapper.updateById(updateObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user