1. 升级 3.0.38

补全业务附件表缺失的 api
 支持 api 获取附件二进制数据
 新增业务附件表状态信息
 补全部分存在嵌套结构的 bpm api 缺失数据
This commit is contained in:
chenbowen
2025-09-25 19:24:06 +08:00
parent 70c8d0d5f7
commit ea04d0dee6
28 changed files with 518 additions and 67 deletions

View File

@@ -32,7 +32,7 @@
<url>https://github.com/YunaiV/ruoyi-vue-pro</url>
<properties>
<revision>3.0.35</revision>
<revision>3.0.38</revision>
<!-- Maven 相关 -->
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
@@ -254,8 +254,8 @@
<id>env-local</id>
<properties>
<env.name>local</env.name>
<config.server-addr>localhost:8848</config.server-addr>
<!-- <config.server-addr>172.16.46.63:30848</config.server-addr>-->
<!-- <config.server-addr>localhost:8848</config.server-addr>-->
<config.server-addr>172.16.46.63:30848</config.server-addr>
<config.namespace>local</config.namespace>
<config.group>DEFAULT_GROUP</config.group>
<config.username/>

View File

@@ -16,6 +16,7 @@ CREATE TABLE infra_bsn_file (
file_id bigint NOT NULL,
file_name varchar(500) DEFAULT '' NULL,
src varchar(100) DEFAULT '' NULL,
status smallint DEFAULT 1 NOT NULL,
creator varchar(64) DEFAULT '' NULL,
create_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
updater varchar(64) DEFAULT '' NULL,
@@ -30,6 +31,7 @@ COMMENT ON COLUMN infra_bsn_file.bsn_cd IS '业务编码';
COMMENT ON COLUMN infra_bsn_file.file_id IS '附件fileId';
COMMENT ON COLUMN infra_bsn_file.file_name IS '附件名称';
COMMENT ON COLUMN infra_bsn_file.src IS '附件来源';
COMMENT ON COLUMN infra_bsn_file.status IS '状态1-正常0-禁用)';
COMMENT ON COLUMN infra_bsn_file.creator IS '创建者';
COMMENT ON COLUMN infra_bsn_file.create_time IS '创建时间';
COMMENT ON COLUMN infra_bsn_file.updater IS '更新者';

View File

@@ -0,0 +1,3 @@
-- 为业务附件关联表添加状态字段 (达梦数据库)
ALTER TABLE infra_bsn_file ADD COLUMN status SMALLINT DEFAULT 1 NOT NULL;
COMMENT ON COLUMN infra_bsn_file.status IS '状态1-正常0-禁用)';

View File

@@ -3,6 +3,7 @@ package com.zt.plat.framework.business.filter;
import com.zt.plat.framework.common.util.spring.SpringUtils;
import com.zt.plat.module.infra.api.businessfile.BusinessFileApi;
import com.zt.plat.module.infra.api.businessfile.dto.BusinessFileSaveReqDTO;
import com.zt.plat.module.infra.enums.businessfile.BusinessFileStatusEnum;
import com.esotericsoftware.minlog.Log;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -139,6 +140,7 @@ public class FileUploadFilter implements Filter {
createReqDTO.setFileId(Long.parseLong(fileId));
createReqDTO.setFileName(fileName);
createReqDTO.setSource(businessSource);
createReqDTO.setStatus(BusinessFileStatusEnum.NORMAL.getStatus()); // 设置默认状态为正常
reqDTOList.add(createReqDTO);
}
}

View File

@@ -1,5 +1,6 @@
package com.zt.plat.module.bpm.api.task.dto;
import com.zt.plat.framework.common.core.KeyValue;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -47,13 +48,86 @@ public class BpmTaskRespDTO {
@Schema(description = "表单编号", example = "1024")
private Long formId;
@Schema(description = "表单路径", example = "/form/leave")
private String formPath;
@Schema(description = "表单名字", example = "请假表单")
private String formName;
@Schema(description = "表单的配置", example = "[]")
private String formConf;
@Schema(description = "表单项的数组", example = "[]")
private String formFields;
private List<String> formFields;
@Schema(description = "提交的表单值", example = "{\"name\": \"芋艿\"}")
private Map<String, Object> formVariables;
@Schema(description = "任务负责人编号", example = "2048")
private Long owner;
@Schema(description = "负责人的用户信息")
private UserSimpleDTO ownerUser;
@Schema(description = "任务分配人编号", example = "2048")
private Long assignee;
@Schema(description = "审核的用户信息")
private UserSimpleDTO assigneeUser;
@Schema(description = "父任务编号", example = "1024")
private String parentTaskId;
@Schema(description = "子任务列表(由加签生成)")
private List<BpmTaskRespDTO> children;
@Schema(description = "所属流程实例")
private ProcessInstanceDTO processInstance;
@Schema(description = "操作按钮设置值")
private Map<Integer, OperationButtonSettingDTO> buttonsSetting;
@Schema(description = "是否需要签名", example = "false")
private Boolean signEnable;
@Schema(description = "是否填写审批意见", example = "false")
private Boolean reasonRequire;
@Schema(description = "节点类型", example = "10")
private Integer nodeType;
@Data
@Schema(description = "流程实例信息")
public static class ProcessInstanceDTO {
@Schema(description = "流程实例编号", example = "1024")
private String id;
@Schema(description = "流程实例名称", example = "芋道")
private String name;
@Schema(description = "提交时间")
private LocalDateTime createTime;
@Schema(description = "流程定义的编号", example = "2048")
private String processDefinitionId;
@Schema(description = "流程摘要", example = "[]")
private List<KeyValue<String, String>> summary;
@Schema(description = "发起人的用户信息")
private UserSimpleDTO startUser;
}
@Data
@Schema(description = "操作按钮设置")
public static class OperationButtonSettingDTO {
@Schema(description = "显示名称", example = "审批")
private String displayName;
@Schema(description = "是否启用", example = "true")
private Boolean enable;
}
}

View File

@@ -0,0 +1,25 @@
package com.zt.plat.module.bpm.api.task.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "RPC 服务 - 用户精简信息 DTO")
@Data
public class UserSimpleDTO {
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long id;
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
private String nickname;
@Schema(description = "用户头像", example = "https://www.iocoder.cn/1.png")
private String avatar;
@Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long deptId;
@Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "研发部")
private String deptName;
}

View File

@@ -75,9 +75,11 @@ public class BpmTaskApiImpl implements BpmTaskApi {
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId())));
Map<String, BpmProcessDefinitionInfoDO> processDefinitionInfoMap = processDefinitionService.getProcessDefinitionInfoMap(convertSet(pageResult.getList(), Task::getProcessDefinitionId));
// 使用转换器构建结果并转换为 DTO
// 使用转换器构建完整的 VO 结果,然后转换为 DTO
var voPageResult = BpmTaskConvert.INSTANCE.buildTodoTaskPage(pageResult, processInstanceMap, userMap, processDefinitionInfoMap);
return success(BeanUtils.toBean(voPageResult.getList(), BpmTaskRespDTO.class));
List<BpmTaskRespDTO> result = BpmTaskConvert.INSTANCE.buildTaskRespDTOList(voPageResult.getList());
return success(result);
}
@Override
@@ -96,9 +98,11 @@ public class BpmTaskApiImpl implements BpmTaskApi {
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId())));
Map<String, BpmProcessDefinitionInfoDO> processDefinitionInfoMap = processDefinitionService.getProcessDefinitionInfoMap(convertSet(pageResult.getList(), HistoricTaskInstance::getProcessDefinitionId));
// 使用转换器构建结果并转换为 DTO
// 使用转换器构建完整的 VO 结果,然后转换为 DTO
var voPageResult = BpmTaskConvert.INSTANCE.buildTaskPage(pageResult, processInstanceMap, userMap, null, processDefinitionInfoMap);
return success(BeanUtils.toBean(voPageResult.getList(), BpmTaskRespDTO.class));
List<BpmTaskRespDTO> result = BpmTaskConvert.INSTANCE.buildTaskRespDTOList(voPageResult.getList());
return success(result);
}
@Override
@@ -121,9 +125,11 @@ public class BpmTaskApiImpl implements BpmTaskApi {
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), DeptUtil::getDeptId));
Map<String, BpmProcessDefinitionInfoDO> processDefinitionInfoMap = processDefinitionService.getProcessDefinitionInfoMap(convertSet(pageResult.getList(), HistoricTaskInstance::getProcessDefinitionId));
// 使用转换器构建结果并转换为 DTO
// 使用转换器构建完整的 VO 结果,然后转换为 DTO
var voPageResult = BpmTaskConvert.INSTANCE.buildTaskPage(pageResult, processInstanceMap, userMap, deptMap, processDefinitionInfoMap);
return success(BeanUtils.toBean(voPageResult.getList(), BpmTaskRespDTO.class));
List<BpmTaskRespDTO> result = BpmTaskConvert.INSTANCE.buildTaskRespDTOList(voPageResult.getList());
return success(result);
}
@Override
@@ -152,9 +158,9 @@ public class BpmTaskApiImpl implements BpmTaskApi {
}
}));
// 使用转换器构建结果并转换为 DTO
// 使用转换器构建完整的 VO 结果,然后转换为 DTO
var voList = BpmTaskConvert.INSTANCE.buildTaskListByProcessInstanceId(taskList, formMap, userMap, deptMap);
List<BpmTaskRespDTO> result = BeanUtils.toBean(voList, BpmTaskRespDTO.class);
List<BpmTaskRespDTO> result = BpmTaskConvert.INSTANCE.buildTaskRespDTOList(voList);
return success(result);
}
@@ -187,9 +193,9 @@ public class BpmTaskApiImpl implements BpmTaskApi {
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSetByFlatMap(taskList, user -> Stream.of(NumberUtils.parseLong(user.getAssignee()), NumberUtils.parseLong(user.getOwner()))));
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), DeptUtil::getDeptId));
// 使用转换器构建结果并转换为 DTO
// 使用转换器构建完整的 VO 结果,然后转换为 DTO
var voList = BpmTaskConvert.INSTANCE.buildTaskListByParentTaskId(taskList, userMap, deptMap);
List<BpmTaskRespDTO> result = BeanUtils.toBean(voList, BpmTaskRespDTO.class);
List<BpmTaskRespDTO> result = BpmTaskConvert.INSTANCE.buildTaskRespDTOList(voList);
return success(result);
}

View File

@@ -8,6 +8,8 @@ import com.zt.plat.framework.common.util.collection.CollectionUtils;
import com.zt.plat.framework.common.util.date.DateUtils;
import com.zt.plat.framework.common.util.number.NumberUtils;
import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.module.bpm.api.task.dto.BpmTaskRespDTO;
import com.zt.plat.module.bpm.api.task.dto.UserSimpleDTO;
import com.zt.plat.module.bpm.controller.admin.base.user.UserSimpleBaseVO;
import com.zt.plat.module.bpm.controller.admin.task.vo.task.BpmTaskRespVO;
import com.zt.plat.module.bpm.dal.dataobject.definition.BpmFormDO;
@@ -230,4 +232,85 @@ public interface BpmTaskConvert {
childTask.setTenantId(parentTask.getTenantId());
}
/**
* 将 BpmTaskRespVO 转换为 BpmTaskRespDTO保持完整的嵌套结构
*/
default List<BpmTaskRespDTO> buildTaskRespDTOList(List<BpmTaskRespVO> voList) {
return CollectionUtils.convertList(voList, this::buildTaskRespDTO);
}
/**
* 将 BpmTaskRespVO 转换为 BpmTaskRespDTO保持完整的嵌套结构
*/
default BpmTaskRespDTO buildTaskRespDTO(BpmTaskRespVO vo) {
if (vo == null) {
return null;
}
BpmTaskRespDTO dto = BeanUtils.toBean(vo, BpmTaskRespDTO.class);
// 转换用户信息
if (vo.getAssigneeUser() != null) {
dto.setAssigneeUser(convertToUserSimpleDTO(vo.getAssigneeUser()));
}
if (vo.getOwnerUser() != null) {
dto.setOwnerUser(convertToUserSimpleDTO(vo.getOwnerUser()));
}
// 转换流程实例信息
if (vo.getProcessInstance() != null) {
BpmTaskRespDTO.ProcessInstanceDTO processInstanceDTO = new BpmTaskRespDTO.ProcessInstanceDTO();
processInstanceDTO.setId(vo.getProcessInstance().getId());
processInstanceDTO.setName(vo.getProcessInstance().getName());
processInstanceDTO.setCreateTime(vo.getProcessInstance().getCreateTime());
processInstanceDTO.setProcessDefinitionId(vo.getProcessInstance().getProcessDefinitionId());
processInstanceDTO.setSummary(vo.getProcessInstance().getSummary());
if (vo.getProcessInstance().getStartUser() != null) {
processInstanceDTO.setStartUser(convertToUserSimpleDTO(vo.getProcessInstance().getStartUser()));
}
dto.setProcessInstance(processInstanceDTO);
}
// 转换操作按钮设置
if (vo.getButtonsSetting() != null) {
Map<Integer, BpmTaskRespDTO.OperationButtonSettingDTO> buttonsSettingDTO = vo.getButtonsSetting().entrySet()
.stream()
.collect(java.util.stream.Collectors.toMap(
Map.Entry::getKey,
entry -> {
BpmTaskRespDTO.OperationButtonSettingDTO settingDTO = new BpmTaskRespDTO.OperationButtonSettingDTO();
settingDTO.setDisplayName(entry.getValue().getDisplayName());
settingDTO.setEnable(entry.getValue().getEnable());
return settingDTO;
}
));
dto.setButtonsSetting(buttonsSettingDTO);
}
// 递归转换子任务
if (vo.getChildren() != null) {
dto.setChildren(buildTaskRespDTOList(vo.getChildren()));
}
return dto;
}
/**
* 将 UserSimpleBaseVO 转换为 UserSimpleDTO确保所有字段都被正确赋值
*/
default UserSimpleDTO convertToUserSimpleDTO(UserSimpleBaseVO vo) {
if (vo == null) {
return null;
}
UserSimpleDTO dto = new UserSimpleDTO();
dto.setId(vo.getId());
dto.setNickname(vo.getNickname());
dto.setAvatar(vo.getAvatar());
dto.setDeptId(vo.getDeptId());
dto.setDeptName(vo.getDeptName()); // 确保 deptName 被正确赋值
return dto;
}
}

View File

@@ -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);
}

View File

@@ -38,6 +38,11 @@ public class BusinessFilePageReqDTO extends PageParam implements Serializable {
*/
private String source;
/**
* 状态1-正常0-禁用)
*/
private Integer status;
/**
* 创建时间
*/

View File

@@ -49,6 +49,11 @@ public class BusinessFileRespDTO implements Serializable {
*/
private String source;
/**
* 状态1-正常0-禁用)
*/
private Integer status;
/**
* 创建时间
*/

View File

@@ -25,5 +25,7 @@ public class BusinessFileSaveReqDTO implements Serializable {
private Long fileId;
/** 业务来源 */
private String source;
/** 状态1-正常0-禁用) */
private Integer status;
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);
}
}

View File

@@ -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());
}
}
}

View File

@@ -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);
}
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -25,4 +25,7 @@ public class BusinessFileSaveReqVO {
@Schema(description = "附件来源")
private String source;
@Schema(description = "状态1-正常0-禁用)", example = "1")
private Integer status;
}

View File

@@ -48,6 +48,11 @@ public class BusinessFileDO extends BaseDO {
*/
@TableField("SRC")
private String source;
/**
* 状态1-正常0-禁用)
*/
@TableField("STATUS")
private Integer status;
}

View File

@@ -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));
}

View File

@@ -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);
}

View File

@@ -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);
}
}
}

View File

@@ -23,6 +23,16 @@ public class AdminUserRespDTO implements VO {
@Schema(description = "部门编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private List<Long> deptIds;
@Schema(description = "部门编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1")
private Long deptId;
public Long getDeptId() {
if (deptIds != null && !deptIds.isEmpty()) {
return deptIds.get(0);
}
return null;
}
@Schema(description = "岗位编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 3]")
private Set<Long> postIds;

View File

@@ -12,16 +12,16 @@ import com.zt.plat.module.system.api.user.dto.AdminUserUpdateStatusReqDTO;
import com.zt.plat.module.system.controller.admin.user.vo.user.UserSaveReqVO;
import com.zt.plat.module.system.dal.dataobject.dept.DeptDO;
import com.zt.plat.module.system.dal.dataobject.user.AdminUserDO;
import com.zt.plat.module.system.dal.dataobject.userdept.UserDeptDO;
import com.zt.plat.module.system.service.dept.DeptService;
import com.zt.plat.module.system.service.user.AdminUserService;
import com.zt.plat.module.system.service.userdept.UserDeptService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import static com.zt.plat.framework.common.pojo.CommonResult.success;
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertSet;
@@ -34,6 +34,8 @@ public class AdminUserApiImpl implements AdminUserApi {
private AdminUserService userService;
@Resource
private DeptService deptService;
@Resource
private UserDeptService userDeptService;
@Override
public CommonResult<Long> createUser(AdminUserSaveReqDTO reqVO) {
@@ -107,7 +109,23 @@ public class AdminUserApiImpl implements AdminUserApi {
public CommonResult<List<AdminUserRespDTO>> getUserList(Collection<Long> ids) {
return DataPermissionUtils.executeIgnore(() -> { // 禁用数据权限。原因是,一般基于指定 id 的 API 查询,都是数据拼接为主
List<AdminUserDO> users = userService.getUserList(ids);
return success(BeanUtils.toBean(users, AdminUserRespDTO.class));
List<UserDeptDO> validUserDeptListByUserIds = userDeptService.getValidUserDeptListByUserIds(ids);
// 构建用户ID到部门ID列表的映射
Map<Long, List<Long>> userDeptMap = validUserDeptListByUserIds.stream()
.collect(Collectors.groupingBy(
UserDeptDO::getUserId,
Collectors.mapping(UserDeptDO::getDeptId, Collectors.toList())
));
// 转换并设置部门信息
List<AdminUserRespDTO> userRespList = BeanUtils.toBean(users, AdminUserRespDTO.class);
userRespList.forEach(userResp -> {
List<Long> deptIds = userDeptMap.getOrDefault(userResp.getId(), new ArrayList<>());
userResp.setDeptIds(deptIds);
});
return success(userRespList);
});
}

View File

@@ -13,11 +13,10 @@ import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.framework.excel.core.util.ExcelUtils;
import com.zt.plat.module.bpm.api.task.BpmProcessInstanceApi;
import com.zt.plat.module.bpm.api.task.BpmTaskApi;
import com.zt.plat.module.bpm.api.task.dto.BpmTaskRespDTO;
import com.zt.plat.module.infra.api.businessfile.BusinessFileApi;
import com.zt.plat.module.infra.api.businessfile.dto.BusinessFilePageReqDTO;
import com.zt.plat.module.infra.api.file.FileApi;
import com.zt.plat.module.infra.api.file.dto.FileRespDTO;
import com.zt.plat.module.system.api.dept.DeptApi;
import com.zt.plat.module.system.api.dept.dto.CompanyDeptInfoRespDTO;
import com.zt.plat.module.template.controller.admin.contract.vo.DemoContractPageReqVO;
import com.zt.plat.module.template.controller.admin.contract.vo.DemoContractRespVO;
import com.zt.plat.module.template.controller.admin.contract.vo.DemoContractSaveReqVO;
@@ -35,11 +34,9 @@ import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.zt.plat.framework.common.pojo.CommonResult.success;
import static com.zt.plat.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@Tag(name = "管理后台 - 合同")
@RestController
@@ -67,6 +64,8 @@ public class DemoContractController extends AbstractFileUploadController impleme
private BpmTaskApi bpmTaskApi;
@Resource
private BpmProcessInstanceApi bpmInsApi;
@Resource
private FileApi fileApi;
@PostMapping("/create")
@Operation(summary = "创建合同")
@@ -114,9 +113,7 @@ public class DemoContractController extends AbstractFileUploadController impleme
@Operation(summary = "获得合同分页")
@PreAuthorize("@ss.hasPermission('template:demo-contract:query')")
public CommonResult<PageResult<DemoContractRespVO>> getDemoContractPage(@Valid DemoContractPageReqVO pageReqVO) {
BusinessFilePageReqDTO pageReqDTO = new BusinessFilePageReqDTO();
CommonResult<List<BpmTaskRespDTO>> taskTodoPage = bpmTaskApi.getTaskListByProcessInstanceId("1111");
CommonResult<Set<CompanyDeptInfoRespDTO>> companyDeptInfoListByUserId = deptApi.getCompanyDeptInfoListByUserId(getLoginUserId());
CommonResult<FileRespDTO> file = fileApi.getFile(1968928810422521857L);
Long id = IdWorker.getId();
System.out.println("Generated ID: " + id);
PageResult<DemoContractDO> pageResult = demoContractService.getDemoContractPage(pageReqVO);