docs(product): 删除产品管理SQL口径和业务设计文档
- 移除02-产品管理SQL已确认口径文档 - 移除02-产品管理业务设计文档 - 清理产品管理模块的详细设计说明 - 删除产品需求状态字段口径定义 - 移除来源承接与需求拆分口径说明 - 清理需求终态原因承接口径内容 - 删除产品生命周期管理设计 - 移除产品团队权限管理规范 - 清理产品与项目关系约束说明 - 删除轻量需求管理业务规则 - 移除产品状态机与流程设计 - 清理权限与动作矩阵定义
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
|
||||
#Tue Apr 21 08:50:58 CST 2026
|
||||
https\://maven.aliyun.com/repository/public/.lastUpdated=1776732658408
|
||||
https\://maven.aliyun.com/repository/public/.error=
|
||||
@@ -23,6 +23,13 @@
|
||||
- 根模块打包类型:`pom`
|
||||
- Spring Boot 版本:`3.5.9`
|
||||
|
||||
## 本地环境约定
|
||||
|
||||
- 本机 Maven 安装路径:`C:\software\apache-maven-3.8.9`
|
||||
- 如需执行 Maven 命令,优先使用完整路径:`C:\software\apache-maven-3.8.9\bin\mvn.cmd`
|
||||
- 不要假设 `mvn` 已加入 PATH
|
||||
- 只有在用户已明确同意执行编译、测试、打包等 Maven 命令时,才使用上述路径执行
|
||||
|
||||
顶层模块:
|
||||
|
||||
1. `rdms-system`
|
||||
@@ -196,6 +203,7 @@ rdms-xxx
|
||||
- 新增或修改代码时,关键字段、关键分支、关键约束和非直观实现应补充简洁中文注释。
|
||||
- 不要为了省事删除原有有效注释,也不要添加无信息量的注释。
|
||||
- 写入中文内容时必须保持 UTF-8 编码,并自行检查中文显示是否正常;不要用“改成英文”规避乱码问题。
|
||||
- 使用 superpowers 产出的功能文档时,例如设计文档、实施计划、联调说明,除非用户明确要求,否则默认用中文落地;代码标识、文件路径、接口路径、SQL、命令保持原始技术标识,不做意译。
|
||||
|
||||
## 工作规则
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ import java.util.List;
|
||||
|
||||
public class InDictCollectionValidator implements ConstraintValidator<InDict, Collection<?>> {
|
||||
|
||||
private static final String MISSING_DICT_DATA_MESSAGE = "字典数据缺失,请联系管理员维护";
|
||||
|
||||
private String dictType;
|
||||
|
||||
@Override
|
||||
@@ -25,6 +27,12 @@ public class InDictCollectionValidator implements ConstraintValidator<InDict, Co
|
||||
}
|
||||
// 校验全部通过
|
||||
List<String> dbValues = DictFrameworkUtils.getDictDataValueList(dictType);
|
||||
if (dbValues.isEmpty()) {
|
||||
context.disableDefaultConstraintViolation();
|
||||
context.buildConstraintViolationWithTemplate(MISSING_DICT_DATA_MESSAGE)
|
||||
.addConstraintViolation();
|
||||
return false;
|
||||
}
|
||||
boolean match = list.stream().allMatch(v -> dbValues.stream()
|
||||
.anyMatch(dbValue -> dbValue.equalsIgnoreCase(v.toString())));
|
||||
if (match) {
|
||||
@@ -40,4 +48,3 @@ public class InDictCollectionValidator implements ConstraintValidator<InDict, Co
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import java.util.List;
|
||||
|
||||
public class InDictValidator implements ConstraintValidator<InDict, Object> {
|
||||
|
||||
private static final String MISSING_DICT_DATA_MESSAGE = "字典数据缺失,请联系管理员维护";
|
||||
|
||||
private String dictType;
|
||||
|
||||
@Override
|
||||
@@ -24,6 +26,12 @@ public class InDictValidator implements ConstraintValidator<InDict, Object> {
|
||||
}
|
||||
// 校验通过
|
||||
final List<String> values = DictFrameworkUtils.getDictDataValueList(dictType);
|
||||
if (values.isEmpty()) {
|
||||
context.disableDefaultConstraintViolation();
|
||||
context.buildConstraintViolationWithTemplate(MISSING_DICT_DATA_MESSAGE)
|
||||
.addConstraintViolation();
|
||||
return false;
|
||||
}
|
||||
boolean match = values.stream().anyMatch(v -> StrUtil.equalsIgnoreCase(v, value.toString()));
|
||||
if (match) {
|
||||
return true;
|
||||
@@ -38,4 +46,3 @@ public class InDictValidator implements ConstraintValidator<InDict, Object> {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,20 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode PRODUCT_STATUS_ACTION_REASON_REQUIRED = new ErrorCode(1_008_001_005, "动作【{}】必须填写原因");
|
||||
ErrorCode PRODUCT_DELETE_NAME_MISMATCH = new ErrorCode(1_008_001_006, "删除确认名称与当前产品名称不一致");
|
||||
ErrorCode PRODUCT_STATUS_NOT_ALLOW_EDIT = new ErrorCode(1_008_001_007, "当前产品状态不允许编辑");
|
||||
ErrorCode PRODUCT_PAUSED_ONLY_ALLOW_LIMITED_UPDATE = new ErrorCode(1_008_001_008, "产品暂停后仅允许变更产品经理、描述和备注");
|
||||
ErrorCode PRODUCT_PAUSED_ONLY_ALLOW_LIMITED_UPDATE = new ErrorCode(1_008_001_008, "产品暂停后仅允许修正描述,产品经理请通过产品团队维护");
|
||||
ErrorCode PRODUCT_MEMBER_NOT_EXISTS = new ErrorCode(1_008_001_009, "产品团队成员不存在");
|
||||
ErrorCode PRODUCT_MEMBER_ALREADY_EXISTS = new ErrorCode(1_008_001_010, "该用户已是当前产品的有效团队成员");
|
||||
ErrorCode PRODUCT_MEMBER_ROLE_INVALID = new ErrorCode(1_008_001_011, "角色不存在或不属于产品对象角色");
|
||||
ErrorCode PRODUCT_MANAGER_TRANSFER_INFO_REQUIRED = new ErrorCode(1_008_001_013, "切换产品经理时必须同时传入原产品经理用户和交接后角色");
|
||||
ErrorCode PRODUCT_MANAGER_MEMBER_NOT_ALLOW_REMOVE = new ErrorCode(1_008_001_014, "当前产品经理不能移出产品团队,请先完成经理转交");
|
||||
ErrorCode PRODUCT_MANAGER_MEMBER_NOT_ALLOW_DOWNGRADE = new ErrorCode(1_008_001_015, "当前产品经理不能直接调整为非经理角色,请先完成经理转交");
|
||||
ErrorCode PRODUCT_MEMBER_NOT_ACTIVE = new ErrorCode(1_008_001_016, "当前产品团队成员已失效");
|
||||
ErrorCode PRODUCT_MANAGER_TRANSFER_SOURCE_INVALID = new ErrorCode(1_008_001_017, "原产品经理信息与当前产品经理不一致");
|
||||
ErrorCode PRODUCT_MANAGER_TRANSFER_ROLE_INVALID = new ErrorCode(1_008_001_018, "原产品经理交接后的角色不能仍为产品经理");
|
||||
ErrorCode PRODUCT_MANAGER_NOT_MODIFIABLE = new ErrorCode(1_008_001_019, "产品主数据编辑不允许直接变更产品经理,请通过产品团队维护");
|
||||
ErrorCode PRODUCT_OBJECT_PERMISSION_DENIED = new ErrorCode(1_008_001_020, "当前用户不具备该产品的操作权限【{}】");
|
||||
ErrorCode PRODUCT_DELETE_CONFIRM_TEXT_INVALID = new ErrorCode(1_008_001_021, "删除确认口令不正确");
|
||||
ErrorCode PRODUCT_STATUS_CONCURRENT_MODIFIED = new ErrorCode(1_008_001_022, "产品状态已发生变化,请刷新后重试");
|
||||
ErrorCode PRODUCT_STATUS_MODEL_NOT_EXISTS_OR_DISABLED = new ErrorCode(1_008_001_023, "产品状态定义不存在或已停用");
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.njcn.rdms.module.project.enums;
|
||||
|
||||
/**
|
||||
* 项目交付域字典类型常量
|
||||
*/
|
||||
public interface ProjectDictTypeConstants {
|
||||
|
||||
/**
|
||||
* 产品方向
|
||||
*/
|
||||
String PRODUCT_DIRECTION = "rdms_product_direction";
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
# 02-产品管理 SQL已确认口径
|
||||
|
||||
## 0. 文档说明
|
||||
|
||||
本文档用于记录产品管理 SQL 已确认的实现口径。
|
||||
|
||||
本文档只保留已确认结果,不保留待确认项、方案对比或历史演变说明。
|
||||
|
||||
## 1. 共享表承接边界
|
||||
|
||||
- `rdms_user_object_role`
|
||||
- `rdms_object_status_model`
|
||||
- `rdms_object_status_transition`
|
||||
- `rdms_biz_audit_log`
|
||||
|
||||
以上共享表继续由 `rdms-project/rdms-project-boot/src/main/resources/sql/product/01_product_schema.sql` 承接。
|
||||
|
||||
## 2. 产品需求状态字段口径
|
||||
|
||||
- `rdms_product_requirement` 统一改为 `status_code` 口径。
|
||||
- 产品需求状态与产品状态保持一致,统一使用状态编码模型。
|
||||
|
||||
## 3. 来源承接与需求拆分口径
|
||||
|
||||
- 产品需求既可能来自工单流转,也可能来自产品内手工新增。
|
||||
- 产品需求不论来源,都允许继续拆分为 N 个子需求。
|
||||
- 同一产品下,同一来源工单只生成 1 条源头需求记录。
|
||||
- 源头需求记录可以拆分为 N 条子需求。
|
||||
- 手工新增需求也可以拆分为 N 条子需求。
|
||||
- 子需求不参与“来源唯一”约束。
|
||||
- 来源追溯和拆分关系分开建模。
|
||||
|
||||
## 4. 需求终态原因承接口径
|
||||
|
||||
- 需求终态原因由主表承接当前结果态,同时审计日志保留完整留痕。
|
||||
- 主表统一承接终态结果字段,覆盖 `reject`、`cancel`、`close` 等终态动作。
|
||||
|
||||
字段口径:
|
||||
|
||||
- `terminal_action_code`
|
||||
- `terminal_reason`
|
||||
- `terminal_time`
|
||||
|
||||
## 5. 当前确认结果
|
||||
|
||||
- 第 1 项:共享表继续由 `01_product_schema.sql` 承接
|
||||
- 第 2 项:`rdms_product_requirement` 统一改为 `status_code`
|
||||
- 第 3 项:来源承接与需求拆分分开建模
|
||||
- 第 4 项:主表补终态结果字段,审计日志继续完整留痕
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,478 +0,0 @@
|
||||
# 03-产品管理范围内产品与产品需求链路与工作流方案
|
||||
|
||||
## 0. 文档目的
|
||||
|
||||
本文档用于回答以下问题:
|
||||
|
||||
- 在当前产品管理范围内,`product -> product_requirement` 是否适合做链路视图
|
||||
- 后续工单进入产品侧时,应如何接入当前产品管理链路
|
||||
- 是否适合引入 Flowable
|
||||
- Flowable 在当前产品管理方案中应承接哪些节点,不应承接哪些节点
|
||||
- 当前产品管理链路应如何建模
|
||||
- 当前产品需求设计中的“终态原因”口径适用范围是什么
|
||||
|
||||
说明:
|
||||
|
||||
- 本文档中的“产品作为主上下文”仅限当前产品管理能力建设范围。
|
||||
- 该口径用于当前产品管理方案收敛,不作为 RDMS 全局统一建模原则。
|
||||
- 本文档只给方案,不直接修改业务代码、SQL 或正式设计文档。
|
||||
|
||||
## 1. 当前现状判断
|
||||
|
||||
### 1.1 当前代码与文档现状
|
||||
|
||||
- 当前仓库未看到 Flowable 依赖、BPMN 定义或流程引擎接入实现。
|
||||
- `rdms-project` 已开始承接通用对象状态模型,当前已有 `rdms_object_status_model`、`rdms_object_status_transition` 的 DO 和 Mapper。
|
||||
- 产品管理当前已经明确:产品与产品需求承接轻量状态流转,但当前版本不展开正式工作流引擎。
|
||||
- 当前产品需求设计已具备来源追溯、状态流转、认领 / 拒绝、拆分等业务语义。
|
||||
- 当前要开发的是产品管理,不是项目管理;`project_requirement / execution / task` 不属于本期范围。
|
||||
|
||||
### 1.2 当前链路特征
|
||||
|
||||
在本期产品管理范围内,当前业务链路主要具备以下特征:
|
||||
|
||||
- 产品是当前方案的主上下文
|
||||
- 产品侧可以手工新增产品需求
|
||||
- 后续工单可以进入产品侧形成来源需求
|
||||
- 一个产品需求可以拆分成 N 个子需求
|
||||
- 某些节点需要人认领、人评审、人审批
|
||||
- 某些节点只是普通业务状态推进,不适合上审批流
|
||||
|
||||
这意味着在本期产品管理范围内,该链路本质上是“产品上下文下的产品需求关系网络”,不是“一条从头跑到尾的单一审批流程”。
|
||||
|
||||
## 2. 核心结论
|
||||
|
||||
### 2.1 可行性判断
|
||||
|
||||
结论:可行,但本期不建议把产品管理范围内的所有动作都堆进单一 Flowable 流程。
|
||||
|
||||
推荐方向:
|
||||
|
||||
- 在本期产品管理方案内,产品作为当前链路的主上下文和主入口
|
||||
- 当前链路聚合围绕 `product`、`product_requirement` 组织
|
||||
- 需求链(`chain`)表示“本期产品管理范围内,产品下的一条源头需求链”
|
||||
- 工单在后续接入时,只作为产品需求的来源关系之一,不作为链路根
|
||||
- 业务主链统一由状态机控制
|
||||
- Flowable 等以后开发评审流程时再接入,只承接评审、审批类协同节点
|
||||
- 各业务对象继续维护自己的 `status_code`
|
||||
- 流程状态不是业务真相源,业务表状态才是业务真相源
|
||||
- 本期先按表和后端接口完成基础建模和后端闭环,不做前端页面和流程引擎接入
|
||||
|
||||
### 2.2 不建议单一长流程的原因
|
||||
|
||||
- 产品需求存在手工新增、父子拆分等多种情况;后续再叠加工单来源时,也难以用单流程表达。
|
||||
- 认领、拒绝、拆分、关闭等动作很多是高频业务动作,不适合全部流程化。
|
||||
- 流程状态和业务状态容易双写不一致。
|
||||
- 当前真正需要先打通的是产品管理范围内的后端聚合能力,而不是先上流程图。
|
||||
|
||||
### 2.3 终态原因口径适用范围
|
||||
|
||||
“终态原因承接口径”不是只针对工单来源需求,而是针对产品需求对象本身。
|
||||
|
||||
也就是说,无论产品需求来自:
|
||||
|
||||
- 工单流转
|
||||
- 手工新增
|
||||
|
||||
只要走到 `reject`、`cancel`、`close` 这类终态动作,都需要明确终态原因承接方式。
|
||||
|
||||
从后端聚合查询角度看,主表保留当前结果态原因字段,审计日志继续保留完整留痕。
|
||||
|
||||
## 3. 建议总体架构
|
||||
|
||||
当前建议拆成 4 层,再预留 1 个后续扩展层。
|
||||
|
||||
### 3.1 业务对象层
|
||||
|
||||
业务对象继续独立建模,独立维护生命周期和 `status_code`。
|
||||
|
||||
本期纳入当前链路建模的对象:
|
||||
|
||||
- 产品 `product`
|
||||
- 产品需求 `product_requirement`
|
||||
- `work_order` 作为后续预留来源对象
|
||||
|
||||
要求:
|
||||
|
||||
- 在本期产品管理范围内,产品是当前链路的主上下文
|
||||
- 产品需求是当前链路的核心业务对象
|
||||
- 每个对象的状态变化由业务服务负责落库
|
||||
- 后续工单进入产品侧后,只承接来源关系,不取代产品主上下文
|
||||
- 业务主链先由状态机控制,不由流程引擎接管
|
||||
|
||||
### 3.2 关系模型层
|
||||
|
||||
关系模型用于描述对象之间的连接关系,而不是靠单个来源字段硬扛全部追溯逻辑。
|
||||
|
||||
本期至少需要表达以下关系:
|
||||
|
||||
- 产品和源头需求之间的主上下文关系
|
||||
- 产品需求父子拆分
|
||||
|
||||
建议引入统一关系表,例如:
|
||||
|
||||
`rdms_biz_relation`
|
||||
|
||||
建议关键字段:
|
||||
|
||||
- `id`
|
||||
- `chain_id`
|
||||
- `product_id`
|
||||
- `from_biz_type`
|
||||
- `from_biz_id`
|
||||
- `to_biz_type`
|
||||
- `to_biz_id`
|
||||
- `relation_type`
|
||||
- `sort`
|
||||
- `remark`
|
||||
|
||||
建议 `relation_type` 取值至少包括:
|
||||
|
||||
- `product_root`:产品主上下文
|
||||
- `split_child`:拆分子需求
|
||||
|
||||
后续预留关系类型:
|
||||
|
||||
- `source_work_order`:来源工单
|
||||
|
||||
说明:
|
||||
|
||||
- `product_root` 用于表达本期产品管理范围内,产品和源头需求之间的主上下文关系。
|
||||
- 手工新增不是对象间来源关系,不必强行补一条虚拟来源边;可由 `rdms_requirement_chain.entry_source_type = manual` 承接。
|
||||
|
||||
### 3.3 事件模型层
|
||||
|
||||
事件模型用于描述“产品下的一条需求链上发生了什么”,服务于后端聚合查询和后续时间线视图。
|
||||
|
||||
建议引入统一事件表,例如:
|
||||
|
||||
`rdms_biz_event`
|
||||
|
||||
建议关键字段:
|
||||
|
||||
- `id`
|
||||
- `chain_id`
|
||||
- `product_id`
|
||||
- `biz_type`
|
||||
- `biz_id`
|
||||
- `event_type`
|
||||
- `action_code`
|
||||
- `from_status_code`
|
||||
- `to_status_code`
|
||||
- `operator_user_id`
|
||||
- `operator_name`
|
||||
- `reason`
|
||||
- `event_time`
|
||||
- `payload_json`
|
||||
|
||||
事件类型可覆盖:
|
||||
|
||||
- `create`
|
||||
- `claim`
|
||||
- `reject`
|
||||
- `split`
|
||||
- `review_pass`
|
||||
- `review_reject`
|
||||
- `close`
|
||||
- `cancel`
|
||||
|
||||
后续预留事件类型:
|
||||
|
||||
- `source_attach`
|
||||
|
||||
### 3.4 需求链聚合层
|
||||
|
||||
为了做当前产品管理范围内的链路聚合,建议引入统一聚合对象。
|
||||
|
||||
建议引入需求链主表,例如:
|
||||
|
||||
`rdms_requirement_chain`
|
||||
|
||||
建议关键字段:
|
||||
|
||||
- `id`
|
||||
- `chain_code`
|
||||
- `product_id`
|
||||
- `root_requirement_id`
|
||||
- `entry_source_type`
|
||||
- `entry_biz_type`
|
||||
- `entry_biz_id`
|
||||
- `title`
|
||||
- `current_status_code`
|
||||
- `closed_flag`
|
||||
|
||||
用途:
|
||||
|
||||
- 作为“产品下的一条源头需求链”的聚合单元
|
||||
- 聚合关系和事件
|
||||
- 支撑后端聚合查询;后续前端如接入,再由产品详情页和产品需求详情页承接
|
||||
|
||||
说明:
|
||||
|
||||
- 一个产品下会有多条需求链
|
||||
- 一条需求链只属于一个产品
|
||||
- 一条需求链只围绕一个源头产品需求展开
|
||||
- 后续工单来源需求创建需求链时,工单只写入 `entry_biz_type / entry_biz_id` 和 `source_work_order` 关系,不作为根对象
|
||||
|
||||
### 3.5 流程绑定层(后续扩展)
|
||||
|
||||
流程引擎只负责协同过程,因此等以后开发评审流程时,可再补业务对象和流程实例的绑定层。
|
||||
|
||||
建议引入流程绑定表,例如:
|
||||
|
||||
`rdms_workflow_binding`
|
||||
|
||||
建议关键字段:
|
||||
|
||||
- `id`
|
||||
- `chain_id`
|
||||
- `product_id`
|
||||
- `biz_type`
|
||||
- `biz_id`
|
||||
- `process_definition_key`
|
||||
- `process_instance_id`
|
||||
- `workflow_status`
|
||||
- `current_task_key`
|
||||
- `current_task_name`
|
||||
- `starter_user_id`
|
||||
- `start_time`
|
||||
- `end_time`
|
||||
|
||||
说明:
|
||||
|
||||
- 该层不是本期前置条件
|
||||
- 本期不接 Flowable 时,不需要先落这张表
|
||||
- 等以后开发评审流程时再接入,只用于评审、审批类协同节点
|
||||
|
||||
## 4. Flowable 适用边界
|
||||
|
||||
### 4.1 适合接 Flowable 的节点
|
||||
|
||||
以下节点等以后开发评审流程时,可考虑接入 Flowable:
|
||||
|
||||
- 产品需求待评审
|
||||
- 高风险终态动作审批
|
||||
- 其他明确的审批类节点
|
||||
|
||||
这类节点的共同特征是:
|
||||
|
||||
- 需要明确待办人
|
||||
- 需要审批意见
|
||||
- 需要驳回、转交、加签、会签等协作能力
|
||||
|
||||
### 4.2 不建议接 Flowable 的节点
|
||||
|
||||
以下节点不建议直接建成流程审批节点:
|
||||
|
||||
- 后续工单接入产品侧后的认领 / 拒绝
|
||||
- 普通状态编辑
|
||||
- 列表筛选查询
|
||||
- 日常状态推进
|
||||
- 产品需求拆分
|
||||
|
||||
这类节点更适合保留在业务状态机或普通业务服务里,否则流程实例会过多、过碎、过重。
|
||||
|
||||
## 5. 当前链路视图如何实现
|
||||
|
||||
本期只要求后端先具备聚合查询能力,不要求直接交付页面。
|
||||
|
||||
### 5.1 拓扑数据
|
||||
|
||||
展示本期产品管理范围内,以产品为入口的对象关系链:
|
||||
|
||||
```text
|
||||
产品
|
||||
-> 产品需求(源头需求)
|
||||
-> 子需求
|
||||
|
||||
后续工单 -(source_work_order)-> 产品需求(可选来源)
|
||||
```
|
||||
|
||||
后端主要聚合:
|
||||
|
||||
- `rdms_requirement_chain`
|
||||
- `rdms_biz_relation`
|
||||
- `product`
|
||||
- `product_requirement`
|
||||
|
||||
### 5.2 时间线数据
|
||||
|
||||
展示产品下某条需求链上的关键事件:
|
||||
|
||||
- 产品需求创建
|
||||
- 产品需求认领
|
||||
- 产品需求评审
|
||||
- 拆分子需求
|
||||
- 关闭 / 拒绝 / 取消
|
||||
|
||||
后端主要聚合:
|
||||
|
||||
- `rdms_biz_event`
|
||||
- `product_requirement` 当前状态摘要
|
||||
|
||||
说明:
|
||||
|
||||
- 时间线围绕单条需求链展开,不是把整个产品下所有动作混成一条总流水。
|
||||
- 本期先交付后端聚合查询接口,不要求同时交付拓扑页和时间线页,也不进入前端联调。
|
||||
|
||||
## 6. 对现有产品管理设计的建议
|
||||
|
||||
### 6.1 本期产品管理范围内的主上下文口径
|
||||
|
||||
既然本期要开发的是产品管理,建议当前方案中的聚合查询和后端入口都优先挂在产品上下文下。
|
||||
|
||||
要求:
|
||||
|
||||
- `product_id` 是链路聚合模型的必填归属字段
|
||||
- 后续前端如接入,产品详情页和产品需求详情页是主入口
|
||||
- 后续工单详情页如需展示链路,只适合作为来源跳转入口,不适合作为主视图入口
|
||||
|
||||
### 6.2 状态口径
|
||||
|
||||
既然你已经确认本期只做产品和产品需求,建议当前阶段只要求这两个对象继续沿用统一的 `status_code` 口径。
|
||||
|
||||
说明:
|
||||
|
||||
- `product`
|
||||
- `product_requirement`
|
||||
|
||||
项目管理阶段再单独设计 `project_requirement / execution / task` 的状态模型和流转规则,不并入本期范围。
|
||||
|
||||
### 6.3 来源与拆分口径
|
||||
|
||||
你已经确认:
|
||||
|
||||
- 来源承接和需求拆分分开建模
|
||||
- 后续工单来源需求可拆分
|
||||
- 手工新增需求也可拆分
|
||||
|
||||
当前产品需求口径应将来源追溯和拆分关系分开承接:
|
||||
|
||||
- `source_biz_*` 字段只承接来源追溯
|
||||
- `parent_requirement_id`、`root_requirement_id` 承接拆分链路
|
||||
- 后续同一产品下,同一来源工单只生成 1 条源头需求记录
|
||||
- 子需求不参与来源唯一约束
|
||||
|
||||
### 6.4 终态原因口径
|
||||
|
||||
产品需求主表统一承接当前结果态字段。
|
||||
|
||||
当前字段方向:
|
||||
|
||||
- `terminal_action_code`
|
||||
- `terminal_reason`
|
||||
- `terminal_time`
|
||||
|
||||
这样后端做本期产品管理范围内的聚合查询时,可以直接读取当前结果态原因,而不用每次回扫审计日志。
|
||||
|
||||
## 7. 建议实施顺序
|
||||
|
||||
建议按三步走,但只有第一步属于本期必做范围。
|
||||
|
||||
### 第一步:先完成本期产品管理的基础建模和后端闭环
|
||||
|
||||
目标:
|
||||
|
||||
- 明确在本期产品管理范围内,产品作为当前链路的主上下文
|
||||
- 建立链路主表
|
||||
- 建立链路关系表
|
||||
- 建立链路事件表
|
||||
- 统一产品和产品需求的状态口径
|
||||
- 先把业务主链的状态机闭环跑通
|
||||
- 先提供产品上下文下查询单条需求链关系拓扑和事件时间线的聚合接口
|
||||
|
||||
这一阶段先不接 Flowable,只按表和后端接口开发,不做前端拓扑页和时间线页,也不扩到项目管理对象。
|
||||
|
||||
### 第二步:后续开发评审流程时接入有限流程节点
|
||||
|
||||
目标:
|
||||
|
||||
- 产品需求评审
|
||||
- 高风险终态审批
|
||||
- 其他明确需要审批协同的节点
|
||||
|
||||
这类节点等以后开发评审流程时可接入 Flowable,但不是本期前置条件。
|
||||
|
||||
### 第三步:后续在项目管理阶段扩展项目域对象
|
||||
|
||||
目标:
|
||||
|
||||
- 在后续项目管理建设时,再补 `project_requirement / execution / task` 等对象
|
||||
- 届时再单独设计它们和产品需求之间的关系、事件和流程边界
|
||||
|
||||
说明:
|
||||
|
||||
- 这一步不属于本期产品管理开发范围。
|
||||
|
||||
## 8. 风险点与控制建议
|
||||
|
||||
### 8.1 范围扩散到项目管理
|
||||
|
||||
风险:
|
||||
|
||||
- 在当前产品管理开发过程中,又把 `project_requirement / execution / task` 一起拉进来
|
||||
|
||||
控制建议:
|
||||
|
||||
- 所有设计文档都明确“本期只做产品和产品需求”
|
||||
- 项目域对象放到后续项目管理建设时再单独设计
|
||||
|
||||
### 8.2 状态双写不一致
|
||||
|
||||
风险:
|
||||
|
||||
- 流程状态更新了,但业务表状态没更新
|
||||
- 业务状态更新了,但流程实例没推进
|
||||
|
||||
控制建议:
|
||||
|
||||
- 本期主链统一由状态机控制
|
||||
- 等以后开发评审流程时接入 Flowable,也只作为协同触发器
|
||||
- 每次关键动作统一写 `rdms_biz_event`
|
||||
|
||||
### 8.3 来源与拆分关系混淆
|
||||
|
||||
风险:
|
||||
|
||||
- 来源关系和拆分关系混在一个字段里,后续追溯会失真
|
||||
|
||||
控制建议:
|
||||
|
||||
- 来源关系和父子拆分关系分开建模
|
||||
- 统一走关系表,不靠单字段隐式表达
|
||||
|
||||
### 8.4 前端聚合过早介入
|
||||
|
||||
风险:
|
||||
|
||||
- 后端模型和接口还没稳住,就先开始拼页面,后面会频繁返工
|
||||
|
||||
控制建议:
|
||||
|
||||
- 本期先完成基础建模和聚合查询接口
|
||||
- 前端页面放到后续接口稳定后再接入
|
||||
|
||||
## 9. 当前建议结论
|
||||
|
||||
当前建议拍板如下:
|
||||
|
||||
1. 在本期产品管理方案内,产品作为当前链路的主上下文。
|
||||
2. 本期范围只包含 `product`、`product_requirement`;`work_order` 只作为后续预留来源对象,不纳入第一批实现。
|
||||
3. 一条需求链(`chain`)表示“产品下的一条源头需求链”,不是整个产品,也不是某个工单。
|
||||
4. 本期先做基础建模和后端闭环,包括 `requirement_chain / relation / event` 模型、状态机主链、关键动作落库和聚合查询接口。
|
||||
5. 本期主链统一由状态机控制;Flowable 等以后开发评审流程时再接入,只用于评审、审批类节点。
|
||||
6. 来源追溯和需求拆分必须分开建模。
|
||||
7. 产品需求终态原因由主表承接当前结果态,并继续保留审计日志完整留痕。
|
||||
8. 项目域对象放到后续项目管理建设时再单独设计,不并入本期产品管理范围。
|
||||
9. 以上口径仅用于当前产品管理建设,不作为 RDMS 全局统一建模原则。
|
||||
|
||||
## 10. 下一步建议产物
|
||||
|
||||
如果继续推进,建议下一步补 3 份专项文档:
|
||||
|
||||
1. `产品管理范围内链路接口设计.md`
|
||||
明确聚合查询接口、状态动作接口的返回结构。
|
||||
2. `产品管理范围内链路SQL与表结构设计.md`
|
||||
明确 `requirement_chain / relation / event` 的表结构和索引设计。
|
||||
3. `产品管理范围内链路开发顺序与任务拆分.md`
|
||||
明确 SQL、DO、Mapper、Service、Controller 的开发顺序。
|
||||
@@ -1,221 +0,0 @@
|
||||
# 04-产品管理 编码前必看清单
|
||||
|
||||
## 0. 文档目的
|
||||
|
||||
本文档用于在开始产品管理相关编码前,明确必须先阅读的文档、必须锁死的业务口径,以及当前文档与可执行 SQL 的同步状态。
|
||||
|
||||
本文档只保留当前编码前必须关注的内容,不保留历史演变说明。
|
||||
|
||||
## 1. 文档分级
|
||||
|
||||
### 1.1 一级依据
|
||||
|
||||
以下文档为产品管理编码主依据,涉及业务口径、接口口径、状态口径时,必须优先对齐:
|
||||
|
||||
- `docs/temp/02-产品管理_业务设计.md`
|
||||
- `docs/temp/02-产品管理_SQL已确认口径.md`
|
||||
|
||||
### 1.2 二级依据
|
||||
|
||||
以下文档用于补齐 SQL 结构说明:
|
||||
|
||||
- `docs/temp/02-产品管理_SQL口径说明.md`
|
||||
|
||||
### 1.3 SQL 阅读基线
|
||||
|
||||
以下文件是当前产品管理编码前唯一需要阅读的 SQL 文件,用于确认当前表结构、状态模型、状态流转和审计表设计:
|
||||
|
||||
- `rdms-project/rdms-project-boot/product/rdms_biz_audit_log.sql`
|
||||
|
||||
说明:
|
||||
|
||||
- 当前 SQL 阅读入口统一以该文件为准。
|
||||
- 该文件当前包含 `rdms_biz_audit_log`、`rdms_object_status_model`、`rdms_object_status_transition`、`rdms_product`、`rdms_product_requirement`、`rdms_product_status_log`、`rdms_user_object_role`。
|
||||
- 编码前必须先识别该文件与已确认口径之间的差异,不能直接把该文件当作最终目标结构。
|
||||
|
||||
### 1.4 场景性依据
|
||||
|
||||
以下文档只在涉及工单来源、链路视图、Flowable 边界时必读:
|
||||
|
||||
- `docs/temp/03-工单到任务全链路与工作流方案.md`
|
||||
|
||||
## 2. 阅读顺序
|
||||
|
||||
开始编码前,按以下顺序阅读:
|
||||
|
||||
1. `02-产品管理_业务设计.md`
|
||||
2. `02-产品管理_SQL已确认口径.md`
|
||||
3. `02-产品管理_SQL口径说明.md`
|
||||
4. `rdms-project/rdms-project-boot/product/rdms_biz_audit_log.sql`
|
||||
5. `03-工单到任务全链路与工作流方案.md`(仅在涉及工单链路、需求拆分、Flowable、全链路视图时阅读)
|
||||
|
||||
## 3. 每份文档必须看的内容
|
||||
|
||||
### 3.1 `02-产品管理_业务设计.md`
|
||||
|
||||
必须重点看以下内容:
|
||||
|
||||
- 模块范围与非本期范围
|
||||
- 页面与对象上下文承载方式
|
||||
- 产品需求规则
|
||||
- 对象关系与数据设计
|
||||
- 产品状态与产品需求状态机
|
||||
- 接口承接
|
||||
- 权限与动作矩阵
|
||||
- 测试关注点
|
||||
|
||||
阅读目标:
|
||||
|
||||
- 明确本次到底做哪些页面、动作、字段和权限。
|
||||
- 明确哪些能力本次不做,避免编码时扩散。
|
||||
- 明确关闭、认领、拒绝、分流等动作的业务边界。
|
||||
|
||||
### 3.2 `02-产品管理_SQL已确认口径.md`
|
||||
|
||||
必须逐条看完以下 4 项:
|
||||
|
||||
- 共享表承接边界
|
||||
- 产品需求状态字段口径
|
||||
- 来源承接与需求拆分口径
|
||||
- 需求终态原因承接口径
|
||||
|
||||
阅读目标:
|
||||
|
||||
- 锁死产品需求 `status_code` 口径。
|
||||
- 锁死来源追溯和需求拆分分开建模。
|
||||
- 锁死终态结果字段由主表承接。
|
||||
|
||||
### 3.3 `02-产品管理_SQL口径说明.md`
|
||||
|
||||
必须重点看以下内容:
|
||||
|
||||
- 共享表与主数据口径
|
||||
- 产品需求口径
|
||||
- 状态与留痕口径
|
||||
|
||||
阅读目标:
|
||||
|
||||
- 明确当前确认后的 SQL 结构表达方式。
|
||||
- 明确状态编码、来源追溯、拆分链路、终态结果字段应该如何落到表结构上。
|
||||
|
||||
### 3.4 `rdms-project/rdms-project-boot/product/rdms_biz_audit_log.sql`
|
||||
|
||||
必须重点看以下内容:
|
||||
|
||||
- `rdms_biz_audit_log`
|
||||
- `rdms_object_status_model`
|
||||
- `rdms_object_status_transition`
|
||||
- `rdms_product`
|
||||
- `rdms_product_requirement`
|
||||
- `rdms_product_status_log`
|
||||
- `rdms_user_object_role`
|
||||
|
||||
阅读目标:
|
||||
|
||||
- 明确当前统一 SQL 阅读入口下的表结构、索引、状态种子数据和审计字段现状。
|
||||
- 明确哪些字段和状态定义仍未对齐已确认口径。
|
||||
|
||||
### 3.5 `03-工单到任务全链路与工作流方案.md`
|
||||
|
||||
仅在以下场景必须看:
|
||||
|
||||
- 涉及工单流转到产品需求
|
||||
- 涉及来源追溯与需求拆分
|
||||
- 涉及产品需求到项目需求的链路设计
|
||||
- 涉及 Flowable 接入边界
|
||||
- 涉及全链路视图
|
||||
|
||||
阅读目标:
|
||||
|
||||
- 明确 Flowable 只承接协同节点,不直接承接整条业务主链状态。
|
||||
- 明确来源关系、拆分关系、事件关系和流程绑定关系要分开建模。
|
||||
|
||||
## 4. 编码前必须锁死的业务口径
|
||||
|
||||
### 4.1 模块边界
|
||||
|
||||
- 产品管理能力落在 `rdms-project`,不落到 `rdms-system`、`rdms-gateway`。
|
||||
- 跨模块共享能力通过 `*-api` 承接,不直接依赖其他 `*-boot` 实现。
|
||||
|
||||
### 4.2 产品需求状态口径
|
||||
|
||||
- `rdms_product_requirement` 主表统一使用 `status_code`。
|
||||
- 产品需求状态定义与流转统一通过 `rdms_object_status_model`、`rdms_object_status_transition` 承接。
|
||||
- `object_type` 统一使用 `product_requirement`。
|
||||
|
||||
### 4.3 来源追溯与需求拆分口径
|
||||
|
||||
- 产品需求来源至少包括 `manual`、`work_order`。
|
||||
- `source_type`、`source_biz_type`、`source_biz_id`、`source_biz_code` 只承接来源追溯。
|
||||
- `parent_requirement_id`、`root_requirement_id` 只承接拆分链路。
|
||||
- 同一产品下,同一来源工单只允许 1 条源头需求记录。
|
||||
- 源头需求和手工新增需求都允许继续拆分子需求。
|
||||
- 子需求不参与来源唯一约束。
|
||||
|
||||
### 4.4 终态结果口径
|
||||
|
||||
- `reject`、`cancel`、`close` 等终态动作统一回写主表。
|
||||
- 主表统一保留以下字段:
|
||||
- `terminal_action_code`
|
||||
- `terminal_reason`
|
||||
- `terminal_time`
|
||||
- 审计日志继续保留完整过程留痕。
|
||||
|
||||
### 4.5 接口动作口径
|
||||
|
||||
- 产品状态动作统一走 `POST /products/{id}/change-status`。
|
||||
- 产品需求状态动作统一走 `POST /products/{id}/requirements/{requirementId}/change-status`。
|
||||
- 产品需求 `change-status` 统一支持 `claim`、`to_review`、`to_dispatch`、`dispatch`、`reject`、`cancel`、`close`。
|
||||
- 状态动作不得混入通用编辑接口。
|
||||
|
||||
### 4.6 权限与审计口径
|
||||
|
||||
- 对象上下文权限按产品对象角色控制。
|
||||
- 产品团队、产品需求、状态动作、敏感操作都必须落审计。
|
||||
- 产品状态日志由 `rdms_product_status_log` 承接。
|
||||
- 产品经理变更、成员调整、需求认领、拒绝、分流、关闭、拆分等由 `rdms_biz_audit_log` 承接。
|
||||
|
||||
## 5. 当前明确不做的内容
|
||||
|
||||
以下内容当前不纳入本轮编码:
|
||||
|
||||
- 产品版本
|
||||
- 产品路线图
|
||||
- 正式评审流
|
||||
- Flowable 引擎接入实现
|
||||
- 产品基线
|
||||
- 产品文档与附件
|
||||
- 工单状态回写
|
||||
- 目标版本字段
|
||||
- 完整链路视图页面
|
||||
|
||||
## 6. 当前现状与目标口径差异
|
||||
|
||||
`rdms_biz_audit_log.sql` 当前仍存在以下差异:
|
||||
|
||||
- `rdms_product_requirement` 仍使用 `status`,尚未切到 `status_code`
|
||||
- 主表仍保留 `closed_reason`、`closed_time`
|
||||
- 主表尚未补齐 `terminal_action_code`、`terminal_reason`、`terminal_time`
|
||||
- 主表尚未补齐 `parent_requirement_id`、`root_requirement_id`
|
||||
- 产品需求状态模型和状态流转种子尚未按 `product_requirement` 完整落齐
|
||||
|
||||
这意味着:
|
||||
|
||||
- 不能直接以当前 `rdms_biz_audit_log.sql` 作为产品需求最终结构开始编码。
|
||||
- 如果进入正式开发,优先动作之一是先同步当前统一 SQL 文件,再同步 DO、Mapper、Service、Controller、接口 VO。
|
||||
|
||||
## 7. 编码前建议执行顺序
|
||||
|
||||
1. 先对齐 `02-产品管理_业务设计.md` 和 `02-产品管理_SQL已确认口径.md`
|
||||
2. 再对齐 `rdms_biz_audit_log.sql` 与已确认 SQL 口径
|
||||
3. 再开始补 DO、Mapper、Service、Controller、ReqVO、RespVO
|
||||
4. 最后对齐权限、审计、状态流转和接口返回字段
|
||||
|
||||
## 8. 编码时禁止自由发挥的点
|
||||
|
||||
- 不要把产品需求状态继续做成 `tinyint` 枚举字段。
|
||||
- 不要把来源追溯和需求拆分混在同一组字段里。
|
||||
- 不要把 `close` 再拆回独立接口。
|
||||
- 不要把状态动作塞进通用编辑接口。
|
||||
- 不要在本轮直接引入 Flowable 落地代码。
|
||||
- 不要在产品模块里扩展未确认的版本、路线图、附件等能力。
|
||||
@@ -1,130 +0,0 @@
|
||||
# 05-产品管理 当前开发完成度清单
|
||||
|
||||
## 0. 文档定位
|
||||
|
||||
本文档只回答 3 件事:
|
||||
|
||||
- 当前产品管理后端已经做了什么
|
||||
- 当前产品管理后端还有什么没做
|
||||
- 前端现在到底能调哪一段,不能把哪一段当成已完成
|
||||
|
||||
说明:
|
||||
|
||||
- 本文档以当前代码实际状态为准,不写历史方案,不写计划性口径。
|
||||
- 本文档当前只覆盖 `rdms-project/rdms-project-boot` 下的产品管理后端实现现状。
|
||||
- 本文档中的“已完成”表示代码已实现并已静态核对,不表示已经执行编译、测试或联调。
|
||||
|
||||
## 1. 当前已完成
|
||||
|
||||
### 1.1 已完成的接口
|
||||
|
||||
当前产品主数据以下 6 个接口已完成代码实现:
|
||||
|
||||
- `GET /project/product/page`
|
||||
- `GET /project/product/get`
|
||||
- `POST /project/product/create`
|
||||
- `PUT /project/product/update`
|
||||
- `POST /project/product/change-status`
|
||||
- `POST /project/product/delete`
|
||||
|
||||
### 1.2 已完成的主数据能力
|
||||
|
||||
围绕产品主数据,当前已完成以下后端能力:
|
||||
|
||||
- 产品分页查询
|
||||
- 产品详情查询
|
||||
- 创建产品
|
||||
- 更新产品
|
||||
- 产品状态变更
|
||||
- 删除产品
|
||||
|
||||
### 1.3 已完成的服务端校验
|
||||
|
||||
当前已补齐以下校验:
|
||||
|
||||
- 产品存在性校验
|
||||
- 产品编码未删除范围唯一校验
|
||||
- 产品名称未删除范围唯一校验
|
||||
- 产品经理用户有效性校验
|
||||
- 产品编码创建后不可修改校验
|
||||
- 产品状态动作必须命中 `rdms_object_status_transition` 校验
|
||||
- 状态动作原因是否必填校验
|
||||
- 删除时产品名称二次确认一致校验
|
||||
|
||||
### 1.4 已完成的状态与留痕能力
|
||||
|
||||
当前已补齐以下状态处理和留痕:
|
||||
|
||||
- 创建时默认状态写入 `active`
|
||||
- 未传产品编码时由服务端自动生成编码,格式按 `CNPDYYYYNNN` 处理
|
||||
- 状态变更按 `action_code` 驱动,不允许直接透传目标状态
|
||||
- 状态变更后同步回写 `rdms_product.status_code`
|
||||
- 状态变更后同步回写 `rdms_product.last_status_reason`
|
||||
- 产品状态动作写入 `rdms_product_status_log`
|
||||
- 创建、编辑、状态变更、删除写入 `rdms_biz_audit_log`
|
||||
|
||||
### 1.5 已补齐的支撑代码
|
||||
|
||||
当前已补齐以下代码支撑:
|
||||
|
||||
- 产品域错误码常量
|
||||
- `rdms_biz_audit_log` 对应 DO / Mapper
|
||||
- `rdms_product_status_log` 对应 DO / Mapper
|
||||
- `ProductMapper` 中产品编码前缀查询能力
|
||||
- `ObjectStatusTransitionMapper` 中仅按启用流转配置查询
|
||||
|
||||
## 2. 当前未完成
|
||||
|
||||
以下内容当前还没有开发完成,不能视为“产品管理已完成”:
|
||||
|
||||
- 产品团队
|
||||
- 产品需求
|
||||
- 关联项目
|
||||
- 最近动态 / `activities`
|
||||
- 产品上下文 / `context`
|
||||
- 对象级导航与按钮权限
|
||||
- 产品团队维护时的 `rdms_user_object_role` 动态写入
|
||||
- 团队维护引起的产品经理关系同步
|
||||
|
||||
## 3. 当前已确认不做
|
||||
|
||||
以下内容已按当前口径确认,本阶段不做,不再视为当前主数据闭环缺口:
|
||||
|
||||
- 创建产品时不写 `rdms_user_object_role`
|
||||
- `rdms_user_object_role` 由后续产品团队维护时动态落库
|
||||
- `pause` / `archive` / `abandon` / `delete` 当前不做关联项目、执行、任务阻塞校验
|
||||
|
||||
## 4. 前端现在可联调范围
|
||||
|
||||
前端当前可以开始联调的范围,仅限“产品主数据最小闭环”:
|
||||
|
||||
- 产品列表
|
||||
- 产品详情
|
||||
- 新建产品
|
||||
- 编辑产品
|
||||
- 产品状态变更
|
||||
- 删除产品
|
||||
|
||||
前端当前不应开始联调整个“产品管理”模块,尤其不应把以下内容当成可用:
|
||||
|
||||
- 产品团队
|
||||
- 产品需求
|
||||
- 关联项目
|
||||
- 最近动态
|
||||
- 产品上下文能力
|
||||
|
||||
## 5. 当前结论
|
||||
|
||||
当前状态不是“产品管理开发完毕”,而是:
|
||||
|
||||
- 产品主数据最小闭环已完成代码实现
|
||||
- 整个产品管理仍有明显未完成范围
|
||||
- 前端现在可以先调产品主数据 6 个接口
|
||||
|
||||
联调前仍需单独确认权限是否齐备,当前主数据接口涉及权限码:
|
||||
|
||||
- `project:product:query`
|
||||
- `project:product:create`
|
||||
- `project:product:update`
|
||||
- `project:product:status`
|
||||
- `project:product:delete`
|
||||
@@ -1,536 +0,0 @@
|
||||
# 06-产品主数据 API 接口文档
|
||||
|
||||
## 0. 文档说明
|
||||
|
||||
本文档用于提供“产品主数据最小闭环”当前已完成接口的标准联调口径,供前端直接调试。
|
||||
|
||||
当前文档只覆盖以下 6 个接口:
|
||||
|
||||
- `GET /project/product/page`
|
||||
- `GET /project/product/get`
|
||||
- `POST /project/product/create`
|
||||
- `PUT /project/product/update`
|
||||
- `POST /project/product/change-status`
|
||||
- `POST /project/product/delete`
|
||||
|
||||
说明:
|
||||
|
||||
- 本文档以当前代码实现为准。
|
||||
- 本文档不覆盖产品团队、产品需求、关联项目、最近动态、产品上下文等未完成能力。
|
||||
- 本文档中的返回示例为标准结构示例,不代表数据库中的真实数据。
|
||||
- 当前仅做静态对齐,未执行编译、启动和联调验证。
|
||||
|
||||
## 1. 接口基础信息
|
||||
|
||||
### 1.1 访问前缀
|
||||
|
||||
当前 Controller 暴露前缀为:
|
||||
|
||||
```text
|
||||
/project/product
|
||||
```
|
||||
|
||||
### 1.2 认证与权限
|
||||
|
||||
默认沿用当前系统 OAuth2 / Token 认证链路。
|
||||
|
||||
请求头建议:
|
||||
|
||||
```http
|
||||
Authorization: Bearer {accessToken}
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
各接口所需权限如下:
|
||||
|
||||
| 接口 | 权限码 |
|
||||
|---|---|
|
||||
| `GET /project/product/page` | `project:product:query` |
|
||||
| `GET /project/product/get` | `project:product:query` |
|
||||
| `POST /project/product/create` | `project:product:create` |
|
||||
| `PUT /project/product/update` | `project:product:update` |
|
||||
| `POST /project/product/change-status` | `project:product:status` |
|
||||
| `POST /project/product/delete` | `project:product:delete` |
|
||||
|
||||
### 1.3 统一返回结构
|
||||
|
||||
所有接口统一返回 `CommonResult<T>`:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "",
|
||||
"data": {}
|
||||
}
|
||||
```
|
||||
|
||||
字段说明:
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| `code` | `number` | 业务返回码,成功固定为 `0` |
|
||||
| `msg` | `string` | 返回消息,成功时通常为空字符串 |
|
||||
| `data` | `object / array / boolean / number / null` | 业务数据 |
|
||||
|
||||
### 1.4 分页返回结构
|
||||
|
||||
分页接口 `data` 统一为:
|
||||
|
||||
```json
|
||||
{
|
||||
"total": 1,
|
||||
"list": []
|
||||
}
|
||||
```
|
||||
|
||||
字段说明:
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| `total` | `number` | 总记录数 |
|
||||
| `list` | `array` | 当前页数据列表 |
|
||||
|
||||
### 1.5 日期时间格式
|
||||
|
||||
当前接口中的日期时间字段统一按下面格式处理:
|
||||
|
||||
```text
|
||||
yyyy-MM-dd HH:mm:ss
|
||||
```
|
||||
|
||||
例如:
|
||||
|
||||
```text
|
||||
2026-04-18 15:30:00
|
||||
```
|
||||
|
||||
## 2. 产品对象字段说明
|
||||
|
||||
产品详情与分页列表当前返回字段一致,对应 `ProductRespVO`。
|
||||
|
||||
| 字段 | 类型 | 必返 | 说明 |
|
||||
|---|---|---|---|
|
||||
| `id` | `number` | 是 | 产品主键 ID |
|
||||
| `code` | `string` | 是 | 产品编码 |
|
||||
| `directionCode` | `string` | 是 | 产品方向字典值 |
|
||||
| `name` | `string` | 是 | 产品名称 |
|
||||
| `managerUserId` | `number` | 是 | 产品经理用户 ID |
|
||||
| `description` | `string` | 否 | 产品描述 |
|
||||
| `statusCode` | `string` | 是 | 产品状态编码 |
|
||||
| `lastStatusReason` | `string` | 否 | 最近一次状态动作原因 |
|
||||
| `remark` | `string` | 否 | 备注 |
|
||||
| `createTime` | `string` | 是 | 创建时间 |
|
||||
| `updateTime` | `string` | 是 | 更新时间 |
|
||||
|
||||
## 3. 通用业务口径
|
||||
|
||||
### 3.1 产品方向
|
||||
|
||||
`directionCode` 使用系统字典 `rdms_product_direction` 的 `value`。
|
||||
|
||||
当前设计文档中的推荐初始值为:
|
||||
|
||||
- `embedded`
|
||||
- `power_electronics`
|
||||
- `system_group`
|
||||
|
||||
### 3.2 产品编码
|
||||
|
||||
- 创建时 `code` 可传可不传。
|
||||
- 如果创建时不传 `code`,后端自动生成,格式为 `CNPDYYYYNNN`。
|
||||
- 更新时不允许修改 `code`。
|
||||
|
||||
### 3.3 产品状态
|
||||
|
||||
当前产品主数据接口涉及的状态编码:
|
||||
|
||||
- `active`
|
||||
- `paused`
|
||||
- `archived`
|
||||
- `abandoned`
|
||||
|
||||
### 3.4 状态动作
|
||||
|
||||
`POST /project/product/change-status` 当前仅支持以下动作:
|
||||
|
||||
- `pause`
|
||||
- `resume`
|
||||
- `archive`
|
||||
- `abandon`
|
||||
|
||||
动作驱动规则:
|
||||
|
||||
- 前端传 `actionCode`
|
||||
- 后端按 `rdms_object_status_transition` 校验是否允许流转
|
||||
- 前端不能直接传目标状态编码
|
||||
|
||||
### 3.5 当前编辑限制
|
||||
|
||||
当前代码口径下:
|
||||
|
||||
- `archived`、`abandoned` 状态不允许编辑
|
||||
- `paused` 状态下,仅允许调整 `managerUserId`、`description`、`remark`
|
||||
- `paused` 状态下不允许修改 `directionCode`、`name`
|
||||
|
||||
## 4. 接口明细
|
||||
|
||||
## 4.1 获取产品分页
|
||||
|
||||
### 接口信息
|
||||
|
||||
| 项目 | 内容 |
|
||||
|---|---|
|
||||
| 请求方式 | `GET` |
|
||||
| 接口路径 | `/project/product/page` |
|
||||
| 权限码 | `project:product:query` |
|
||||
|
||||
### 请求参数
|
||||
|
||||
| 参数 | 位置 | 类型 | 必填 | 说明 |
|
||||
|---|---|---|---|---|
|
||||
| `pageNo` | query | `number` | 是 | 页码,从 `1` 开始 |
|
||||
| `pageSize` | query | `number` | 是 | 每页条数,最大 `200` |
|
||||
| `keyword` | query | `string` | 否 | 关键词,匹配产品编码或产品名称 |
|
||||
| `directionCode` | query | `string` | 否 | 产品方向字典值 |
|
||||
| `managerUserId` | query | `number` | 否 | 产品经理用户 ID |
|
||||
| `statusCode` | query | `string` | 否 | 产品状态编码 |
|
||||
| `updateTime` | query | `string[]` | 否 | 更新时间区间,建议传两个同名参数 |
|
||||
|
||||
`updateTime` 示例:
|
||||
|
||||
```text
|
||||
/project/product/page?pageNo=1&pageSize=10&updateTime=2026-04-01 00:00:00&updateTime=2026-04-30 23:59:59
|
||||
```
|
||||
|
||||
### 请求示例
|
||||
|
||||
```http
|
||||
GET /project/product/page?pageNo=1&pageSize=10&keyword=RDMS&statusCode=active
|
||||
```
|
||||
|
||||
### 成功返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "",
|
||||
"data": {
|
||||
"total": 2,
|
||||
"list": [
|
||||
{
|
||||
"id": 3200000000001,
|
||||
"code": "CNPD2026001",
|
||||
"directionCode": "embedded",
|
||||
"name": "RDMS产品平台",
|
||||
"managerUserId": 1024,
|
||||
"description": "面向研发管理的一体化产品",
|
||||
"statusCode": "active",
|
||||
"lastStatusReason": null,
|
||||
"remark": "首批试点产品",
|
||||
"createTime": "2026-04-18 09:30:00",
|
||||
"updateTime": "2026-04-18 09:30:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 4.2 获取产品详情
|
||||
|
||||
### 接口信息
|
||||
|
||||
| 项目 | 内容 |
|
||||
|---|---|
|
||||
| 请求方式 | `GET` |
|
||||
| 接口路径 | `/project/product/get` |
|
||||
| 权限码 | `project:product:query` |
|
||||
|
||||
### 请求参数
|
||||
|
||||
| 参数 | 位置 | 类型 | 必填 | 说明 |
|
||||
|---|---|---|---|---|
|
||||
| `id` | query | `number` | 是 | 产品 ID |
|
||||
|
||||
### 请求示例
|
||||
|
||||
```http
|
||||
GET /project/product/get?id=3200000000001
|
||||
```
|
||||
|
||||
### 成功返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "",
|
||||
"data": {
|
||||
"id": 3200000000001,
|
||||
"code": "CNPD2026001",
|
||||
"directionCode": "embedded",
|
||||
"name": "RDMS产品平台",
|
||||
"managerUserId": 1024,
|
||||
"description": "面向研发管理的一体化产品",
|
||||
"statusCode": "active",
|
||||
"lastStatusReason": null,
|
||||
"remark": "首批试点产品",
|
||||
"createTime": "2026-04-18 09:30:00",
|
||||
"updateTime": "2026-04-18 09:30:00"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 4.3 创建产品
|
||||
|
||||
### 接口信息
|
||||
|
||||
| 项目 | 内容 |
|
||||
|---|---|
|
||||
| 请求方式 | `POST` |
|
||||
| 接口路径 | `/project/product/create` |
|
||||
| 权限码 | `project:product:create` |
|
||||
|
||||
### 请求体字段
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
|---|---|---|---|
|
||||
| `id` | `number` | 否 | 创建时不需要传 |
|
||||
| `code` | `string` | 否 | 产品编码;为空时后端自动生成 |
|
||||
| `directionCode` | `string` | 是 | 产品方向字典值 |
|
||||
| `name` | `string` | 是 | 产品名称 |
|
||||
| `managerUserId` | `number` | 是 | 产品经理用户 ID |
|
||||
| `description` | `string` | 否 | 产品描述 |
|
||||
| `remark` | `string` | 否 | 备注 |
|
||||
|
||||
### 请求示例
|
||||
|
||||
```json
|
||||
{
|
||||
"directionCode": "embedded",
|
||||
"name": "RDMS产品平台",
|
||||
"managerUserId": 1024,
|
||||
"description": "面向研发管理的一体化产品",
|
||||
"remark": "首批试点产品"
|
||||
}
|
||||
```
|
||||
|
||||
### 成功返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "",
|
||||
"data": 3200000000001
|
||||
}
|
||||
```
|
||||
|
||||
### 当前服务端规则
|
||||
|
||||
- `name` 必填,长度最大 `128`
|
||||
- `directionCode` 必填,长度最大 `32`
|
||||
- `managerUserId` 必填
|
||||
- `code` 最大长度 `64`
|
||||
- `remark` 最大长度 `500`
|
||||
- 产品编码未删除范围唯一
|
||||
- 产品名称未删除范围唯一
|
||||
- 产品经理必须是有效用户
|
||||
- 创建成功后默认状态为 `active`
|
||||
|
||||
## 4.4 更新产品
|
||||
|
||||
### 接口信息
|
||||
|
||||
| 项目 | 内容 |
|
||||
|---|---|
|
||||
| 请求方式 | `PUT` |
|
||||
| 接口路径 | `/project/product/update` |
|
||||
| 权限码 | `project:product:update` |
|
||||
|
||||
### 请求体字段
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
|---|---|---|---|
|
||||
| `id` | `number` | 是 | 产品 ID |
|
||||
| `code` | `string` | 否 | 如传入,必须与原产品编码一致 |
|
||||
| `directionCode` | `string` | 是 | 产品方向字典值 |
|
||||
| `name` | `string` | 是 | 产品名称 |
|
||||
| `managerUserId` | `number` | 是 | 产品经理用户 ID |
|
||||
| `description` | `string` | 否 | 产品描述 |
|
||||
| `remark` | `string` | 否 | 备注 |
|
||||
|
||||
### 请求示例
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 3200000000001,
|
||||
"code": "CNPD2026001",
|
||||
"directionCode": "embedded",
|
||||
"name": "RDMS产品平台",
|
||||
"managerUserId": 2048,
|
||||
"description": "更新后的产品描述",
|
||||
"remark": "已切换负责人"
|
||||
}
|
||||
```
|
||||
|
||||
### 成功返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "",
|
||||
"data": true
|
||||
}
|
||||
```
|
||||
|
||||
### 当前服务端规则
|
||||
|
||||
- `id` 必传
|
||||
- 产品必须存在
|
||||
- 产品经理必须是有效用户
|
||||
- 产品编码不允许修改
|
||||
- 产品名称未删除范围唯一
|
||||
- `archived`、`abandoned` 状态不允许编辑
|
||||
- `paused` 状态仅允许调整 `managerUserId`、`description`、`remark`
|
||||
|
||||
## 4.5 变更产品状态
|
||||
|
||||
### 接口信息
|
||||
|
||||
| 项目 | 内容 |
|
||||
|---|---|
|
||||
| 请求方式 | `POST` |
|
||||
| 接口路径 | `/project/product/change-status` |
|
||||
| 权限码 | `project:product:status` |
|
||||
|
||||
### 请求体字段
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
|---|---|---|---|
|
||||
| `id` | `number` | 是 | 产品 ID |
|
||||
| `actionCode` | `string` | 是 | 动作编码 |
|
||||
| `reason` | `string` | 否 | 动作原因;是否必填由流转配置决定 |
|
||||
|
||||
### `actionCode` 当前支持值
|
||||
|
||||
| `actionCode` | 含义 | 当前典型流转 | 原因是否必填 |
|
||||
|---|---|---|---|
|
||||
| `pause` | 暂停 | `active -> paused` | 是 |
|
||||
| `resume` | 恢复 | `paused -> active` | 否 |
|
||||
| `archive` | 归档 | `active / paused -> archived` | 是 |
|
||||
| `abandon` | 废弃 | `active / paused -> abandoned` | 是 |
|
||||
|
||||
### 请求示例
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 3200000000001,
|
||||
"actionCode": "pause",
|
||||
"reason": "当前阶段资源受限,先暂停推进"
|
||||
}
|
||||
```
|
||||
|
||||
### 成功返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "",
|
||||
"data": true
|
||||
}
|
||||
```
|
||||
|
||||
### 当前服务端规则
|
||||
|
||||
- 产品必须存在
|
||||
- 动作必须命中 `rdms_object_status_transition`
|
||||
- 前端不能直接传目标状态
|
||||
- 若当前流转配置要求必须填写原因,则 `reason` 必填
|
||||
- 状态变更后会同步回写:
|
||||
- `rdms_product.status_code`
|
||||
- `rdms_product.last_status_reason`
|
||||
- 状态变更后会写入:
|
||||
- `rdms_product_status_log`
|
||||
- `rdms_biz_audit_log`
|
||||
|
||||
## 4.6 删除产品
|
||||
|
||||
### 接口信息
|
||||
|
||||
| 项目 | 内容 |
|
||||
|---|---|
|
||||
| 请求方式 | `POST` |
|
||||
| 接口路径 | `/project/product/delete` |
|
||||
| 权限码 | `project:product:delete` |
|
||||
|
||||
### 请求体字段
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
|---|---|---|---|
|
||||
| `id` | `number` | 是 | 产品 ID |
|
||||
| `productName` | `string` | 是 | 二次确认输入的产品名称 |
|
||||
| `reason` | `string` | 是 | 删除原因 |
|
||||
|
||||
### 请求示例
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 3200000000001,
|
||||
"productName": "RDMS产品平台",
|
||||
"reason": "产品录入错误,需重新创建"
|
||||
}
|
||||
```
|
||||
|
||||
### 成功返回示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "",
|
||||
"data": true
|
||||
}
|
||||
```
|
||||
|
||||
### 当前服务端规则
|
||||
|
||||
- 产品必须存在
|
||||
- `productName` 必须与当前产品名称完全一致
|
||||
- `reason` 必填
|
||||
- 当前删除实现为逻辑删除
|
||||
- 删除后会写入:
|
||||
- `rdms_product_status_log`
|
||||
- `rdms_biz_audit_log`
|
||||
|
||||
## 5. 业务错误码
|
||||
|
||||
当前产品主数据接口已使用的产品域错误码如下:
|
||||
|
||||
| 错误码 | 常量 | 含义 |
|
||||
|---|---|---|
|
||||
| `1008001000` | `PRODUCT_NOT_EXISTS` | 产品不存在 |
|
||||
| `1008001001` | `PRODUCT_CODE_DUPLICATE` | 已存在相同产品编码 |
|
||||
| `1008001002` | `PRODUCT_NAME_DUPLICATE` | 已存在相同产品名称 |
|
||||
| `1008001003` | `PRODUCT_CODE_NOT_MODIFIABLE` | 产品编码创建后不允许修改 |
|
||||
| `1008001004` | `PRODUCT_STATUS_ACTION_NOT_ALLOWED` | 当前状态不支持指定动作 |
|
||||
| `1008001005` | `PRODUCT_STATUS_ACTION_REASON_REQUIRED` | 当前动作必须填写原因 |
|
||||
| `1008001006` | `PRODUCT_DELETE_NAME_MISMATCH` | 删除确认名称与当前产品名称不一致 |
|
||||
| `1008001007` | `PRODUCT_STATUS_NOT_ALLOW_EDIT` | 当前产品状态不允许编辑 |
|
||||
| `1008001008` | `PRODUCT_PAUSED_ONLY_ALLOW_LIMITED_UPDATE` | 产品暂停后仅允许变更产品经理、描述和备注 |
|
||||
|
||||
此外还可能返回全局错误码:
|
||||
|
||||
| 错误码 | 含义 |
|
||||
|---|---|
|
||||
| `0` | 成功 |
|
||||
| `400` | 请求参数不正确 |
|
||||
| `401` | 账号未登录 |
|
||||
| `403` | 没有该操作权限 |
|
||||
| `500` | 系统异常 |
|
||||
|
||||
## 6. 联调注意事项
|
||||
|
||||
当前前端联调时请注意:
|
||||
|
||||
- 当前只联调产品主数据,不要把产品团队、产品需求、关联项目等能力一起接入。
|
||||
- 创建产品时不写 `rdms_user_object_role`,产品团队关系留待后续团队维护接口处理。
|
||||
- `pause` / `archive` / `abandon` / `delete` 当前不做关联项目、执行、任务阻塞校验。
|
||||
- 若联调账号缺少权限,会直接返回 `403`。
|
||||
- 若产品方向字典值未准备好,创建和更新接口会触发字典校验失败。
|
||||
@@ -1,287 +0,0 @@
|
||||
/*
|
||||
产品管理初始化 SQL
|
||||
|
||||
说明:
|
||||
1. 本文件作为当前产品管理唯一执行 SQL。
|
||||
2. 产品方向 `direction_code` 统一存系统字典 `value`;系统字典数据本文件不重复创建。
|
||||
3. 产品与产品需求状态统一走状态编码模型。
|
||||
4. 产品需求当前先按已确认状态集落库;补齐流转动作码 `start_execution`、`accept`。
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for rdms_biz_audit_log
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `rdms_biz_audit_log`;
|
||||
CREATE TABLE `rdms_biz_audit_log` (
|
||||
`id` bigint NOT NULL COMMENT '主键ID',
|
||||
`biz_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '业务对象类型(如:product、product_requirement、rdms_user_object_role、project、project_requirement、execution、task)',
|
||||
`biz_id` bigint NOT NULL COMMENT '业务对象ID',
|
||||
`action_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '动作类型(如:create、update、change_manager、add_member、remove_member、claim、split、dispatch、reject、cancel、close、start_execution、accept、export)',
|
||||
`from_status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '原状态',
|
||||
`to_status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '目标状态',
|
||||
`field_changes` json NULL COMMENT '关键字段变更摘要(用于负责人变更、成员调整等)',
|
||||
`reason` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '动作原因或说明',
|
||||
`operator_user_id` bigint NOT NULL COMMENT '操作人用户ID',
|
||||
`operator_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '操作人名称快照',
|
||||
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `idx_rdms_biz_audit_log_biz_deleted`(`biz_type` ASC, `biz_id` ASC, `deleted` ASC) USING BTREE COMMENT '业务对象索引',
|
||||
INDEX `idx_rdms_biz_audit_log_action_deleted`(`action_type` ASC, `deleted` ASC) USING BTREE COMMENT '动作类型索引',
|
||||
INDEX `idx_rdms_biz_audit_log_operator_deleted`(`operator_user_id` ASC, `deleted` ASC) USING BTREE COMMENT '操作人索引',
|
||||
INDEX `idx_rdms_biz_audit_log_create_time`(`create_time` ASC) USING BTREE COMMENT '创建时间索引'
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'RDMS通用业务审计日志表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for rdms_object_status_model
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `rdms_object_status_model`;
|
||||
CREATE TABLE `rdms_object_status_model` (
|
||||
`id` bigint NOT NULL COMMENT '主键ID',
|
||||
`object_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '对象类型(product、project、product_requirement、project_requirement、execution、task)',
|
||||
`status_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '状态编码',
|
||||
`status_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '状态名称',
|
||||
`sort` int NOT NULL DEFAULT 0 COMMENT '排序值',
|
||||
`status` tinyint NOT NULL DEFAULT 0 COMMENT '配置状态(0启用 1停用)',
|
||||
`initial_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否初始状态',
|
||||
`terminal_flag` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否终态',
|
||||
`allow_edit` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否允许编辑对象主数据',
|
||||
`allow_create_project` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否允许新建项目',
|
||||
`allow_create_requirement` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否允许新增需求',
|
||||
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_rdms_object_status_model_object_status_deleted`(`object_type` ASC, `status_code` ASC, `deleted` ASC) USING BTREE COMMENT '对象状态编码未删除范围唯一',
|
||||
INDEX `idx_rdms_object_status_model_object_sort_deleted`(`object_type` ASC, `sort` ASC, `deleted` ASC) USING BTREE COMMENT '对象状态排序索引',
|
||||
INDEX `idx_rdms_object_status_model_object_terminal_deleted`(`object_type` ASC, `terminal_flag` ASC, `deleted` ASC) USING BTREE COMMENT '对象终态索引'
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'RDMS对象状态模型表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of rdms_object_status_model
|
||||
-- ----------------------------
|
||||
INSERT INTO `rdms_object_status_model` VALUES (3100000001001, 'product', 'active', '启用', 10, 0, b'1', b'0', b'1', b'1', b'1', '产品正常可用状态', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_model` VALUES (3100000001002, 'product', 'paused', '暂停', 20, 0, b'0', b'0', b'1', b'0', b'0', '受环境或资源限制临时暂停推进', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_model` VALUES (3100000001003, 'product', 'archived', '归档', 30, 0, b'0', b'1', b'0', b'0', b'0', '历史留存,只读为主', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_model` VALUES (3100000001004, 'product', 'abandoned', '废弃', 40, 0, b'0', b'1', b'0', b'0', b'0', '确认不再继续推进', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_model` VALUES (3100000001201, 'product_requirement', 'pending_confirm', '待确认', 10, 0, b'1', b'0', b'0', b'0', b'0', '工单流转到产品侧后的初始状态', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_model` VALUES (3100000001202, 'product_requirement', 'pending_process', '待处理', 20, 0, b'1', b'0', b'1', b'0', b'0', '手工新增后的默认状态', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_model` VALUES (3100000001203, 'product_requirement', 'pending_review', '待评审', 30, 0, b'0', b'0', b'1', b'0', b'0', '待产品侧完成业务评审判断', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_model` VALUES (3100000001204, 'product_requirement', 'pending_dispatch', '待分流', 40, 0, b'0', b'0', b'1', b'0', b'0', '需求成立,等待明确承接方向', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_model` VALUES (3100000001205, 'product_requirement', 'dispatched', '已分流', 50, 0, b'0', b'0', b'1', b'0', b'0', '已明确承接方向', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_model` VALUES (3100000001206, 'product_requirement', 'in_progress', '实施中', 60, 0, b'0', b'0', b'1', b'0', b'0', '承接项目已进入正式执行', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_model` VALUES (3100000001207, 'product_requirement', 'accepted', '已验收', 70, 0, b'0', b'0', b'1', b'0', b'0', '承接结果已完成验收', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_model` VALUES (3100000001208, 'product_requirement', 'closed', '已关闭', 80, 0, b'0', b'1', b'0', b'0', b'0', '生命周期闭环完成', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_model` VALUES (3100000001209, 'product_requirement', 'rejected', '已拒绝', 90, 0, b'0', b'1', b'0', b'0', b'0', '需求确认不成立或产品侧不接收', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_model` VALUES (3100000001210, 'product_requirement', 'canceled', '已取消', 100, 0, b'0', b'1', b'0', b'0', b'0', '推进过程中终止', '', NOW(), '', NOW(), b'0');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for rdms_object_status_transition
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `rdms_object_status_transition`;
|
||||
CREATE TABLE `rdms_object_status_transition` (
|
||||
`id` bigint NOT NULL COMMENT '主键ID',
|
||||
`object_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '对象类型(product、project、product_requirement、project_requirement、execution、task)',
|
||||
`action_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '动作编码(pause、resume、archive、abandon、claim、to_review、to_dispatch、dispatch、start_execution、accept、reject、cancel、close)',
|
||||
`action_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '动作名称',
|
||||
`from_status_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '起始状态编码',
|
||||
`to_status_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '目标状态编码',
|
||||
`need_reason` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否必须填写原因(1必须 0非必须)',
|
||||
`status` tinyint NOT NULL DEFAULT 0 COMMENT '配置状态(0启用 1停用)',
|
||||
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_rdms_object_status_transition_object_from_action_deleted`(`object_type` ASC, `from_status_code` ASC, `action_code` ASC, `deleted` ASC) USING BTREE COMMENT '对象起始状态动作未删除范围唯一',
|
||||
INDEX `idx_rdms_object_status_transition_object_from_deleted`(`object_type` ASC, `from_status_code` ASC, `status` ASC, `deleted` ASC) USING BTREE COMMENT '对象起始状态流转索引',
|
||||
INDEX `idx_rdms_object_status_transition_object_to_deleted`(`object_type` ASC, `to_status_code` ASC, `status` ASC, `deleted` ASC) USING BTREE COMMENT '对象目标状态流转索引'
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'RDMS对象状态流转表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of rdms_object_status_transition
|
||||
-- ----------------------------
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001101, 'product', 'pause', '暂停', 'active', 'paused', b'1', 0, '启用转暂停', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001102, 'product', 'resume', '恢复', 'paused', 'active', b'0', 0, '暂停恢复启用', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001103, 'product', 'archive', '归档', 'active', 'archived', b'1', 0, '启用转归档', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001104, 'product', 'archive', '归档', 'paused', 'archived', b'1', 0, '暂停转归档', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001105, 'product', 'abandon', '废弃', 'active', 'abandoned', b'1', 0, '启用转废弃', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001106, 'product', 'abandon', '废弃', 'paused', 'abandoned', b'1', 0, '暂停转废弃', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001301, 'product_requirement', 'claim', '认领', 'pending_confirm', 'pending_process', b'0', 0, '待确认转待处理', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001302, 'product_requirement', 'reject', '拒绝', 'pending_confirm', 'rejected', b'1', 0, '待确认转已拒绝', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001303, 'product_requirement', 'cancel', '取消', 'pending_confirm', 'canceled', b'1', 0, '待确认转已取消', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001304, 'product_requirement', 'to_review', '转待评审', 'pending_process', 'pending_review', b'0', 0, '待处理转待评审', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001305, 'product_requirement', 'to_dispatch', '转待分流', 'pending_process', 'pending_dispatch', b'0', 0, '待处理转待分流', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001306, 'product_requirement', 'reject', '拒绝', 'pending_process', 'rejected', b'1', 0, '待处理转已拒绝', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001307, 'product_requirement', 'cancel', '取消', 'pending_process', 'canceled', b'1', 0, '待处理转已取消', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001308, 'product_requirement', 'to_dispatch', '转待分流', 'pending_review', 'pending_dispatch', b'0', 0, '待评审转待分流', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001309, 'product_requirement', 'reject', '拒绝', 'pending_review', 'rejected', b'1', 0, '待评审转已拒绝', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001310, 'product_requirement', 'cancel', '取消', 'pending_review', 'canceled', b'1', 0, '待评审转已取消', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001311, 'product_requirement', 'dispatch', '分流', 'pending_dispatch', 'dispatched', b'0', 0, '待分流转已分流', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001312, 'product_requirement', 'cancel', '取消', 'pending_dispatch', 'canceled', b'1', 0, '待分流转已取消', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001313, 'product_requirement', 'start_execution', '开始实施', 'dispatched', 'in_progress', b'0', 0, '已分流转实施中', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001314, 'product_requirement', 'cancel', '取消', 'dispatched', 'canceled', b'1', 0, '已分流转已取消', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001315, 'product_requirement', 'accept', '验收', 'in_progress', 'accepted', b'0', 0, '实施中转已验收', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001316, 'product_requirement', 'cancel', '取消', 'in_progress', 'canceled', b'1', 0, '实施中转已取消', '', NOW(), '', NOW(), b'0');
|
||||
INSERT INTO `rdms_object_status_transition` VALUES (3100000001317, 'product_requirement', 'close', '关闭', 'accepted', 'closed', b'1', 0, '已验收转已关闭', '', NOW(), '', NOW(), b'0');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for rdms_product
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `rdms_product`;
|
||||
CREATE TABLE `rdms_product` (
|
||||
`id` bigint NOT NULL COMMENT '主键ID',
|
||||
`code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '产品编码(格式:CNPDYYYYNNN,支持手工录入或系统自动生成)',
|
||||
`direction_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '产品方向字典值(system_dict_data.value;推荐字典类型 rdms_product_direction)',
|
||||
`status_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active' COMMENT '产品状态编码(引用 rdms_object_status_model.status_code,object_type = product)',
|
||||
`name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '产品名称',
|
||||
`manager_user_id` bigint NOT NULL COMMENT '当前产品经理用户ID(冗余读模型字段,权威来源仍为 rdms_user_object_role)',
|
||||
`description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '产品描述',
|
||||
`last_status_reason` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '最近一次状态动作原因',
|
||||
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_rdms_product_code_deleted`(`code` ASC, `deleted` ASC) USING BTREE COMMENT '产品编码未删除范围唯一',
|
||||
UNIQUE INDEX `uk_rdms_product_name_deleted`(`name` ASC, `deleted` ASC) USING BTREE COMMENT '产品名称未删除范围唯一',
|
||||
INDEX `idx_rdms_product_direction_status_code_deleted`(`direction_code` ASC, `status_code` ASC, `deleted` ASC) USING BTREE COMMENT '产品方向状态索引',
|
||||
INDEX `idx_rdms_product_manager_status_code_deleted`(`manager_user_id` ASC, `status_code` ASC, `deleted` ASC) USING BTREE COMMENT '产品经理状态索引',
|
||||
INDEX `idx_rdms_product_status_code_deleted`(`status_code` ASC, `deleted` ASC) USING BTREE COMMENT '产品状态索引',
|
||||
INDEX `idx_rdms_product_update_time`(`update_time` ASC) USING BTREE COMMENT '更新时间索引'
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '产品主表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for rdms_product_rd_order
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `rdms_product_rd_order`;
|
||||
CREATE TABLE `rdms_product_rd_order` (
|
||||
`id` bigint NOT NULL COMMENT '主键ID',
|
||||
`product_id` bigint NOT NULL COMMENT '产品ID',
|
||||
`order_year` int NOT NULL COMMENT '研发令号年度',
|
||||
`rd_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '研发令号',
|
||||
`status` tinyint NOT NULL DEFAULT 0 COMMENT '状态(0有效 1失效)',
|
||||
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_rdms_product_rd_order_product_year_deleted`(`product_id` ASC, `order_year` ASC, `deleted` ASC) USING BTREE COMMENT '同一产品同一年度未删除范围唯一',
|
||||
INDEX `idx_rdms_product_rd_order_product_status_deleted`(`product_id` ASC, `status` ASC, `deleted` ASC) USING BTREE COMMENT '产品研发令号状态索引',
|
||||
INDEX `idx_rdms_product_rd_order_no_deleted`(`rd_order_no` ASC, `deleted` ASC) USING BTREE COMMENT '研发令号检索索引',
|
||||
INDEX `idx_rdms_product_rd_order_year_deleted`(`order_year` ASC, `deleted` ASC) USING BTREE COMMENT '研发令年度索引'
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '产品研发令号表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for rdms_product_requirement
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `rdms_product_requirement`;
|
||||
CREATE TABLE `rdms_product_requirement` (
|
||||
`id` bigint NOT NULL COMMENT '主键ID',
|
||||
`product_id` bigint NOT NULL COMMENT '所属产品ID',
|
||||
`title` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '需求标题',
|
||||
`category` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '需求分类',
|
||||
`source_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '需求来源类型(如:manual、work_order)',
|
||||
`source_biz_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '来源业务类型(如:work_order)',
|
||||
`source_biz_id` bigint NULL DEFAULT NULL COMMENT '来源业务ID',
|
||||
`source_biz_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '来源业务编号',
|
||||
`root_requirement_id` bigint NULL DEFAULT NULL COMMENT '源头需求ID(同一来源链路根节点)',
|
||||
`parent_requirement_id` bigint NULL DEFAULT NULL COMMENT '直接父需求ID(拆分子需求回指父需求)',
|
||||
`priority` tinyint NOT NULL DEFAULT 1 COMMENT '优先级(0低 1中 2高 3紧急)',
|
||||
`status_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending_process' COMMENT '需求状态编码(引用 rdms_object_status_model.status_code,object_type = product_requirement)',
|
||||
`description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '需求描述',
|
||||
`proposer_id` bigint NOT NULL COMMENT '提出人用户ID',
|
||||
`current_handler_user_id` bigint NULL DEFAULT NULL COMMENT '当前处理人用户ID',
|
||||
`implement_project_id` bigint NULL DEFAULT NULL COMMENT '默认实现项目ID',
|
||||
`terminal_action_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '终态动作编码(reject、cancel、close)',
|
||||
`terminal_reason` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '终态原因',
|
||||
`terminal_time` datetime NULL DEFAULT NULL COMMENT '终态时间',
|
||||
`sort` int NOT NULL DEFAULT 0 COMMENT '排序值',
|
||||
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `idx_rdms_product_requirement_product_status_deleted`(`product_id` ASC, `status_code` ASC, `deleted` ASC) USING BTREE COMMENT '产品需求状态索引',
|
||||
INDEX `idx_rdms_product_requirement_product_source_deleted`(`product_id` ASC, `source_type` ASC, `deleted` ASC) USING BTREE COMMENT '产品需求来源索引',
|
||||
INDEX `idx_rdms_product_requirement_product_priority_deleted`(`product_id` ASC, `priority` ASC, `deleted` ASC) USING BTREE COMMENT '产品需求优先级索引',
|
||||
INDEX `idx_rdms_product_requirement_source_biz_deleted`(`source_biz_type` ASC, `source_biz_id` ASC, `deleted` ASC) USING BTREE COMMENT '来源业务索引',
|
||||
INDEX `idx_rdms_product_requirement_root_deleted`(`root_requirement_id` ASC, `deleted` ASC) USING BTREE COMMENT '源头需求索引',
|
||||
INDEX `idx_rdms_product_requirement_parent_deleted`(`parent_requirement_id` ASC, `deleted` ASC) USING BTREE COMMENT '父需求索引',
|
||||
INDEX `idx_rdms_product_requirement_handler_deleted`(`current_handler_user_id` ASC, `deleted` ASC) USING BTREE COMMENT '当前处理人索引',
|
||||
INDEX `idx_rdms_product_requirement_terminal_action_deleted`(`terminal_action_code` ASC, `deleted` ASC) USING BTREE COMMENT '终态动作索引',
|
||||
INDEX `idx_rdms_product_requirement_implement_project_deleted`(`implement_project_id` ASC, `deleted` ASC) USING BTREE COMMENT '默认实现项目索引'
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '产品需求表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for rdms_product_status_log
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `rdms_product_status_log`;
|
||||
CREATE TABLE `rdms_product_status_log` (
|
||||
`id` bigint NOT NULL COMMENT '主键ID',
|
||||
`product_id` bigint NOT NULL COMMENT '产品ID',
|
||||
`action_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '动作类型(pause、resume、archive、abandon、delete)',
|
||||
`from_status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '变更前状态编码',
|
||||
`to_status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '变更后状态编码',
|
||||
`reason` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '动作原因',
|
||||
`operator_user_id` bigint NOT NULL COMMENT '操作人用户ID',
|
||||
`operator_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '操作人名称快照',
|
||||
`product_code_snapshot` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '产品编码快照',
|
||||
`product_name_snapshot` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '产品名称快照',
|
||||
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `idx_rdms_product_status_log_product_deleted`(`product_id` ASC, `deleted` ASC) USING BTREE COMMENT '产品状态日志索引',
|
||||
INDEX `idx_rdms_product_status_log_operator_deleted`(`operator_user_id` ASC, `deleted` ASC) USING BTREE COMMENT '操作人索引',
|
||||
INDEX `idx_rdms_product_status_log_create_time`(`create_time` ASC) USING BTREE COMMENT '创建时间索引'
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '产品状态日志表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for rdms_user_object_role
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `rdms_user_object_role`;
|
||||
CREATE TABLE `rdms_user_object_role` (
|
||||
`id` bigint NOT NULL COMMENT '主键ID',
|
||||
`user_id` bigint NOT NULL COMMENT '用户ID',
|
||||
`object_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '对象类型(product、project)',
|
||||
`object_id` bigint NOT NULL COMMENT '对象ID',
|
||||
`role_id` bigint NOT NULL COMMENT '对象角色ID(指向 system_role.id,要求 scope_type = object)',
|
||||
`status` tinyint NOT NULL DEFAULT 0 COMMENT '状态(0有效 1失效;成员关系是否有效的唯一判定字段)',
|
||||
`joined_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '加入时间',
|
||||
`left_time` datetime NULL DEFAULT NULL COMMENT '退出时间,仅用于留痕,不参与权限判断',
|
||||
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_rdms_user_object_role_user_object_deleted`(`user_id` ASC, `object_type` ASC, `object_id` ASC, `deleted` ASC) USING BTREE COMMENT '用户对象关系未删除范围唯一',
|
||||
INDEX `idx_rdms_user_object_role_object_status_deleted`(`object_type` ASC, `object_id` ASC, `status` ASC, `deleted` ASC) USING BTREE COMMENT '对象成员索引',
|
||||
INDEX `idx_rdms_user_object_role_role_deleted`(`role_id` ASC, `deleted` ASC) USING BTREE COMMENT '对象角色索引',
|
||||
INDEX `idx_rdms_user_object_role_user_deleted`(`user_id` ASC, `deleted` ASC) USING BTREE COMMENT '用户索引'
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'RDMS对象成员角色关系表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
@@ -3,6 +3,7 @@ package com.njcn.rdms.module.project.controller.admin.product;
|
||||
import com.njcn.rdms.framework.common.pojo.CommonResult;
|
||||
import com.njcn.rdms.framework.common.pojo.PageResult;
|
||||
import com.njcn.rdms.framework.common.util.object.BeanUtils;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductContextRespVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductDeleteReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductPageReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductRespVO;
|
||||
@@ -39,7 +40,6 @@ public class ProductController {
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新产品")
|
||||
@PreAuthorize("@ss.hasPermission('project:product:update')")
|
||||
public CommonResult<Boolean> updateProduct(@Valid @RequestBody ProductSaveReqVO updateReqVO) {
|
||||
productService.updateProduct(updateReqVO);
|
||||
return success(true);
|
||||
@@ -48,12 +48,18 @@ public class ProductController {
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获取产品详情")
|
||||
@Parameter(name = "id", description = "产品编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('project:product:query')")
|
||||
public CommonResult<ProductRespVO> getProduct(@RequestParam("id") Long id) {
|
||||
ProductDO product = productService.getProduct(id);
|
||||
return success(BeanUtils.toBean(product, ProductRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/context")
|
||||
@Operation(summary = "获取产品上下文")
|
||||
@Parameter(name = "id", description = "产品编号", required = true, example = "1024")
|
||||
public CommonResult<ProductContextRespVO> getProductContext(@PathVariable("id") Long id) {
|
||||
return success(productService.getProductContext(id));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获取产品分页")
|
||||
@PreAuthorize("@ss.hasPermission('project:product:query')")
|
||||
@@ -64,7 +70,6 @@ public class ProductController {
|
||||
|
||||
@PostMapping("/change-status")
|
||||
@Operation(summary = "变更产品状态")
|
||||
@PreAuthorize("@ss.hasPermission('project:product:status')")
|
||||
public CommonResult<Boolean> changeProductStatus(@Valid @RequestBody ProductStatusActionReqVO reqVO) {
|
||||
productService.changeProductStatus(reqVO);
|
||||
return success(true);
|
||||
@@ -72,7 +77,6 @@ public class ProductController {
|
||||
|
||||
@PostMapping("/delete")
|
||||
@Operation(summary = "删除产品")
|
||||
@PreAuthorize("@ss.hasPermission('project:product:delete')")
|
||||
public CommonResult<Boolean> deleteProduct(@Valid @RequestBody ProductDeleteReqVO reqVO) {
|
||||
productService.deleteProduct(reqVO);
|
||||
return success(true);
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product;
|
||||
|
||||
import com.njcn.rdms.framework.common.pojo.CommonResult;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.member.ProductMemberInactiveReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.member.ProductMemberRespVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.member.ProductMemberSaveReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.member.ProductMemberUpdateReqVO;
|
||||
import com.njcn.rdms.module.project.service.product.ProductMemberService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 产品团队")
|
||||
@RestController
|
||||
@RequestMapping("/project/product")
|
||||
@Validated
|
||||
public class ProductMemberController {
|
||||
|
||||
@Resource
|
||||
private ProductMemberService productMemberService;
|
||||
|
||||
@GetMapping("/{id}/members")
|
||||
@Operation(summary = "获取产品团队成员列表")
|
||||
@Parameter(name = "id", description = "产品编号", required = true, example = "1024")
|
||||
public CommonResult<List<ProductMemberRespVO>> getProductMemberList(@PathVariable("id") Long productId) {
|
||||
return success(productMemberService.getProductMemberList(productId));
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/members")
|
||||
@Operation(summary = "新增产品团队成员")
|
||||
@Parameter(name = "id", description = "产品编号", required = true, example = "1024")
|
||||
public CommonResult<Long> createProductMember(@PathVariable("id") Long productId,
|
||||
@Valid @RequestBody ProductMemberSaveReqVO reqVO) {
|
||||
return success(productMemberService.createProductMember(productId, reqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/members/{memberId}")
|
||||
@Operation(summary = "调整产品团队成员角色")
|
||||
public CommonResult<Boolean> updateProductMember(@PathVariable("id") Long productId,
|
||||
@PathVariable("memberId") Long memberId,
|
||||
@Valid @RequestBody ProductMemberUpdateReqVO reqVO) {
|
||||
productMemberService.updateProductMember(productId, memberId, reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/members/{memberId}/inactive")
|
||||
@Operation(summary = "移出产品团队成员")
|
||||
public CommonResult<Boolean> inactiveProductMember(@PathVariable("id") Long productId,
|
||||
@PathVariable("memberId") Long memberId,
|
||||
@Valid @RequestBody ProductMemberInactiveReqVO reqVO) {
|
||||
productMemberService.inactiveProductMember(productId, memberId, reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product;
|
||||
|
||||
import com.njcn.rdms.framework.common.pojo.CommonResult;
|
||||
import com.njcn.rdms.framework.common.pojo.PageResult;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.activity.ProductActivityPageReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.activity.ProductActivityRespVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.setting.ProductSettingBaseInfoUpdateReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.setting.ProductSettingRespVO;
|
||||
import com.njcn.rdms.module.project.service.product.ProductService;
|
||||
import com.njcn.rdms.module.project.service.product.ProductSettingService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 产品设置")
|
||||
@RestController
|
||||
@RequestMapping("/project/product")
|
||||
@Validated
|
||||
public class ProductSettingController {
|
||||
|
||||
@Resource
|
||||
private ProductSettingService productSettingService;
|
||||
@Resource
|
||||
private ProductService productService;
|
||||
|
||||
@GetMapping("/{id}/settings")
|
||||
@Operation(summary = "获取产品设置")
|
||||
@Parameter(name = "id", description = "产品编号", required = true, example = "1024")
|
||||
public CommonResult<ProductSettingRespVO> getProductSettings(@PathVariable("id") Long id) {
|
||||
return success(productSettingService.getProductSettings(id));
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/activities")
|
||||
@Operation(summary = "获取产品动态")
|
||||
@Parameter(name = "id", description = "产品编号", required = true, example = "1024")
|
||||
public CommonResult<PageResult<ProductActivityRespVO>> getProductActivities(@PathVariable("id") Long id,
|
||||
@Valid ProductActivityPageReqVO reqVO) {
|
||||
return success(productSettingService.getProductActivities(id, reqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/settings/base-info")
|
||||
@Operation(summary = "更新产品设置基础信息")
|
||||
@Parameter(name = "id", description = "产品编号", required = true, example = "1024")
|
||||
public CommonResult<Boolean> updateProductBaseInfo(@PathVariable("id") Long id,
|
||||
@Valid @RequestBody ProductSettingBaseInfoUpdateReqVO reqVO) {
|
||||
productService.updateProductBaseInfo(id, reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product.vo.activity;
|
||||
|
||||
import com.njcn.rdms.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.njcn.rdms.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 产品动态分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ProductActivityPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "动态类型", example = "status")
|
||||
@Size(max = 16, message = "动态类型长度不能超过16个字符")
|
||||
private String activityType;
|
||||
|
||||
@Schema(description = "动作编码", example = "pause")
|
||||
@Size(max = 32, message = "动作编码长度不能超过32个字符")
|
||||
private String actionType;
|
||||
|
||||
@Schema(description = "操作时间区间", example = "[2026-04-01 00:00:00, 2026-04-30 23:59:59]")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] operateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product.vo.activity;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 产品动态 Response VO")
|
||||
@Data
|
||||
public class ProductActivityRespVO {
|
||||
|
||||
@Schema(description = "动态类型", example = "status")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "动作编码", example = "pause")
|
||||
private String actionType;
|
||||
|
||||
@Schema(description = "动作名称", example = "暂停")
|
||||
private String actionName;
|
||||
|
||||
@Schema(description = "原状态", example = "active")
|
||||
private String fromStatus;
|
||||
|
||||
@Schema(description = "目标状态", example = "paused")
|
||||
private String toStatus;
|
||||
|
||||
@Schema(description = "动作原因", example = "资源不足")
|
||||
private String reason;
|
||||
|
||||
@Schema(description = "操作人用户编号", example = "1024")
|
||||
private Long operatorUserId;
|
||||
|
||||
@Schema(description = "操作人名称", example = "张三")
|
||||
private String operatorName;
|
||||
|
||||
@Schema(description = "操作时间", example = "2026-04-21 12:00:00")
|
||||
private LocalDateTime operateTime;
|
||||
|
||||
@Schema(description = "展示摘要", example = "张三执行了【暂停】:资源不足")
|
||||
private String summary;
|
||||
|
||||
@Schema(description = "补充详情")
|
||||
private String details;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product.vo.member;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 产品团队成员移出 Request VO")
|
||||
@Data
|
||||
public class ProductMemberInactiveReqVO {
|
||||
|
||||
@Schema(description = "移出原因", example = "已退出当前产品协作")
|
||||
@Size(max = 500, message = "移出原因长度不能超过500个字符")
|
||||
private String reason;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product.vo.member;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 产品团队成员 Response VO")
|
||||
@Data
|
||||
public class ProductMemberRespVO {
|
||||
|
||||
@Schema(description = "团队关系编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户昵称", example = "小王")
|
||||
private String userNickname;
|
||||
|
||||
@Schema(description = "角色编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3100000002001")
|
||||
private Long roleId;
|
||||
|
||||
@Schema(description = "角色名称", example = "产品经理")
|
||||
private String roleName;
|
||||
|
||||
@Schema(description = "角色编码", example = "product_manager")
|
||||
private String roleCode;
|
||||
|
||||
@Schema(description = "是否当前产品经理", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
private Boolean managerFlag;
|
||||
|
||||
@Schema(description = "状态(0有效 1失效)", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "加入时间")
|
||||
private LocalDateTime joinedTime;
|
||||
|
||||
@Schema(description = "退出时间")
|
||||
private LocalDateTime leftTime;
|
||||
|
||||
@Schema(description = "备注", example = "当前负责需求收敛")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product.vo.member;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 产品团队成员新增 Request VO")
|
||||
@Data
|
||||
public class ProductMemberSaveReqVO {
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "用户编号不能为空")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "角色编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3100000002001")
|
||||
@NotNull(message = "角色编号不能为空")
|
||||
private Long roleId;
|
||||
|
||||
@Schema(description = "备注", example = "来自产品团队维护")
|
||||
@Size(max = 500, message = "备注长度不能超过500个字符")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "原产品经理用户编号,仅切换产品经理时传递", example = "2048")
|
||||
private Long previousManagerUserId;
|
||||
|
||||
@Schema(description = "原产品经理交接后的角色编号,仅切换产品经理时传递", example = "3100000002002")
|
||||
private Long previousManagerRoleId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product.vo.member;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 产品团队成员更新 Request VO")
|
||||
@Data
|
||||
public class ProductMemberUpdateReqVO {
|
||||
|
||||
@Schema(description = "角色编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3100000002002")
|
||||
@NotNull(message = "角色编号不能为空")
|
||||
private Long roleId;
|
||||
|
||||
@Schema(description = "备注", example = "调整为产品观察者")
|
||||
@Size(max = 500, message = "备注长度不能超过500个字符")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "变更原因", example = "职责调整")
|
||||
@Size(max = 500, message = "变更原因长度不能超过500个字符")
|
||||
private String reason;
|
||||
|
||||
@Schema(description = "原产品经理用户编号,仅切换产品经理时传递", example = "2048")
|
||||
private Long previousManagerUserId;
|
||||
|
||||
@Schema(description = "原产品经理交接后的角色编号,仅切换产品经理时传递", example = "3100000002002")
|
||||
private Long previousManagerRoleId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product.vo.product;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 产品上下文导航 Response VO")
|
||||
@Data
|
||||
public class ProductContextNavRespVO {
|
||||
|
||||
@Schema(description = "菜单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3201")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "菜单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "概览")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "菜单路径", example = "/project/product/overview")
|
||||
private String path;
|
||||
|
||||
@Schema(description = "菜单图标", example = "mdi:view-dashboard-outline")
|
||||
private String icon;
|
||||
|
||||
@Schema(description = "显示顺序", example = "10")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product.vo.product;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 产品上下文中的当前产品摘要 Response VO")
|
||||
@Data
|
||||
public class ProductContextProductRespVO {
|
||||
|
||||
@Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "CNPD2026001")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "产品方向字典值", requiredMode = Schema.RequiredMode.REQUIRED, example = "direction_value")
|
||||
private String directionCode;
|
||||
|
||||
@Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "RDMS产品平台")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "产品经理用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long managerUserId;
|
||||
|
||||
@Schema(description = "产品状态编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "active")
|
||||
private String statusCode;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product.vo.product;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 产品上下文 Response VO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class ProductContextRespVO {
|
||||
|
||||
@Schema(description = "当前产品摘要")
|
||||
private ProductContextProductRespVO currentProduct;
|
||||
|
||||
@Schema(description = "当前用户在该产品下的角色信息")
|
||||
private ProductContextRoleRespVO currentRole;
|
||||
|
||||
@Schema(description = "当前产品下可见导航集合")
|
||||
private List<ProductContextNavRespVO> navs;
|
||||
|
||||
@Schema(description = "当前产品下按钮权限码集合")
|
||||
private List<String> buttons;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product.vo.product;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 产品上下文中的当前角色 Response VO")
|
||||
@Data
|
||||
public class ProductContextRoleRespVO {
|
||||
|
||||
@Schema(description = "对象角色编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3201")
|
||||
private Long roleId;
|
||||
|
||||
@Schema(description = "对象角色编码", example = "product_manager")
|
||||
private String roleCode;
|
||||
|
||||
@Schema(description = "对象角色名称", example = "产品经理")
|
||||
private String roleName;
|
||||
|
||||
}
|
||||
@@ -24,4 +24,9 @@ public class ProductDeleteReqVO {
|
||||
@Size(max = 500, message = "删除原因长度不能超过500个字符")
|
||||
private String reason;
|
||||
|
||||
@Schema(description = "删除确认口令,当前固定输入 DELETE", requiredMode = Schema.RequiredMode.REQUIRED, example = "DELETE")
|
||||
@NotBlank(message = "删除确认口令不能为空")
|
||||
@Size(max = 32, message = "删除确认口令长度不能超过32个字符")
|
||||
private String confirmText;
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.njcn.rdms.module.project.controller.admin.product.vo.product;
|
||||
|
||||
import com.njcn.rdms.framework.common.pojo.PageParam;
|
||||
import com.njcn.rdms.framework.dict.validation.InDict;
|
||||
import com.njcn.rdms.module.project.enums.ProjectDictTypeConstants;
|
||||
import com.njcn.rdms.module.system.enums.DictTypeConstants;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
@@ -21,8 +21,8 @@ public class ProductPageReqVO extends PageParam {
|
||||
@Schema(description = "关键词,匹配产品编码或产品名称", example = "CNPD2026001")
|
||||
private String keyword;
|
||||
|
||||
@Schema(description = "产品方向字典值", example = "embedded")
|
||||
@InDict(type = ProjectDictTypeConstants.PRODUCT_DIRECTION)
|
||||
@Schema(description = "产品方向字典值", example = "direction_value")
|
||||
@InDict(type = DictTypeConstants.OBJECT_DIRECTION)
|
||||
private String directionCode;
|
||||
|
||||
@Schema(description = "产品经理用户编号", example = "1024")
|
||||
|
||||
@@ -15,7 +15,7 @@ public class ProductRespVO {
|
||||
@Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "CNPD2026001")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "产品方向字典值", requiredMode = Schema.RequiredMode.REQUIRED, example = "embedded")
|
||||
@Schema(description = "产品方向字典值", requiredMode = Schema.RequiredMode.REQUIRED, example = "direction_value")
|
||||
private String directionCode;
|
||||
|
||||
@Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "RDMS产品平台")
|
||||
@@ -33,9 +33,6 @@ public class ProductRespVO {
|
||||
@Schema(description = "最近一次状态动作原因", example = "阶段性暂停")
|
||||
private String lastStatusReason;
|
||||
|
||||
@Schema(description = "备注", example = "预留")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product.vo.product;
|
||||
|
||||
import com.njcn.rdms.framework.dict.validation.InDict;
|
||||
import com.njcn.rdms.module.project.enums.ProjectDictTypeConstants;
|
||||
import com.njcn.rdms.module.system.enums.DictTypeConstants;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@@ -19,10 +19,10 @@ public class ProductSaveReqVO {
|
||||
@Size(max = 64, message = "产品编码长度不能超过64个字符")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "产品方向字典值", requiredMode = Schema.RequiredMode.REQUIRED, example = "embedded")
|
||||
@Schema(description = "产品方向字典值", requiredMode = Schema.RequiredMode.REQUIRED, example = "direction_value")
|
||||
@NotBlank(message = "产品方向不能为空")
|
||||
@Size(max = 32, message = "产品方向长度不能超过32个字符")
|
||||
@InDict(type = ProjectDictTypeConstants.PRODUCT_DIRECTION)
|
||||
@InDict(type = DictTypeConstants.OBJECT_DIRECTION)
|
||||
private String directionCode;
|
||||
|
||||
@Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "RDMS产品平台")
|
||||
@@ -37,8 +37,4 @@ public class ProductSaveReqVO {
|
||||
@Schema(description = "产品描述", example = "面向研发管理的一体化产品")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "备注", example = "预留")
|
||||
@Size(max = 500, message = "备注长度不能超过500个字符")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product.vo.setting;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Schema(description = "管理后台 - 产品设置生命周期动作 Response VO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class ProductSettingActionRespVO {
|
||||
|
||||
@Schema(description = "动作编码", example = "archive")
|
||||
private String actionCode;
|
||||
|
||||
@Schema(description = "动作名称", example = "归档")
|
||||
private String actionName;
|
||||
|
||||
@Schema(description = "是否必须填写原因", example = "true")
|
||||
private Boolean needReason;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product.vo.setting;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Schema(description = "管理后台 - 产品设置基础信息 Response VO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class ProductSettingBaseInfoRespVO {
|
||||
|
||||
@Schema(description = "产品编号", example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "产品编码", example = "CNPD2026001")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "产品方向字典值", example = "direction_value")
|
||||
private String directionCode;
|
||||
|
||||
@Schema(description = "产品名称", example = "统一交付平台")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "产品经理用户编号", example = "10001")
|
||||
private Long managerUserId;
|
||||
|
||||
@Schema(description = "产品经理昵称", example = "张三")
|
||||
private String managerUserNickname;
|
||||
|
||||
@Schema(description = "产品描述", example = "产品描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "产品状态编码", example = "active")
|
||||
private String statusCode;
|
||||
|
||||
@Schema(description = "最近一次状态动作原因", example = "恢复正常推进")
|
||||
private String lastStatusReason;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product.vo.setting;
|
||||
|
||||
import com.njcn.rdms.framework.dict.validation.InDict;
|
||||
import com.njcn.rdms.module.system.enums.DictTypeConstants;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 产品设置基础信息更新 Request VO")
|
||||
@Data
|
||||
public class ProductSettingBaseInfoUpdateReqVO {
|
||||
|
||||
@Schema(description = "产品方向字典值", requiredMode = Schema.RequiredMode.REQUIRED, example = "direction_value")
|
||||
@NotBlank(message = "产品方向不能为空")
|
||||
@Size(max = 32, message = "产品方向长度不能超过32个字符")
|
||||
@InDict(type = DictTypeConstants.OBJECT_DIRECTION)
|
||||
private String directionCode;
|
||||
|
||||
@Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "RDMS产品平台")
|
||||
@NotBlank(message = "产品名称不能为空")
|
||||
@Size(max = 128, message = "产品名称长度不能超过128个字符")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "产品描述", example = "面向研发管理的一体化产品")
|
||||
private String description;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product.vo.setting;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 产品设置生命周期 Response VO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class ProductSettingLifecycleRespVO {
|
||||
|
||||
@Schema(description = "当前状态编码", example = "active")
|
||||
private String statusCode;
|
||||
|
||||
@Schema(description = "当前状态名称", example = "启用")
|
||||
private String statusName;
|
||||
|
||||
@Schema(description = "最近一次状态动作原因", example = "恢复正常推进")
|
||||
private String lastStatusReason;
|
||||
|
||||
@Schema(description = "是否终态", example = "false")
|
||||
private Boolean terminal;
|
||||
|
||||
@Schema(description = "是否允许编辑", example = "true")
|
||||
private Boolean allowEdit;
|
||||
|
||||
@Schema(description = "当前状态可执行动作")
|
||||
private List<ProductSettingActionRespVO> availableActions;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.rdms.module.project.controller.admin.product.vo.setting;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Schema(description = "管理后台 - 产品设置 Response VO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class ProductSettingRespVO {
|
||||
|
||||
@Schema(description = "产品基础信息")
|
||||
private ProductSettingBaseInfoRespVO baseInfo;
|
||||
|
||||
@Schema(description = "产品生命周期信息")
|
||||
private ProductSettingLifecycleRespVO lifecycle;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.njcn.rdms.module.project.dal.dataobject.member;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.rdms.framework.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* RDMS 对象成员角色关系表
|
||||
*/
|
||||
@TableName("rdms_user_object_role")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class UserObjectRoleDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 对象类型
|
||||
*/
|
||||
private String objectType;
|
||||
/**
|
||||
* 对象ID
|
||||
*/
|
||||
private Long objectId;
|
||||
/**
|
||||
* 对象角色ID
|
||||
*/
|
||||
private Long roleId;
|
||||
/**
|
||||
* 状态(0有效 1失效)
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 加入时间
|
||||
*/
|
||||
private LocalDateTime joinedTime;
|
||||
/**
|
||||
* 退出时间
|
||||
*/
|
||||
private LocalDateTime leftTime;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.njcn.rdms.module.project.dal.dataobject.permission;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.rdms.framework.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 对象菜单表
|
||||
*/
|
||||
@TableName("system_menu")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SystemMenuDO extends BaseDO {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String permission;
|
||||
|
||||
private String scopeType;
|
||||
|
||||
private String objectType;
|
||||
|
||||
private Integer type;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
private String path;
|
||||
|
||||
private String icon;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private Boolean visible;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.njcn.rdms.module.project.dal.dataobject.permission;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.rdms.framework.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 角色信息表
|
||||
*/
|
||||
@TableName("system_role")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SystemRoleDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 作用域类型
|
||||
*/
|
||||
private String scopeType;
|
||||
/**
|
||||
* 对象类型
|
||||
*/
|
||||
private String objectType;
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 角色状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 角色类型
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.njcn.rdms.module.project.dal.dataobject.permission;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.rdms.framework.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 对象角色菜单关联表
|
||||
*/
|
||||
@TableName("system_role_menu")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SystemRoleMenuDO extends BaseDO {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
private Long roleId;
|
||||
|
||||
private Long menuId;
|
||||
|
||||
}
|
||||
@@ -47,9 +47,5 @@ public class ProductDO extends BaseDO {
|
||||
* 最近一次状态动作原因
|
||||
*/
|
||||
private String lastStatusReason;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
||||
@@ -51,14 +51,6 @@ public class ObjectStatusModelDO extends BaseDO {
|
||||
* 是否允许编辑对象主数据
|
||||
*/
|
||||
private Boolean allowEdit;
|
||||
/**
|
||||
* 是否允许新建项目
|
||||
*/
|
||||
private Boolean allowCreateProject;
|
||||
/**
|
||||
* 是否允许新增需求
|
||||
*/
|
||||
private Boolean allowCreateRequirement;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,34 @@
|
||||
package com.njcn.rdms.module.project.dal.mysql.audit;
|
||||
|
||||
import com.njcn.rdms.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.njcn.rdms.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.njcn.rdms.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.audit.BizAuditLogDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface BizAuditLogMapper extends BaseMapperX<BizAuditLogDO> {
|
||||
|
||||
default List<BizAuditLogDO> selectListByBiz(String bizType, Long bizId, String actionType, LocalDateTime[] operateTime) {
|
||||
return selectList(new LambdaQueryWrapperX<BizAuditLogDO>()
|
||||
.eq(BizAuditLogDO::getBizType, bizType)
|
||||
.eq(BizAuditLogDO::getBizId, bizId)
|
||||
.eqIfPresent(BizAuditLogDO::getActionType, actionType)
|
||||
.betweenIfPresent(BaseDO::getCreateTime, operateTime)
|
||||
.orderByDesc(BaseDO::getCreateTime)
|
||||
.orderByDesc(BizAuditLogDO::getId));
|
||||
}
|
||||
|
||||
default List<BizAuditLogDO> selectListByBizType(String bizType, String actionType, LocalDateTime[] operateTime) {
|
||||
return selectList(new LambdaQueryWrapperX<BizAuditLogDO>()
|
||||
.eq(BizAuditLogDO::getBizType, bizType)
|
||||
.eqIfPresent(BizAuditLogDO::getActionType, actionType)
|
||||
.betweenIfPresent(BaseDO::getCreateTime, operateTime)
|
||||
.orderByDesc(BaseDO::getCreateTime)
|
||||
.orderByDesc(BizAuditLogDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.njcn.rdms.module.project.dal.mysql.member;
|
||||
|
||||
import com.njcn.rdms.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.njcn.rdms.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.member.UserObjectRoleDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface UserObjectRoleMapper extends BaseMapperX<UserObjectRoleDO> {
|
||||
|
||||
default List<UserObjectRoleDO> selectListByObject(String objectType, Long objectId) {
|
||||
return selectList(new LambdaQueryWrapperX<UserObjectRoleDO>()
|
||||
.eq(UserObjectRoleDO::getObjectType, objectType)
|
||||
.eq(UserObjectRoleDO::getObjectId, objectId)
|
||||
.orderByAsc(UserObjectRoleDO::getStatus)
|
||||
.orderByAsc(UserObjectRoleDO::getJoinedTime)
|
||||
.orderByAsc(UserObjectRoleDO::getId));
|
||||
}
|
||||
|
||||
default UserObjectRoleDO selectByObjectAndUserId(String objectType, Long objectId, Long userId) {
|
||||
return selectOne(new LambdaQueryWrapperX<UserObjectRoleDO>()
|
||||
.eq(UserObjectRoleDO::getObjectType, objectType)
|
||||
.eq(UserObjectRoleDO::getObjectId, objectId)
|
||||
.eq(UserObjectRoleDO::getUserId, userId));
|
||||
}
|
||||
|
||||
default UserObjectRoleDO selectByIdAndObject(Long id, String objectType, Long objectId) {
|
||||
return selectOne(new LambdaQueryWrapperX<UserObjectRoleDO>()
|
||||
.eq(UserObjectRoleDO::getId, id)
|
||||
.eq(UserObjectRoleDO::getObjectType, objectType)
|
||||
.eq(UserObjectRoleDO::getObjectId, objectId));
|
||||
}
|
||||
|
||||
default UserObjectRoleDO selectActiveByObjectAndUserId(String objectType, Long objectId, Long userId) {
|
||||
return selectOne(new LambdaQueryWrapperX<UserObjectRoleDO>()
|
||||
.eq(UserObjectRoleDO::getObjectType, objectType)
|
||||
.eq(UserObjectRoleDO::getObjectId, objectId)
|
||||
.eq(UserObjectRoleDO::getUserId, userId)
|
||||
.eq(UserObjectRoleDO::getStatus, 0));
|
||||
}
|
||||
|
||||
default List<UserObjectRoleDO> selectListByIdsAndObject(List<Long> ids, String objectType, Long objectId) {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return selectList(new LambdaQueryWrapperX<UserObjectRoleDO>()
|
||||
.in(UserObjectRoleDO::getId, ids)
|
||||
.eq(UserObjectRoleDO::getObjectType, objectType)
|
||||
.eq(UserObjectRoleDO::getObjectId, objectId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.rdms.module.project.dal.mysql.permission;
|
||||
|
||||
import com.njcn.rdms.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.njcn.rdms.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.permission.SystemMenuDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SystemMenuMapper extends BaseMapperX<SystemMenuDO> {
|
||||
|
||||
default List<SystemMenuDO> selectListByIdsAndScopeAndObjectType(Collection<Long> ids,
|
||||
String scopeType,
|
||||
String objectType) {
|
||||
return selectList(new LambdaQueryWrapperX<SystemMenuDO>()
|
||||
.inIfPresent(SystemMenuDO::getId, ids)
|
||||
.eq(SystemMenuDO::getScopeType, scopeType)
|
||||
.eq(SystemMenuDO::getObjectType, objectType));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.njcn.rdms.module.project.dal.mysql.permission;
|
||||
|
||||
import com.njcn.rdms.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.njcn.rdms.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.permission.SystemRoleDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SystemRoleMapper extends BaseMapperX<SystemRoleDO> {
|
||||
|
||||
default SystemRoleDO selectByIdAndScopeAndObjectType(Long id, String scopeType, String objectType) {
|
||||
return selectOne(new LambdaQueryWrapperX<SystemRoleDO>()
|
||||
.eq(SystemRoleDO::getId, id)
|
||||
.eq(SystemRoleDO::getScopeType, scopeType)
|
||||
.eq(SystemRoleDO::getObjectType, objectType)
|
||||
.eq(SystemRoleDO::getStatus, 0));
|
||||
}
|
||||
|
||||
default List<SystemRoleDO> selectListByIdsAndScopeAndObjectType(Collection<Long> ids,
|
||||
String scopeType,
|
||||
String objectType) {
|
||||
return selectList(new LambdaQueryWrapperX<SystemRoleDO>()
|
||||
.inIfPresent(SystemRoleDO::getId, ids)
|
||||
.eq(SystemRoleDO::getScopeType, scopeType)
|
||||
.eq(SystemRoleDO::getObjectType, objectType)
|
||||
.eq(SystemRoleDO::getStatus, 0));
|
||||
}
|
||||
|
||||
default SystemRoleDO selectByScopeAndObjectTypeAndCode(String scopeType, String objectType, String code) {
|
||||
return selectOne(new LambdaQueryWrapperX<SystemRoleDO>()
|
||||
.eq(SystemRoleDO::getScopeType, scopeType)
|
||||
.eq(SystemRoleDO::getObjectType, objectType)
|
||||
.eq(SystemRoleDO::getCode, code)
|
||||
.eq(SystemRoleDO::getStatus, 0));
|
||||
}
|
||||
|
||||
default SystemRoleDO selectByScopeAndObjectTypeAndName(String scopeType, String objectType, String name) {
|
||||
return selectOne(new LambdaQueryWrapperX<SystemRoleDO>()
|
||||
.eq(SystemRoleDO::getScopeType, scopeType)
|
||||
.eq(SystemRoleDO::getObjectType, objectType)
|
||||
.eq(SystemRoleDO::getName, name)
|
||||
.eq(SystemRoleDO::getStatus, 0));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.rdms.module.project.dal.mysql.permission;
|
||||
|
||||
import com.njcn.rdms.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.permission.SystemRoleMenuDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SystemRoleMenuMapper extends BaseMapperX<SystemRoleMenuDO> {
|
||||
|
||||
default List<SystemRoleMenuDO> selectListByRoleId(Long roleId) {
|
||||
return selectList(SystemRoleMenuDO::getRoleId, roleId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,4 +43,19 @@ public interface ProductMapper extends BaseMapperX<ProductDO> {
|
||||
.orderByDesc(ProductDO::getCode));
|
||||
}
|
||||
|
||||
default int updateStatusByIdAndStatus(Long id, String fromStatus, String toStatus, String lastStatusReason) {
|
||||
ProductDO update = new ProductDO();
|
||||
update.setStatusCode(toStatus);
|
||||
update.setLastStatusReason(lastStatusReason);
|
||||
return update(update, new LambdaQueryWrapperX<ProductDO>()
|
||||
.eq(ProductDO::getId, id)
|
||||
.eq(ProductDO::getStatusCode, fromStatus));
|
||||
}
|
||||
|
||||
default int deleteByIdAndStatus(Long id, String statusCode) {
|
||||
return delete(new LambdaQueryWrapperX<ProductDO>()
|
||||
.eq(ProductDO::getId, id)
|
||||
.eq(ProductDO::getStatusCode, statusCode));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,24 @@
|
||||
package com.njcn.rdms.module.project.dal.mysql.product;
|
||||
|
||||
import com.njcn.rdms.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.njcn.rdms.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.njcn.rdms.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.product.ProductStatusLogDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ProductStatusLogMapper extends BaseMapperX<ProductStatusLogDO> {
|
||||
|
||||
default List<ProductStatusLogDO> selectListByProductId(Long productId, String actionType, LocalDateTime[] operateTime) {
|
||||
return selectList(new LambdaQueryWrapperX<ProductStatusLogDO>()
|
||||
.eq(ProductStatusLogDO::getProductId, productId)
|
||||
.eqIfPresent(ProductStatusLogDO::getActionType, actionType)
|
||||
.betweenIfPresent(BaseDO::getCreateTime, operateTime)
|
||||
.orderByDesc(BaseDO::getCreateTime)
|
||||
.orderByDesc(ProductStatusLogDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,13 @@ public interface ObjectStatusModelMapper extends BaseMapperX<ObjectStatusModelDO
|
||||
.eq(ObjectStatusModelDO::getStatusCode, statusCode));
|
||||
}
|
||||
|
||||
default ObjectStatusModelDO selectByObjectTypeAndStatusCodeEnabled(String objectType, String statusCode) {
|
||||
return selectOne(new LambdaQueryWrapperX<ObjectStatusModelDO>()
|
||||
.eq(ObjectStatusModelDO::getObjectType, objectType)
|
||||
.eq(ObjectStatusModelDO::getStatusCode, statusCode)
|
||||
.eq(ObjectStatusModelDO::getStatus, 0));
|
||||
}
|
||||
|
||||
default List<ObjectStatusModelDO> selectListByObjectType(String objectType) {
|
||||
return selectList(new LambdaQueryWrapperX<ObjectStatusModelDO>()
|
||||
.eq(ObjectStatusModelDO::getObjectType, objectType)
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.njcn.rdms.module.project.framework.security.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 对象级权限校验注解。
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface CheckObjectPermission {
|
||||
|
||||
/**
|
||||
* 对象类型,例如 product。
|
||||
*/
|
||||
String objectType();
|
||||
|
||||
/**
|
||||
* 对象编号 SpEL 表达式。
|
||||
*/
|
||||
String objectId();
|
||||
|
||||
/**
|
||||
* 对象权限码。
|
||||
*/
|
||||
String permission() default "";
|
||||
|
||||
/**
|
||||
* 是否仅校验成员身份。
|
||||
*/
|
||||
boolean memberOnly() default false;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.njcn.rdms.module.project.framework.security.aop;
|
||||
|
||||
import com.njcn.rdms.framework.common.util.spring.SpringExpressionUtils;
|
||||
import com.njcn.rdms.module.project.framework.security.annotation.CheckObjectPermission;
|
||||
import com.njcn.rdms.module.project.framework.security.service.ObjectPermissionService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.njcn.rdms.framework.common.exception.util.ServiceExceptionUtil.invalidParamException;
|
||||
|
||||
/**
|
||||
* 对象级权限切面。
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ObjectPermissionAspect {
|
||||
|
||||
private final Map<String, ObjectPermissionService> objectPermissionServiceMap;
|
||||
|
||||
public ObjectPermissionAspect(List<ObjectPermissionService> objectPermissionServices) {
|
||||
this.objectPermissionServiceMap = objectPermissionServices.stream()
|
||||
.collect(Collectors.toMap(ObjectPermissionService::getObjectType, Function.identity()));
|
||||
}
|
||||
|
||||
@Around("@annotation(checkObjectPermission)")
|
||||
public Object aroundPointCut(ProceedingJoinPoint joinPoint,
|
||||
CheckObjectPermission checkObjectPermission) throws Throwable {
|
||||
ObjectPermissionService permissionService = objectPermissionServiceMap.get(checkObjectPermission.objectType());
|
||||
if (permissionService == null) {
|
||||
throw invalidParamException("暂不支持对象类型:{}", checkObjectPermission.objectType());
|
||||
}
|
||||
Long objectId = resolveObjectId(joinPoint, checkObjectPermission.objectId());
|
||||
permissionService.checkPermission(objectId, checkObjectPermission.permission(),
|
||||
checkObjectPermission.memberOnly());
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
|
||||
private Long resolveObjectId(ProceedingJoinPoint joinPoint, String expression) {
|
||||
Object parsedValue = SpringExpressionUtils.parseExpression(joinPoint, expression);
|
||||
if (parsedValue instanceof Number number) {
|
||||
return number.longValue();
|
||||
}
|
||||
if (parsedValue instanceof String value && StringUtils.hasText(value)) {
|
||||
try {
|
||||
return Long.parseLong(value.trim());
|
||||
} catch (NumberFormatException ex) {
|
||||
log.warn("[resolveObjectId][expression({}) value({}) 不是合法数字]", expression, value);
|
||||
}
|
||||
}
|
||||
if (Objects.isNull(parsedValue)) {
|
||||
throw invalidParamException("对象编号不能为空");
|
||||
}
|
||||
throw invalidParamException("对象编号解析失败:{}", expression);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.rdms.module.project.framework.security.service;
|
||||
|
||||
/**
|
||||
* 对象级权限服务。
|
||||
*/
|
||||
public interface ObjectPermissionService {
|
||||
|
||||
/**
|
||||
* 返回支持的对象类型。
|
||||
*/
|
||||
String getObjectType();
|
||||
|
||||
/**
|
||||
* 校验当前登录用户是否具备对象权限。
|
||||
*
|
||||
* @param objectId 对象编号
|
||||
* @param permission 权限码
|
||||
* @param memberOnly 是否只要求成员身份
|
||||
*/
|
||||
void checkPermission(Long objectId, String permission, boolean memberOnly);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.njcn.rdms.module.project.framework.security.service;
|
||||
|
||||
import com.njcn.rdms.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.member.UserObjectRoleDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.permission.SystemMenuDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.permission.SystemRoleMenuDO;
|
||||
import com.njcn.rdms.module.project.dal.mysql.member.UserObjectRoleMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.permission.SystemMenuMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.permission.SystemRoleMenuMapper;
|
||||
import com.njcn.rdms.module.project.enums.ErrorCodeConstants;
|
||||
import com.njcn.rdms.module.system.enums.permission.PermissionScopeTypeEnum;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.njcn.rdms.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.njcn.rdms.framework.common.exception.util.ServiceExceptionUtil.invalidParamException;
|
||||
|
||||
/**
|
||||
* 产品对象权限服务。
|
||||
*/
|
||||
@Service
|
||||
public class ProductObjectPermissionService implements ObjectPermissionService {
|
||||
|
||||
private static final String PRODUCT_OBJECT_TYPE = "product";
|
||||
private static final String ROLE_SCOPE_OBJECT = PermissionScopeTypeEnum.OBJECT.getScopeType();
|
||||
|
||||
@Resource
|
||||
private UserObjectRoleMapper userObjectRoleMapper;
|
||||
@Resource
|
||||
private SystemRoleMenuMapper systemRoleMenuMapper;
|
||||
@Resource
|
||||
private SystemMenuMapper systemMenuMapper;
|
||||
|
||||
@Override
|
||||
public String getObjectType() {
|
||||
return PRODUCT_OBJECT_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkPermission(Long objectId, String permission, boolean memberOnly) {
|
||||
if (objectId == null) {
|
||||
throw invalidParamException("对象编号不能为空");
|
||||
}
|
||||
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
||||
UserObjectRoleDO currentMember = userObjectRoleMapper
|
||||
.selectActiveByObjectAndUserId(PRODUCT_OBJECT_TYPE, objectId, loginUserId);
|
||||
if (currentMember == null) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_OBJECT_PERMISSION_DENIED,
|
||||
buildDeniedPermission(permission, memberOnly));
|
||||
}
|
||||
if (memberOnly) {
|
||||
return;
|
||||
}
|
||||
String normalizedPermission = normalizePermission(permission);
|
||||
if (!getRolePermissions(currentMember.getRoleId()).contains(normalizedPermission)) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_OBJECT_PERMISSION_DENIED, normalizedPermission);
|
||||
}
|
||||
}
|
||||
|
||||
private Set<String> getRolePermissions(Long roleId) {
|
||||
List<SystemRoleMenuDO> roleMenus = systemRoleMenuMapper.selectListByRoleId(roleId);
|
||||
if (roleMenus == null || roleMenus.isEmpty()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
Set<Long> menuIds = roleMenus.stream()
|
||||
.map(SystemRoleMenuDO::getMenuId)
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
if (menuIds.isEmpty()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
List<SystemMenuDO> menus = systemMenuMapper.selectListByIdsAndScopeAndObjectType(
|
||||
menuIds, ROLE_SCOPE_OBJECT, PRODUCT_OBJECT_TYPE);
|
||||
if (menus == null || menus.isEmpty()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return menus.stream()
|
||||
.filter(menu -> ROLE_SCOPE_OBJECT.equals(menu.getScopeType()))
|
||||
.filter(menu -> PRODUCT_OBJECT_TYPE.equals(menu.getObjectType()))
|
||||
.filter(menu -> Integer.valueOf(0).equals(menu.getStatus()))
|
||||
.map(SystemMenuDO::getPermission)
|
||||
.filter(StringUtils::hasText)
|
||||
.map(String::trim)
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
private String normalizePermission(String permission) {
|
||||
if (!StringUtils.hasText(permission)) {
|
||||
throw invalidParamException("对象权限码不能为空");
|
||||
}
|
||||
return permission.trim();
|
||||
}
|
||||
|
||||
private String buildDeniedPermission(String permission, boolean memberOnly) {
|
||||
return memberOnly ? "member" : normalizePermission(permission);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.njcn.rdms.module.project.service.product;
|
||||
|
||||
import com.njcn.rdms.framework.common.pojo.PageResult;
|
||||
import com.njcn.rdms.framework.common.util.json.JsonUtils;
|
||||
import com.njcn.rdms.framework.common.util.object.PageUtils;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.activity.ProductActivityPageReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.activity.ProductActivityRespVO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.audit.BizAuditLogDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.member.UserObjectRoleDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.product.ProductStatusLogDO;
|
||||
import com.njcn.rdms.module.project.dal.mysql.audit.BizAuditLogMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.member.UserObjectRoleMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.product.ProductStatusLogMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class ProductActivityQueryService {
|
||||
|
||||
private static final String PRODUCT_OBJECT_TYPE = "product";
|
||||
private static final String MEMBER_BIZ_TYPE = "rdms_user_object_role";
|
||||
|
||||
private static final String ACTIVITY_TYPE_STATUS = "status";
|
||||
private static final String ACTIVITY_TYPE_PRODUCT = "product";
|
||||
private static final String ACTIVITY_TYPE_MEMBER = "member";
|
||||
|
||||
@Resource
|
||||
private ProductStatusLogMapper productStatusLogMapper;
|
||||
@Resource
|
||||
private BizAuditLogMapper bizAuditLogMapper;
|
||||
@Resource
|
||||
private UserObjectRoleMapper userObjectRoleMapper;
|
||||
|
||||
public PageResult<ProductActivityRespVO> getProductActivities(Long productId, ProductActivityPageReqVO reqVO) {
|
||||
List<ActivityItem> items = new ArrayList<>();
|
||||
if (includeType(reqVO.getActivityType(), ACTIVITY_TYPE_STATUS)) {
|
||||
productStatusLogMapper.selectListByProductId(productId, reqVO.getActionType(), reqVO.getOperateTime())
|
||||
.forEach(log -> items.add(new ActivityItem(log.getId(), log.getCreateTime(), toStatusActivity(log))));
|
||||
}
|
||||
if (includeType(reqVO.getActivityType(), ACTIVITY_TYPE_PRODUCT)) {
|
||||
bizAuditLogMapper.selectListByBiz(PRODUCT_OBJECT_TYPE, productId, reqVO.getActionType(), reqVO.getOperateTime())
|
||||
.forEach(log -> items.add(new ActivityItem(log.getId(), log.getCreateTime(), toProductActivity(log))));
|
||||
}
|
||||
if (includeType(reqVO.getActivityType(), ACTIVITY_TYPE_MEMBER)) {
|
||||
appendMemberActivities(productId, reqVO, items);
|
||||
}
|
||||
|
||||
items.sort(Comparator.comparing(ActivityItem::operateTime, Comparator.nullsLast(LocalDateTime::compareTo))
|
||||
.thenComparing(ActivityItem::sourceId, Comparator.nullsLast(Long::compareTo))
|
||||
.reversed());
|
||||
|
||||
List<ProductActivityRespVO> activities = items.stream()
|
||||
.map(ActivityItem::respVO)
|
||||
.toList();
|
||||
return buildPageResult(activities, reqVO);
|
||||
}
|
||||
|
||||
private void appendMemberActivities(Long productId, ProductActivityPageReqVO reqVO, List<ActivityItem> items) {
|
||||
List<BizAuditLogDO> memberLogs = bizAuditLogMapper
|
||||
.selectListByBizType(MEMBER_BIZ_TYPE, reqVO.getActionType(), reqVO.getOperateTime());
|
||||
if (memberLogs.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Long> memberIds = memberLogs.stream()
|
||||
.map(BizAuditLogDO::getBizId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.toList();
|
||||
if (memberIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<Long, UserObjectRoleDO> memberMap = userObjectRoleMapper
|
||||
.selectListByIdsAndObject(memberIds, PRODUCT_OBJECT_TYPE, productId)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(UserObjectRoleDO::getId, Function.identity()));
|
||||
memberLogs.stream()
|
||||
.filter(log -> memberMap.containsKey(log.getBizId()))
|
||||
.forEach(log -> items.add(new ActivityItem(log.getId(), log.getCreateTime(), toMemberActivity(log))));
|
||||
}
|
||||
|
||||
private PageResult<ProductActivityRespVO> buildPageResult(List<ProductActivityRespVO> activities,
|
||||
ProductActivityPageReqVO reqVO) {
|
||||
if (activities.isEmpty()) {
|
||||
return PageResult.empty();
|
||||
}
|
||||
int start = PageUtils.getStart(reqVO);
|
||||
if (start >= activities.size()) {
|
||||
return PageResult.empty((long) activities.size());
|
||||
}
|
||||
int end = Math.min(start + reqVO.getPageSize(), activities.size());
|
||||
return new PageResult<>(activities.subList(start, end), (long) activities.size());
|
||||
}
|
||||
|
||||
private boolean includeType(String actual, String expected) {
|
||||
return !StringUtils.hasText(actual) || Objects.equals(actual.trim(), expected);
|
||||
}
|
||||
|
||||
private ProductActivityRespVO toStatusActivity(ProductStatusLogDO log) {
|
||||
ProductActivityRespVO respVO = new ProductActivityRespVO();
|
||||
respVO.setType(ACTIVITY_TYPE_STATUS);
|
||||
respVO.setActionType(log.getActionType());
|
||||
respVO.setActionName(resolveActionName(log.getActionType()));
|
||||
respVO.setFromStatus(log.getFromStatus());
|
||||
respVO.setToStatus(log.getToStatus());
|
||||
respVO.setReason(log.getReason());
|
||||
respVO.setOperatorUserId(log.getOperatorUserId());
|
||||
respVO.setOperatorName(log.getOperatorName());
|
||||
respVO.setOperateTime(log.getCreateTime());
|
||||
respVO.setSummary(buildSummary(log.getOperatorName(), respVO.getActionName(), log.getReason()));
|
||||
respVO.setDetails(JsonUtils.toJsonString(buildStatusDetails(log)));
|
||||
return respVO;
|
||||
}
|
||||
|
||||
private Map<String, Object> buildStatusDetails(ProductStatusLogDO log) {
|
||||
Map<String, Object> details = new LinkedHashMap<>();
|
||||
details.put("productCodeSnapshot", log.getProductCodeSnapshot());
|
||||
details.put("productNameSnapshot", log.getProductNameSnapshot());
|
||||
return details;
|
||||
}
|
||||
|
||||
private ProductActivityRespVO toProductActivity(BizAuditLogDO log) {
|
||||
ProductActivityRespVO respVO = new ProductActivityRespVO();
|
||||
respVO.setType(ACTIVITY_TYPE_PRODUCT);
|
||||
respVO.setActionType(log.getActionType());
|
||||
respVO.setActionName(resolveActionName(log.getActionType()));
|
||||
respVO.setFromStatus(log.getFromStatus());
|
||||
respVO.setToStatus(log.getToStatus());
|
||||
respVO.setReason(log.getReason());
|
||||
respVO.setOperatorUserId(log.getOperatorUserId());
|
||||
respVO.setOperatorName(log.getOperatorName());
|
||||
respVO.setOperateTime(log.getCreateTime());
|
||||
respVO.setSummary(buildSummary(log.getOperatorName(), respVO.getActionName(), log.getReason()));
|
||||
respVO.setDetails(log.getFieldChanges());
|
||||
return respVO;
|
||||
}
|
||||
|
||||
private ProductActivityRespVO toMemberActivity(BizAuditLogDO log) {
|
||||
ProductActivityRespVO respVO = toProductActivity(log);
|
||||
respVO.setType(ACTIVITY_TYPE_MEMBER);
|
||||
return respVO;
|
||||
}
|
||||
|
||||
private String resolveActionName(String actionType) {
|
||||
if (!StringUtils.hasText(actionType)) {
|
||||
return actionType;
|
||||
}
|
||||
return switch (actionType.trim()) {
|
||||
case "create" -> "创建";
|
||||
case "update" -> "更新";
|
||||
case "delete" -> "删除";
|
||||
case "pause" -> "暂停";
|
||||
case "resume" -> "恢复";
|
||||
case "archive" -> "归档";
|
||||
case "abandon" -> "废弃";
|
||||
case "change_manager" -> "切换产品经理";
|
||||
case "add_member" -> "新增成员";
|
||||
case "update_member" -> "调整成员";
|
||||
case "remove_member" -> "移出成员";
|
||||
default -> actionType.trim();
|
||||
};
|
||||
}
|
||||
|
||||
private String buildSummary(String operatorName, String actionName, String reason) {
|
||||
String actualOperatorName = StringUtils.hasText(operatorName) ? operatorName : "系统";
|
||||
if (StringUtils.hasText(reason)) {
|
||||
return String.format("%s执行了【%s】:%s", actualOperatorName, actionName, reason);
|
||||
}
|
||||
return String.format("%s执行了【%s】", actualOperatorName, actionName);
|
||||
}
|
||||
|
||||
private record ActivityItem(Long sourceId, LocalDateTime operateTime, ProductActivityRespVO respVO) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.njcn.rdms.module.project.service.product;
|
||||
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.member.ProductMemberInactiveReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.member.ProductMemberRespVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.member.ProductMemberSaveReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.member.ProductMemberUpdateReqVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 产品团队 Service 接口
|
||||
*/
|
||||
public interface ProductMemberService {
|
||||
|
||||
/**
|
||||
* 获取产品团队成员列表
|
||||
*
|
||||
* @param productId 产品编号
|
||||
* @return 成员列表
|
||||
*/
|
||||
List<ProductMemberRespVO> getProductMemberList(Long productId);
|
||||
|
||||
/**
|
||||
* 新增产品团队成员
|
||||
*
|
||||
* @param productId 产品编号
|
||||
* @param reqVO 请求参数
|
||||
* @return 团队关系编号
|
||||
*/
|
||||
Long createProductMember(Long productId, ProductMemberSaveReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 调整产品团队成员角色
|
||||
*
|
||||
* @param productId 产品编号
|
||||
* @param memberId 成员关系编号
|
||||
* @param reqVO 请求参数
|
||||
*/
|
||||
void updateProductMember(Long productId, Long memberId, ProductMemberUpdateReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 移出产品团队成员
|
||||
*
|
||||
* @param productId 产品编号
|
||||
* @param memberId 成员关系编号
|
||||
* @param reqVO 请求参数
|
||||
*/
|
||||
void inactiveProductMember(Long productId, Long memberId, ProductMemberInactiveReqVO reqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,414 @@
|
||||
package com.njcn.rdms.module.project.service.product;
|
||||
|
||||
import com.njcn.rdms.framework.common.util.json.JsonUtils;
|
||||
import com.njcn.rdms.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.member.ProductMemberInactiveReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.member.ProductMemberRespVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.member.ProductMemberSaveReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.member.ProductMemberUpdateReqVO;
|
||||
import com.njcn.rdms.module.project.framework.security.annotation.CheckObjectPermission;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.audit.BizAuditLogDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.member.UserObjectRoleDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.permission.SystemRoleDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.product.ProductDO;
|
||||
import com.njcn.rdms.module.project.dal.mysql.audit.BizAuditLogMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.member.UserObjectRoleMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.permission.SystemRoleMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.product.ProductMapper;
|
||||
import com.njcn.rdms.module.project.enums.ErrorCodeConstants;
|
||||
import com.njcn.rdms.module.system.api.user.AdminUserApi;
|
||||
import com.njcn.rdms.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.njcn.rdms.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 产品团队 Service 实现类
|
||||
*/
|
||||
@Service
|
||||
public class ProductMemberServiceImpl implements ProductMemberService {
|
||||
|
||||
private static final String PRODUCT_OBJECT_TYPE = "product";
|
||||
private static final String ROLE_SCOPE_OBJECT = "object";
|
||||
private static final String PRODUCT_QUERY_PERMISSION = "project:product:query";
|
||||
private static final String PRODUCT_UPDATE_PERMISSION = "project:product:update";
|
||||
|
||||
private static final Integer MEMBER_STATUS_ACTIVE = 0;
|
||||
private static final Integer MEMBER_STATUS_INACTIVE = 1;
|
||||
|
||||
private static final String PRODUCT_MANAGER_ROLE_CODE = "product_manager";
|
||||
|
||||
private static final String AUDIT_BIZ_TYPE_MEMBER = "rdms_user_object_role";
|
||||
private static final String AUDIT_BIZ_TYPE_PRODUCT = "product";
|
||||
private static final String AUDIT_ACTION_ADD_MEMBER = "add_member";
|
||||
private static final String AUDIT_ACTION_UPDATE_MEMBER = "update_member";
|
||||
private static final String AUDIT_ACTION_REMOVE_MEMBER = "remove_member";
|
||||
private static final String AUDIT_ACTION_CHANGE_MANAGER = "change_manager";
|
||||
|
||||
@Resource
|
||||
private ProductMapper productMapper;
|
||||
@Resource
|
||||
private UserObjectRoleMapper userObjectRoleMapper;
|
||||
@Resource
|
||||
private SystemRoleMapper systemRoleMapper;
|
||||
@Resource
|
||||
private BizAuditLogMapper bizAuditLogMapper;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
@CheckObjectPermission(objectType = PRODUCT_OBJECT_TYPE, objectId = "#productId",
|
||||
permission = PRODUCT_QUERY_PERMISSION)
|
||||
public List<ProductMemberRespVO> getProductMemberList(Long productId) {
|
||||
ProductDO product = validateProductExists(productId);
|
||||
List<UserObjectRoleDO> members = userObjectRoleMapper.selectListByObject(PRODUCT_OBJECT_TYPE, productId);
|
||||
Map<Long, SystemRoleDO> roleMap = getRoleMap(members.stream().map(UserObjectRoleDO::getRoleId).collect(Collectors.toSet()));
|
||||
Map<Long, AdminUserRespDTO> userMap = getUserMap(members.stream().map(UserObjectRoleDO::getUserId).collect(Collectors.toSet()));
|
||||
return members.stream().map(member -> {
|
||||
ProductMemberRespVO respVO = new ProductMemberRespVO();
|
||||
respVO.setId(member.getId());
|
||||
respVO.setUserId(member.getUserId());
|
||||
AdminUserRespDTO user = userMap.get(member.getUserId());
|
||||
respVO.setUserNickname(user == null ? null : user.getNickname());
|
||||
respVO.setRoleId(member.getRoleId());
|
||||
SystemRoleDO role = roleMap.get(member.getRoleId());
|
||||
respVO.setRoleName(role == null ? null : role.getName());
|
||||
respVO.setRoleCode(role == null ? null : role.getCode());
|
||||
respVO.setManagerFlag(Objects.equals(member.getUserId(), product.getManagerUserId())
|
||||
&& Objects.equals(member.getStatus(), MEMBER_STATUS_ACTIVE));
|
||||
respVO.setStatus(member.getStatus());
|
||||
respVO.setJoinedTime(member.getJoinedTime());
|
||||
respVO.setLeftTime(member.getLeftTime());
|
||||
respVO.setRemark(member.getRemark());
|
||||
return respVO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CheckObjectPermission(objectType = PRODUCT_OBJECT_TYPE, objectId = "#productId",
|
||||
permission = PRODUCT_UPDATE_PERMISSION)
|
||||
public Long createProductMember(Long productId, ProductMemberSaveReqVO reqVO) {
|
||||
ProductDO product = validateProductExists(productId);
|
||||
SystemRoleDO targetRole = validateProductRole(reqVO.getRoleId());
|
||||
UserObjectRoleDO existingMember = userObjectRoleMapper
|
||||
.selectByObjectAndUserId(PRODUCT_OBJECT_TYPE, productId, reqVO.getUserId());
|
||||
if (existingMember != null && Objects.equals(existingMember.getStatus(), MEMBER_STATUS_ACTIVE)) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_MEMBER_ALREADY_EXISTS);
|
||||
}
|
||||
|
||||
UserObjectRoleDO member;
|
||||
UserObjectRoleDO before = null;
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if (existingMember == null) {
|
||||
member = new UserObjectRoleDO();
|
||||
member.setUserId(reqVO.getUserId());
|
||||
member.setObjectType(PRODUCT_OBJECT_TYPE);
|
||||
member.setObjectId(productId);
|
||||
member.setRoleId(targetRole.getId());
|
||||
member.setStatus(MEMBER_STATUS_ACTIVE);
|
||||
member.setJoinedTime(now);
|
||||
member.setLeftTime(null);
|
||||
member.setRemark(normalizeNullableText(reqVO.getRemark()));
|
||||
userObjectRoleMapper.insert(member);
|
||||
} else {
|
||||
before = cloneMember(existingMember);
|
||||
member = existingMember;
|
||||
member.setRoleId(targetRole.getId());
|
||||
member.setStatus(MEMBER_STATUS_ACTIVE);
|
||||
member.setJoinedTime(now);
|
||||
member.setLeftTime(null);
|
||||
member.setRemark(normalizeNullableText(reqVO.getRemark()));
|
||||
userObjectRoleMapper.updateById(member);
|
||||
}
|
||||
|
||||
writeMemberAuditLog(member, AUDIT_ACTION_ADD_MEMBER, before, member, null);
|
||||
if (isManagerRole(targetRole)) {
|
||||
transferManager(product, member, reqVO.getPreviousManagerUserId(), reqVO.getPreviousManagerRoleId(), null);
|
||||
}
|
||||
return member.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CheckObjectPermission(objectType = PRODUCT_OBJECT_TYPE, objectId = "#productId",
|
||||
permission = PRODUCT_UPDATE_PERMISSION)
|
||||
public void updateProductMember(Long productId, Long memberId, ProductMemberUpdateReqVO reqVO) {
|
||||
ProductDO product = validateProductExists(productId);
|
||||
UserObjectRoleDO member = validateMemberExists(productId, memberId);
|
||||
if (!Objects.equals(member.getStatus(), MEMBER_STATUS_ACTIVE)) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_MEMBER_NOT_ACTIVE);
|
||||
}
|
||||
|
||||
SystemRoleDO targetRole = validateProductRole(reqVO.getRoleId());
|
||||
UserObjectRoleDO before = cloneMember(member);
|
||||
member.setRemark(normalizeNullableText(reqVO.getRemark()));
|
||||
|
||||
if (isManagerRole(targetRole)) {
|
||||
member.setRoleId(targetRole.getId());
|
||||
userObjectRoleMapper.updateById(member);
|
||||
transferManager(product, member, reqVO.getPreviousManagerUserId(),
|
||||
reqVO.getPreviousManagerRoleId(), normalizeNullableText(reqVO.getReason()));
|
||||
} else {
|
||||
if (Objects.equals(member.getUserId(), product.getManagerUserId())) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_MANAGER_MEMBER_NOT_ALLOW_DOWNGRADE);
|
||||
}
|
||||
member.setRoleId(targetRole.getId());
|
||||
userObjectRoleMapper.updateById(member);
|
||||
}
|
||||
|
||||
writeMemberAuditLog(member, AUDIT_ACTION_UPDATE_MEMBER, before, member, normalizeNullableText(reqVO.getReason()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CheckObjectPermission(objectType = PRODUCT_OBJECT_TYPE, objectId = "#productId",
|
||||
permission = PRODUCT_UPDATE_PERMISSION)
|
||||
public void inactiveProductMember(Long productId, Long memberId, ProductMemberInactiveReqVO reqVO) {
|
||||
ProductDO product = validateProductExists(productId);
|
||||
UserObjectRoleDO member = validateMemberExists(productId, memberId);
|
||||
if (!Objects.equals(member.getStatus(), MEMBER_STATUS_ACTIVE)) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_MEMBER_NOT_ACTIVE);
|
||||
}
|
||||
if (Objects.equals(member.getUserId(), product.getManagerUserId())) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_MANAGER_MEMBER_NOT_ALLOW_REMOVE);
|
||||
}
|
||||
|
||||
UserObjectRoleDO before = cloneMember(member);
|
||||
member.setStatus(MEMBER_STATUS_INACTIVE);
|
||||
member.setLeftTime(LocalDateTime.now());
|
||||
userObjectRoleMapper.updateById(member);
|
||||
|
||||
writeMemberAuditLog(member, AUDIT_ACTION_REMOVE_MEMBER, before, member,
|
||||
normalizeNullableText(reqVO.getReason()));
|
||||
}
|
||||
|
||||
private ProductDO validateProductExists(Long productId) {
|
||||
if (productId == null) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_NOT_EXISTS);
|
||||
}
|
||||
ProductDO product = productMapper.selectById(productId);
|
||||
if (product == null) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_NOT_EXISTS);
|
||||
}
|
||||
return product;
|
||||
}
|
||||
|
||||
private UserObjectRoleDO validateMemberExists(Long productId, Long memberId) {
|
||||
UserObjectRoleDO member = userObjectRoleMapper.selectByIdAndObject(memberId, PRODUCT_OBJECT_TYPE, productId);
|
||||
if (member == null) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_MEMBER_NOT_EXISTS);
|
||||
}
|
||||
return member;
|
||||
}
|
||||
|
||||
private SystemRoleDO validateProductRole(Long roleId) {
|
||||
SystemRoleDO role = systemRoleMapper.selectByIdAndScopeAndObjectType(roleId, ROLE_SCOPE_OBJECT, PRODUCT_OBJECT_TYPE);
|
||||
if (role == null) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_MEMBER_ROLE_INVALID);
|
||||
}
|
||||
return role;
|
||||
}
|
||||
|
||||
private void transferManager(ProductDO product,
|
||||
UserObjectRoleDO targetManagerMember,
|
||||
Long previousManagerUserId,
|
||||
Long previousManagerRoleId,
|
||||
String reason) {
|
||||
Long currentManagerUserId = product.getManagerUserId();
|
||||
Long targetManagerUserId = targetManagerMember.getUserId();
|
||||
if (Objects.equals(currentManagerUserId, targetManagerUserId)) {
|
||||
product.setManagerUserId(targetManagerUserId);
|
||||
productMapper.updateById(product);
|
||||
return;
|
||||
}
|
||||
|
||||
SystemRoleDO previousManagerRole = validatePreviousManagerTransfer(currentManagerUserId,
|
||||
previousManagerUserId, previousManagerRoleId);
|
||||
transferPreviousManager(product.getId(), previousManagerUserId, previousManagerRole.getId(), reason);
|
||||
|
||||
product.setManagerUserId(targetManagerUserId);
|
||||
productMapper.updateById(product);
|
||||
writeManagerChangeAuditLog(product.getId(), currentManagerUserId, targetManagerUserId, reason);
|
||||
}
|
||||
|
||||
private SystemRoleDO validatePreviousManagerTransfer(Long currentManagerUserId,
|
||||
Long previousManagerUserId,
|
||||
Long previousManagerRoleId) {
|
||||
if (currentManagerUserId == null
|
||||
|| previousManagerUserId == null
|
||||
|| previousManagerRoleId == null) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_MANAGER_TRANSFER_INFO_REQUIRED);
|
||||
}
|
||||
if (!Objects.equals(currentManagerUserId, previousManagerUserId)) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_MANAGER_TRANSFER_SOURCE_INVALID);
|
||||
}
|
||||
SystemRoleDO previousManagerRole = validateProductRole(previousManagerRoleId);
|
||||
if (isManagerRole(previousManagerRole)) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_MANAGER_TRANSFER_ROLE_INVALID);
|
||||
}
|
||||
return previousManagerRole;
|
||||
}
|
||||
|
||||
private void transferPreviousManager(Long productId, Long previousManagerUserId, Long previousManagerRoleId, String reason) {
|
||||
UserObjectRoleDO existingMember = userObjectRoleMapper
|
||||
.selectByObjectAndUserId(PRODUCT_OBJECT_TYPE, productId, previousManagerUserId);
|
||||
UserObjectRoleDO before = existingMember == null ? null : cloneMember(existingMember);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
UserObjectRoleDO member;
|
||||
String actionType;
|
||||
if (existingMember == null) {
|
||||
member = new UserObjectRoleDO();
|
||||
member.setUserId(previousManagerUserId);
|
||||
member.setObjectType(PRODUCT_OBJECT_TYPE);
|
||||
member.setObjectId(productId);
|
||||
member.setRoleId(previousManagerRoleId);
|
||||
member.setStatus(MEMBER_STATUS_ACTIVE);
|
||||
member.setJoinedTime(now);
|
||||
member.setLeftTime(null);
|
||||
member.setRemark(null);
|
||||
userObjectRoleMapper.insert(member);
|
||||
actionType = AUDIT_ACTION_ADD_MEMBER;
|
||||
} else {
|
||||
member = existingMember;
|
||||
member.setRoleId(previousManagerRoleId);
|
||||
member.setStatus(MEMBER_STATUS_ACTIVE);
|
||||
member.setLeftTime(null);
|
||||
if (!Objects.equals(before.getStatus(), MEMBER_STATUS_ACTIVE)) {
|
||||
member.setJoinedTime(now);
|
||||
actionType = AUDIT_ACTION_ADD_MEMBER;
|
||||
} else {
|
||||
actionType = AUDIT_ACTION_UPDATE_MEMBER;
|
||||
}
|
||||
userObjectRoleMapper.updateById(member);
|
||||
}
|
||||
writeMemberAuditLog(member, actionType, before, member, reason);
|
||||
}
|
||||
|
||||
private boolean isManagerRole(SystemRoleDO role) {
|
||||
return Objects.equals(PRODUCT_MANAGER_ROLE_CODE, role.getCode());
|
||||
}
|
||||
|
||||
private Map<Long, SystemRoleDO> getRoleMap(Set<Long> roleIds) {
|
||||
if (roleIds.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<SystemRoleDO> roles = systemRoleMapper
|
||||
.selectListByIdsAndScopeAndObjectType(roleIds, ROLE_SCOPE_OBJECT, PRODUCT_OBJECT_TYPE);
|
||||
return roles.stream().collect(Collectors.toMap(SystemRoleDO::getId, Function.identity()));
|
||||
}
|
||||
|
||||
private Map<Long, AdminUserRespDTO> getUserMap(Set<Long> userIds) {
|
||||
if (userIds.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return adminUserApi.getUserMap(userIds);
|
||||
}
|
||||
|
||||
private void writeMemberAuditLog(UserObjectRoleDO member,
|
||||
String actionType,
|
||||
UserObjectRoleDO before,
|
||||
UserObjectRoleDO after,
|
||||
String reason) {
|
||||
BizAuditLogDO auditLog = new BizAuditLogDO();
|
||||
auditLog.setBizType(AUDIT_BIZ_TYPE_MEMBER);
|
||||
auditLog.setBizId(member.getId());
|
||||
auditLog.setActionType(actionType);
|
||||
auditLog.setFieldChanges(buildMemberFieldChanges(before, after));
|
||||
auditLog.setReason(reason);
|
||||
auditLog.setOperatorUserId(SecurityFrameworkUtils.getLoginUserId());
|
||||
auditLog.setOperatorName(defaultText(SecurityFrameworkUtils.getLoginUserNickname()));
|
||||
bizAuditLogMapper.insert(auditLog);
|
||||
}
|
||||
|
||||
private void writeManagerChangeAuditLog(Long productId, Long beforeManagerUserId, Long afterManagerUserId, String reason) {
|
||||
if (Objects.equals(beforeManagerUserId, afterManagerUserId)) {
|
||||
return;
|
||||
}
|
||||
BizAuditLogDO auditLog = new BizAuditLogDO();
|
||||
auditLog.setBizType(AUDIT_BIZ_TYPE_PRODUCT);
|
||||
auditLog.setBizId(productId);
|
||||
auditLog.setActionType(AUDIT_ACTION_CHANGE_MANAGER);
|
||||
auditLog.setFieldChanges(buildManagerFieldChanges(beforeManagerUserId, afterManagerUserId));
|
||||
auditLog.setReason(reason);
|
||||
auditLog.setOperatorUserId(SecurityFrameworkUtils.getLoginUserId());
|
||||
auditLog.setOperatorName(defaultText(SecurityFrameworkUtils.getLoginUserNickname()));
|
||||
bizAuditLogMapper.insert(auditLog);
|
||||
}
|
||||
|
||||
private String buildMemberFieldChanges(UserObjectRoleDO before, UserObjectRoleDO after) {
|
||||
Map<String, Object> fieldChanges = new LinkedHashMap<>();
|
||||
appendFieldChange(fieldChanges, "userId", valueOf(before, UserObjectRoleDO::getUserId),
|
||||
valueOf(after, UserObjectRoleDO::getUserId));
|
||||
appendFieldChange(fieldChanges, "roleId", valueOf(before, UserObjectRoleDO::getRoleId),
|
||||
valueOf(after, UserObjectRoleDO::getRoleId));
|
||||
appendFieldChange(fieldChanges, "status", valueOf(before, UserObjectRoleDO::getStatus),
|
||||
valueOf(after, UserObjectRoleDO::getStatus));
|
||||
appendFieldChange(fieldChanges, "joinedTime", valueOf(before, UserObjectRoleDO::getJoinedTime),
|
||||
valueOf(after, UserObjectRoleDO::getJoinedTime));
|
||||
appendFieldChange(fieldChanges, "leftTime", valueOf(before, UserObjectRoleDO::getLeftTime),
|
||||
valueOf(after, UserObjectRoleDO::getLeftTime));
|
||||
appendFieldChange(fieldChanges, "remark", valueOf(before, UserObjectRoleDO::getRemark),
|
||||
valueOf(after, UserObjectRoleDO::getRemark));
|
||||
return fieldChanges.isEmpty() ? null : JsonUtils.toJsonString(fieldChanges);
|
||||
}
|
||||
|
||||
private String buildManagerFieldChanges(Long beforeManagerUserId, Long afterManagerUserId) {
|
||||
Map<String, Object> fieldChanges = new LinkedHashMap<>();
|
||||
appendFieldChange(fieldChanges, "managerUserId", beforeManagerUserId, afterManagerUserId);
|
||||
return JsonUtils.toJsonString(fieldChanges);
|
||||
}
|
||||
|
||||
private UserObjectRoleDO cloneMember(UserObjectRoleDO source) {
|
||||
UserObjectRoleDO clone = new UserObjectRoleDO();
|
||||
clone.setId(source.getId());
|
||||
clone.setUserId(source.getUserId());
|
||||
clone.setObjectType(source.getObjectType());
|
||||
clone.setObjectId(source.getObjectId());
|
||||
clone.setRoleId(source.getRoleId());
|
||||
clone.setStatus(source.getStatus());
|
||||
clone.setJoinedTime(source.getJoinedTime());
|
||||
clone.setLeftTime(source.getLeftTime());
|
||||
clone.setRemark(source.getRemark());
|
||||
return clone;
|
||||
}
|
||||
|
||||
private <T> T valueOf(UserObjectRoleDO member, Function<UserObjectRoleDO, T> getter) {
|
||||
return member == null ? null : getter.apply(member);
|
||||
}
|
||||
|
||||
private void appendFieldChange(Map<String, Object> fieldChanges, String fieldName, Object before, Object after) {
|
||||
if (Objects.equals(before, after)) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> value = new LinkedHashMap<>();
|
||||
value.put("before", before);
|
||||
value.put("after", after);
|
||||
fieldChanges.put(fieldName, value);
|
||||
}
|
||||
|
||||
private String normalizeNullableText(String value) {
|
||||
if (!StringUtils.hasText(value)) {
|
||||
return null;
|
||||
}
|
||||
return value.trim();
|
||||
}
|
||||
|
||||
private String defaultText(String value) {
|
||||
return StringUtils.hasText(value) ? value : "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.njcn.rdms.module.project.service.product;
|
||||
|
||||
import com.njcn.rdms.framework.common.pojo.PageResult;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductContextRespVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductDeleteReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductPageReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductSaveReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductStatusActionReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.setting.ProductSettingBaseInfoUpdateReqVO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.product.ProductDO;
|
||||
|
||||
/**
|
||||
@@ -27,6 +29,14 @@ public interface ProductService {
|
||||
*/
|
||||
void updateProduct(ProductSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 更新产品设置页基础信息
|
||||
*
|
||||
* @param productId 产品编号
|
||||
* @param reqVO 更新请求
|
||||
*/
|
||||
void updateProductBaseInfo(Long productId, ProductSettingBaseInfoUpdateReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 获取产品详情
|
||||
*
|
||||
@@ -35,6 +45,14 @@ public interface ProductService {
|
||||
*/
|
||||
ProductDO getProduct(Long id);
|
||||
|
||||
/**
|
||||
* 获取产品上下文
|
||||
*
|
||||
* @param id 产品编号
|
||||
* @return 产品上下文
|
||||
*/
|
||||
ProductContextRespVO getProductContext(Long id);
|
||||
|
||||
/**
|
||||
* 获取产品分页
|
||||
*
|
||||
|
||||
@@ -5,30 +5,54 @@ import com.njcn.rdms.framework.common.pojo.PageResult;
|
||||
import com.njcn.rdms.framework.common.util.json.JsonUtils;
|
||||
import com.njcn.rdms.framework.common.util.object.BeanUtils;
|
||||
import com.njcn.rdms.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductContextNavRespVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductContextProductRespVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductContextRoleRespVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductContextRespVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductDeleteReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductPageReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductSaveReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductStatusActionReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.setting.ProductSettingBaseInfoUpdateReqVO;
|
||||
import com.njcn.rdms.module.project.framework.security.annotation.CheckObjectPermission;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.audit.BizAuditLogDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.member.UserObjectRoleDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.permission.SystemMenuDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.permission.SystemRoleDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.permission.SystemRoleMenuDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.product.ProductDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.product.ProductStatusLogDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.status.ObjectStatusTransitionDO;
|
||||
import com.njcn.rdms.module.project.dal.mysql.audit.BizAuditLogMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.member.UserObjectRoleMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.permission.SystemMenuMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.permission.SystemRoleMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.permission.SystemRoleMenuMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.product.ProductMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.product.ProductStatusLogMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.status.ObjectStatusTransitionMapper;
|
||||
import com.njcn.rdms.module.project.enums.ErrorCodeConstants;
|
||||
import com.njcn.rdms.module.system.api.user.AdminUserApi;
|
||||
import com.njcn.rdms.module.system.enums.permission.MenuTypeEnum;
|
||||
import com.njcn.rdms.module.system.enums.permission.PermissionScopeTypeEnum;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.njcn.rdms.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.njcn.rdms.framework.common.exception.util.ServiceExceptionUtil.invalidParamException;
|
||||
@@ -40,16 +64,29 @@ import static com.njcn.rdms.framework.common.exception.util.ServiceExceptionUtil
|
||||
public class ProductServiceImpl implements ProductService {
|
||||
|
||||
private static final String PRODUCT_OBJECT_TYPE = "product";
|
||||
private static final String ROLE_SCOPE_OBJECT = PermissionScopeTypeEnum.OBJECT.getScopeType();
|
||||
private static final String PRODUCT_MANAGER_ROLE_CODE = "product_manager";
|
||||
|
||||
private static final String PRODUCT_ACTIVE_STATUS = "active";
|
||||
private static final String PRODUCT_PAUSED_STATUS = "paused";
|
||||
private static final String PRODUCT_ARCHIVED_STATUS = "archived";
|
||||
private static final String PRODUCT_ABANDONED_STATUS = "abandoned";
|
||||
|
||||
private static final Integer MEMBER_STATUS_ACTIVE = 0;
|
||||
|
||||
private static final String PRODUCT_CREATE_ACTION = "create";
|
||||
private static final String PRODUCT_UPDATE_ACTION = "update";
|
||||
private static final String PRODUCT_DELETE_ACTION = "delete";
|
||||
private static final String PRODUCT_CHANGE_MANAGER_ACTION = "change_manager";
|
||||
private static final String PRODUCT_ADD_MEMBER_ACTION = "add_member";
|
||||
private static final String AUDIT_BIZ_TYPE_MEMBER = "rdms_user_object_role";
|
||||
|
||||
private static final String PRODUCT_CODE_PREFIX = "CNPD";
|
||||
private static final String PRODUCT_QUERY_PERMISSION = "project:product:query";
|
||||
private static final String PRODUCT_UPDATE_PERMISSION = "project:product:update";
|
||||
private static final String PRODUCT_STATUS_PERMISSION = "project:product:status";
|
||||
private static final String PRODUCT_DELETE_PERMISSION = "project:product:delete";
|
||||
private static final String PRODUCT_DELETE_CONFIRM_TEXT = "DELETE";
|
||||
|
||||
@Resource
|
||||
private ProductMapper productMapper;
|
||||
@@ -60,6 +97,14 @@ public class ProductServiceImpl implements ProductService {
|
||||
@Resource
|
||||
private ObjectStatusTransitionMapper objectStatusTransitionMapper;
|
||||
@Resource
|
||||
private UserObjectRoleMapper userObjectRoleMapper;
|
||||
@Resource
|
||||
private SystemRoleMapper systemRoleMapper;
|
||||
@Resource
|
||||
private SystemRoleMenuMapper systemRoleMenuMapper;
|
||||
@Resource
|
||||
private SystemMenuMapper systemMenuMapper;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
@@ -75,44 +120,82 @@ public class ProductServiceImpl implements ProductService {
|
||||
product.setName(createReqVO.getName().trim());
|
||||
product.setManagerUserId(createReqVO.getManagerUserId());
|
||||
product.setDescription(normalizeNullableText(createReqVO.getDescription()));
|
||||
product.setRemark(normalizeNullableText(createReqVO.getRemark()));
|
||||
productMapper.insert(product);
|
||||
|
||||
initManagerMemberRelation(product);
|
||||
writeBizAuditLog(product, PRODUCT_CREATE_ACTION, null, PRODUCT_ACTIVE_STATUS,
|
||||
buildFieldChanges(null, product), null);
|
||||
buildProductFieldChanges(null, product), null);
|
||||
return product.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CheckObjectPermission(objectType = PRODUCT_OBJECT_TYPE, objectId = "#updateReqVO.id",
|
||||
permission = PRODUCT_UPDATE_PERMISSION)
|
||||
public void updateProduct(ProductSaveReqVO updateReqVO) {
|
||||
if (updateReqVO.getId() == null) {
|
||||
throw invalidParamException("产品编号不能为空");
|
||||
}
|
||||
ProductDO product = validateProductExists(updateReqVO.getId());
|
||||
validateManagerUser(updateReqVO.getManagerUserId());
|
||||
validateProductCodeUnchanged(product, updateReqVO.getCode());
|
||||
validateProductEditable(product, updateReqVO);
|
||||
validateProductNameUnique(updateReqVO.getId(), updateReqVO.getName());
|
||||
|
||||
ProductDO before = BeanUtils.toBean(product, ProductDO.class);
|
||||
|
||||
product.setDirectionCode(updateReqVO.getDirectionCode());
|
||||
product.setName(updateReqVO.getName().trim());
|
||||
product.setManagerUserId(updateReqVO.getManagerUserId());
|
||||
product.setDescription(normalizeNullableText(updateReqVO.getDescription()));
|
||||
product.setRemark(normalizeNullableText(updateReqVO.getRemark()));
|
||||
productMapper.updateById(product);
|
||||
|
||||
writeBizAuditLog(product, PRODUCT_UPDATE_ACTION, product.getStatusCode(), product.getStatusCode(),
|
||||
buildFieldChanges(before, product), null);
|
||||
validateManagerUserUnchanged(product, updateReqVO.getManagerUserId());
|
||||
applyProductBaseInfoUpdate(product, updateReqVO.getDirectionCode(), updateReqVO.getName(), updateReqVO.getDescription());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CheckObjectPermission(objectType = PRODUCT_OBJECT_TYPE, objectId = "#productId",
|
||||
permission = PRODUCT_UPDATE_PERMISSION)
|
||||
public void updateProductBaseInfo(Long productId, ProductSettingBaseInfoUpdateReqVO reqVO) {
|
||||
ProductDO product = validateProductExists(productId);
|
||||
applyProductBaseInfoUpdate(product, reqVO.getDirectionCode(), reqVO.getName(), reqVO.getDescription());
|
||||
}
|
||||
|
||||
@Override
|
||||
@CheckObjectPermission(objectType = PRODUCT_OBJECT_TYPE, objectId = "#id",
|
||||
permission = PRODUCT_QUERY_PERMISSION)
|
||||
public ProductDO getProduct(Long id) {
|
||||
return validateProductExists(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CheckObjectPermission(objectType = PRODUCT_OBJECT_TYPE, objectId = "#id", memberOnly = true)
|
||||
public ProductContextRespVO getProductContext(Long id) {
|
||||
ProductDO product = validateProductExists(id);
|
||||
|
||||
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
||||
UserObjectRoleDO currentMember = userObjectRoleMapper
|
||||
.selectActiveByObjectAndUserId(PRODUCT_OBJECT_TYPE, id, loginUserId);
|
||||
ProductContextRespVO respVO = new ProductContextRespVO();
|
||||
respVO.setCurrentProduct(buildCurrentProduct(product));
|
||||
if (currentMember == null) {
|
||||
respVO.setNavs(Collections.emptyList());
|
||||
respVO.setButtons(Collections.emptyList());
|
||||
return respVO;
|
||||
}
|
||||
|
||||
SystemRoleDO currentRole = systemRoleMapper
|
||||
.selectByIdAndScopeAndObjectType(currentMember.getRoleId(), ROLE_SCOPE_OBJECT, PRODUCT_OBJECT_TYPE);
|
||||
respVO.setCurrentRole(buildCurrentRole(currentMember, currentRole));
|
||||
|
||||
List<SystemRoleMenuDO> roleMenus = systemRoleMenuMapper.selectListByRoleId(currentMember.getRoleId());
|
||||
if (roleMenus.isEmpty()) {
|
||||
respVO.setNavs(Collections.emptyList());
|
||||
respVO.setButtons(Collections.emptyList());
|
||||
return respVO;
|
||||
}
|
||||
|
||||
Set<Long> menuIds = roleMenus.stream()
|
||||
.map(SystemRoleMenuDO::getMenuId)
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
List<SystemMenuDO> menus = filterEnableProductObjectMenus(
|
||||
systemMenuMapper.selectListByIdsAndScopeAndObjectType(menuIds, ROLE_SCOPE_OBJECT, PRODUCT_OBJECT_TYPE));
|
||||
|
||||
respVO.setNavs(buildContextNavs(menus));
|
||||
respVO.setButtons(buildContextButtons(menus));
|
||||
return respVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProductDO> getProductPage(ProductPageReqVO pageReqVO) {
|
||||
return productMapper.selectPage(pageReqVO);
|
||||
@@ -120,6 +203,8 @@ public class ProductServiceImpl implements ProductService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CheckObjectPermission(objectType = PRODUCT_OBJECT_TYPE, objectId = "#reqVO.id",
|
||||
permission = PRODUCT_STATUS_PERMISSION)
|
||||
public void changeProductStatus(ProductStatusActionReqVO reqVO) {
|
||||
ProductDO product = validateProductExists(reqVO.getId());
|
||||
String actionCode = reqVO.getActionCode().trim();
|
||||
@@ -129,9 +214,12 @@ public class ProductServiceImpl implements ProductService {
|
||||
|
||||
String fromStatus = product.getStatusCode();
|
||||
String toStatus = transition.getToStatusCode();
|
||||
int updateCount = productMapper.updateStatusByIdAndStatus(product.getId(), fromStatus, toStatus, reason);
|
||||
if (updateCount != 1) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_STATUS_CONCURRENT_MODIFIED);
|
||||
}
|
||||
product.setStatusCode(toStatus);
|
||||
product.setLastStatusReason(reason);
|
||||
productMapper.updateById(product);
|
||||
|
||||
writeProductStatusLog(product, actionCode, fromStatus, toStatus, reason);
|
||||
writeBizAuditLog(product, actionCode, fromStatus, toStatus, null, reason);
|
||||
@@ -139,15 +227,21 @@ public class ProductServiceImpl implements ProductService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CheckObjectPermission(objectType = PRODUCT_OBJECT_TYPE, objectId = "#reqVO.id",
|
||||
permission = PRODUCT_DELETE_PERMISSION)
|
||||
public void deleteProduct(ProductDeleteReqVO reqVO) {
|
||||
ProductDO product = validateProductExists(reqVO.getId());
|
||||
validateDeleteConfirmText(reqVO.getConfirmText());
|
||||
if (!Objects.equals(product.getName(), reqVO.getProductName().trim())) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_DELETE_NAME_MISMATCH);
|
||||
}
|
||||
|
||||
String reason = reqVO.getReason().trim();
|
||||
String fromStatus = product.getStatusCode();
|
||||
productMapper.deleteById(reqVO.getId());
|
||||
int deleteCount = productMapper.deleteByIdAndStatus(reqVO.getId(), fromStatus);
|
||||
if (deleteCount != 1) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_STATUS_CONCURRENT_MODIFIED);
|
||||
}
|
||||
|
||||
writeProductStatusLog(product, PRODUCT_DELETE_ACTION, fromStatus, null, reason);
|
||||
writeBizAuditLog(product, PRODUCT_DELETE_ACTION, fromStatus, null, null, reason);
|
||||
@@ -213,8 +307,20 @@ public class ProductServiceImpl implements ProductService {
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void validateManagerUserUnchanged(ProductDO product, Long managerUserId) {
|
||||
if (!Objects.equals(product.getManagerUserId(), managerUserId)) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_MANAGER_NOT_MODIFIABLE);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void validateProductEditable(ProductDO product, ProductSaveReqVO updateReqVO) {
|
||||
validateProductEditable(product, updateReqVO.getDirectionCode(), updateReqVO.getName());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void validateProductEditable(ProductDO product, String directionCode, String name) {
|
||||
if (PRODUCT_ARCHIVED_STATUS.equals(product.getStatusCode())
|
||||
|| PRODUCT_ABANDONED_STATUS.equals(product.getStatusCode())) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_STATUS_NOT_ALLOW_EDIT);
|
||||
@@ -222,8 +328,8 @@ public class ProductServiceImpl implements ProductService {
|
||||
if (!PRODUCT_PAUSED_STATUS.equals(product.getStatusCode())) {
|
||||
return;
|
||||
}
|
||||
if (!Objects.equals(product.getDirectionCode(), updateReqVO.getDirectionCode())
|
||||
|| !Objects.equals(product.getName(), updateReqVO.getName().trim())) {
|
||||
if (!Objects.equals(product.getDirectionCode(), directionCode)
|
||||
|| !Objects.equals(product.getName(), name.trim())) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_PAUSED_ONLY_ALLOW_LIMITED_UPDATE);
|
||||
}
|
||||
}
|
||||
@@ -245,6 +351,14 @@ public class ProductServiceImpl implements ProductService {
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void validateDeleteConfirmText(String confirmText) {
|
||||
String normalizedConfirmText = normalizeNullableText(confirmText);
|
||||
if (!Objects.equals(PRODUCT_DELETE_CONFIRM_TEXT, normalizedConfirmText)) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_DELETE_CONFIRM_TEXT_INVALID);
|
||||
}
|
||||
}
|
||||
|
||||
private String generateProductCode(String code) {
|
||||
String normalizedCode = normalizeNullableText(code);
|
||||
if (StringUtils.hasText(normalizedCode)) {
|
||||
@@ -271,6 +385,90 @@ public class ProductServiceImpl implements ProductService {
|
||||
return generatedCode;
|
||||
}
|
||||
|
||||
private void initManagerMemberRelation(ProductDO product) {
|
||||
SystemRoleDO managerRole = systemRoleMapper
|
||||
.selectByScopeAndObjectTypeAndCode(ROLE_SCOPE_OBJECT, PRODUCT_OBJECT_TYPE, PRODUCT_MANAGER_ROLE_CODE);
|
||||
if (managerRole == null) {
|
||||
throw invalidParamException("未找到产品经理对象角色配置:{}", PRODUCT_MANAGER_ROLE_CODE);
|
||||
}
|
||||
|
||||
UserObjectRoleDO member = new UserObjectRoleDO();
|
||||
member.setUserId(product.getManagerUserId());
|
||||
member.setObjectType(PRODUCT_OBJECT_TYPE);
|
||||
member.setObjectId(product.getId());
|
||||
member.setRoleId(managerRole.getId());
|
||||
member.setStatus(MEMBER_STATUS_ACTIVE);
|
||||
member.setJoinedTime(LocalDateTime.now());
|
||||
member.setLeftTime(null);
|
||||
userObjectRoleMapper.insert(member);
|
||||
|
||||
writeMemberInitAuditLog(member);
|
||||
writeManagerInitAuditLog(product.getId(), product.getManagerUserId());
|
||||
}
|
||||
|
||||
private List<SystemMenuDO> filterEnableProductObjectMenus(List<SystemMenuDO> menus) {
|
||||
if (menus == null || menus.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return menus.stream()
|
||||
.filter(menu -> Objects.equals(ROLE_SCOPE_OBJECT, menu.getScopeType()))
|
||||
.filter(menu -> Objects.equals(PRODUCT_OBJECT_TYPE, menu.getObjectType()))
|
||||
.filter(menu -> Objects.equals(0, menu.getStatus()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private ProductContextProductRespVO buildCurrentProduct(ProductDO product) {
|
||||
return BeanUtils.toBean(product, ProductContextProductRespVO.class);
|
||||
}
|
||||
|
||||
private ProductContextRoleRespVO buildCurrentRole(UserObjectRoleDO currentMember, SystemRoleDO currentRole) {
|
||||
ProductContextRoleRespVO roleRespVO = new ProductContextRoleRespVO();
|
||||
roleRespVO.setRoleId(currentMember.getRoleId());
|
||||
if (currentRole != null) {
|
||||
roleRespVO.setRoleCode(currentRole.getCode());
|
||||
roleRespVO.setRoleName(currentRole.getName());
|
||||
}
|
||||
return roleRespVO;
|
||||
}
|
||||
|
||||
private List<ProductContextNavRespVO> buildContextNavs(List<SystemMenuDO> menus) {
|
||||
if (menus.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<ProductContextNavRespVO> navs = menus.stream()
|
||||
.filter(menu -> !MenuTypeEnum.BUTTON.getType().equals(menu.getType()))
|
||||
.filter(menu -> !Boolean.FALSE.equals(menu.getVisible()))
|
||||
.map(menu -> {
|
||||
ProductContextNavRespVO nav = new ProductContextNavRespVO();
|
||||
nav.setId(menu.getId());
|
||||
nav.setName(menu.getName());
|
||||
nav.setPath(menu.getPath());
|
||||
nav.setIcon(menu.getIcon());
|
||||
nav.setSort(menu.getSort());
|
||||
return nav;
|
||||
})
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
navs.sort(Comparator.comparing(ProductContextNavRespVO::getSort, Comparator.nullsLast(Integer::compareTo))
|
||||
.thenComparing(ProductContextNavRespVO::getId, Comparator.nullsLast(Long::compareTo)));
|
||||
return navs;
|
||||
}
|
||||
|
||||
private List<String> buildContextButtons(List<SystemMenuDO> menus) {
|
||||
if (menus.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return menus.stream()
|
||||
.filter(menu -> MenuTypeEnum.BUTTON.getType().equals(menu.getType()))
|
||||
.map(SystemMenuDO::getPermission)
|
||||
.filter(StringUtils::hasText)
|
||||
.map(String::trim)
|
||||
.distinct()
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private void writeProductStatusLog(ProductDO product, String actionType, String fromStatus,
|
||||
String toStatus, String reason) {
|
||||
ProductStatusLogDO statusLog = new ProductStatusLogDO();
|
||||
@@ -301,7 +499,56 @@ public class ProductServiceImpl implements ProductService {
|
||||
bizAuditLogMapper.insert(auditLog);
|
||||
}
|
||||
|
||||
private String buildFieldChanges(ProductDO before, ProductDO after) {
|
||||
private void writeMemberInitAuditLog(UserObjectRoleDO member) {
|
||||
BizAuditLogDO auditLog = new BizAuditLogDO();
|
||||
auditLog.setBizType(AUDIT_BIZ_TYPE_MEMBER);
|
||||
auditLog.setBizId(member.getId());
|
||||
auditLog.setActionType(PRODUCT_ADD_MEMBER_ACTION);
|
||||
auditLog.setFieldChanges(buildMemberFieldChanges(member));
|
||||
auditLog.setOperatorUserId(SecurityFrameworkUtils.getLoginUserId());
|
||||
auditLog.setOperatorName(defaultText(SecurityFrameworkUtils.getLoginUserNickname()));
|
||||
bizAuditLogMapper.insert(auditLog);
|
||||
}
|
||||
|
||||
private void writeManagerInitAuditLog(Long productId, Long managerUserId) {
|
||||
BizAuditLogDO auditLog = new BizAuditLogDO();
|
||||
auditLog.setBizType(PRODUCT_OBJECT_TYPE);
|
||||
auditLog.setBizId(productId);
|
||||
auditLog.setActionType(PRODUCT_CHANGE_MANAGER_ACTION);
|
||||
auditLog.setFieldChanges(buildManagerFieldChanges(null, managerUserId));
|
||||
auditLog.setOperatorUserId(SecurityFrameworkUtils.getLoginUserId());
|
||||
auditLog.setOperatorName(defaultText(SecurityFrameworkUtils.getLoginUserNickname()));
|
||||
bizAuditLogMapper.insert(auditLog);
|
||||
}
|
||||
|
||||
private ProductDO cloneProduct(ProductDO source) {
|
||||
ProductDO target = new ProductDO();
|
||||
target.setId(source.getId());
|
||||
target.setCode(source.getCode());
|
||||
target.setDirectionCode(source.getDirectionCode());
|
||||
target.setStatusCode(source.getStatusCode());
|
||||
target.setName(source.getName());
|
||||
target.setManagerUserId(source.getManagerUserId());
|
||||
target.setDescription(source.getDescription());
|
||||
target.setLastStatusReason(source.getLastStatusReason());
|
||||
return target;
|
||||
}
|
||||
|
||||
private void applyProductBaseInfoUpdate(ProductDO product, String directionCode, String name, String description) {
|
||||
validateProductEditable(product, directionCode, name);
|
||||
validateProductNameUnique(product.getId(), name);
|
||||
|
||||
ProductDO before = cloneProduct(product);
|
||||
product.setDirectionCode(directionCode);
|
||||
product.setName(name.trim());
|
||||
product.setDescription(normalizeNullableText(description));
|
||||
productMapper.updateById(product);
|
||||
|
||||
writeBizAuditLog(product, PRODUCT_UPDATE_ACTION, before.getStatusCode(), product.getStatusCode(),
|
||||
buildProductFieldChanges(before, product), null);
|
||||
}
|
||||
|
||||
private String buildProductFieldChanges(ProductDO before, ProductDO after) {
|
||||
Map<String, Object> fieldChanges = new LinkedHashMap<>();
|
||||
appendFieldChange(fieldChanges, "code", valueOf(before, ProductDO::getCode), valueOf(after, ProductDO::getCode));
|
||||
appendFieldChange(fieldChanges, "directionCode", valueOf(before, ProductDO::getDirectionCode),
|
||||
@@ -315,10 +562,26 @@ public class ProductServiceImpl implements ProductService {
|
||||
valueOf(after, ProductDO::getDescription));
|
||||
appendFieldChange(fieldChanges, "lastStatusReason", valueOf(before, ProductDO::getLastStatusReason),
|
||||
valueOf(after, ProductDO::getLastStatusReason));
|
||||
appendFieldChange(fieldChanges, "remark", valueOf(before, ProductDO::getRemark), valueOf(after, ProductDO::getRemark));
|
||||
return fieldChanges.isEmpty() ? null : JsonUtils.toJsonString(fieldChanges);
|
||||
}
|
||||
|
||||
private String buildMemberFieldChanges(UserObjectRoleDO member) {
|
||||
Map<String, Object> fieldChanges = new LinkedHashMap<>();
|
||||
appendFieldChange(fieldChanges, "userId", null, member.getUserId());
|
||||
appendFieldChange(fieldChanges, "roleId", null, member.getRoleId());
|
||||
appendFieldChange(fieldChanges, "status", null, member.getStatus());
|
||||
appendFieldChange(fieldChanges, "joinedTime", null, member.getJoinedTime());
|
||||
appendFieldChange(fieldChanges, "leftTime", null, member.getLeftTime());
|
||||
appendFieldChange(fieldChanges, "remark", null, member.getRemark());
|
||||
return JsonUtils.toJsonString(fieldChanges);
|
||||
}
|
||||
|
||||
private String buildManagerFieldChanges(Long beforeManagerUserId, Long afterManagerUserId) {
|
||||
Map<String, Object> fieldChanges = new LinkedHashMap<>();
|
||||
appendFieldChange(fieldChanges, "managerUserId", beforeManagerUserId, afterManagerUserId);
|
||||
return JsonUtils.toJsonString(fieldChanges);
|
||||
}
|
||||
|
||||
private <T> T valueOf(ProductDO product, Function<ProductDO, T> getter) {
|
||||
return product == null ? null : getter.apply(product);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.njcn.rdms.module.project.service.product;
|
||||
|
||||
import com.njcn.rdms.framework.common.pojo.PageResult;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.activity.ProductActivityPageReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.activity.ProductActivityRespVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.setting.ProductSettingRespVO;
|
||||
|
||||
/**
|
||||
* 产品设置 Service 接口
|
||||
*/
|
||||
public interface ProductSettingService {
|
||||
|
||||
/**
|
||||
* 获取产品设置
|
||||
*
|
||||
* @param productId 产品编号
|
||||
* @return 产品设置
|
||||
*/
|
||||
ProductSettingRespVO getProductSettings(Long productId);
|
||||
|
||||
/**
|
||||
* 获取产品动态
|
||||
*
|
||||
* @param productId 产品编号
|
||||
* @param reqVO 查询参数
|
||||
* @return 产品动态分页
|
||||
*/
|
||||
PageResult<ProductActivityRespVO> getProductActivities(Long productId, ProductActivityPageReqVO reqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.njcn.rdms.module.project.service.product;
|
||||
|
||||
import com.njcn.rdms.framework.common.pojo.CommonResult;
|
||||
import com.njcn.rdms.framework.common.pojo.PageResult;
|
||||
import com.njcn.rdms.module.project.framework.security.annotation.CheckObjectPermission;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.activity.ProductActivityPageReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.activity.ProductActivityRespVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.setting.ProductSettingBaseInfoRespVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.setting.ProductSettingLifecycleRespVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.setting.ProductSettingRespVO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.product.ProductDO;
|
||||
import com.njcn.rdms.module.project.dal.mysql.product.ProductMapper;
|
||||
import com.njcn.rdms.module.project.enums.ErrorCodeConstants;
|
||||
import com.njcn.rdms.module.system.api.user.AdminUserApi;
|
||||
import com.njcn.rdms.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import static com.njcn.rdms.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
@Service
|
||||
public class ProductSettingServiceImpl implements ProductSettingService {
|
||||
|
||||
private static final String PRODUCT_OBJECT_TYPE = "product";
|
||||
private static final String PRODUCT_QUERY_PERMISSION = "project:product:query";
|
||||
|
||||
@Resource
|
||||
private ProductMapper productMapper;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
@Resource
|
||||
private ProductStatusViewService productStatusViewService;
|
||||
@Resource
|
||||
private ProductActivityQueryService productActivityQueryService;
|
||||
|
||||
@Override
|
||||
@CheckObjectPermission(objectType = PRODUCT_OBJECT_TYPE, objectId = "#productId",
|
||||
permission = PRODUCT_QUERY_PERMISSION)
|
||||
public ProductSettingRespVO getProductSettings(Long productId) {
|
||||
ProductDO product = validateProductExists(productId);
|
||||
ProductSettingRespVO respVO = new ProductSettingRespVO();
|
||||
respVO.setBaseInfo(buildBaseInfo(product));
|
||||
respVO.setLifecycle(buildLifecycle(product));
|
||||
return respVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@CheckObjectPermission(objectType = PRODUCT_OBJECT_TYPE, objectId = "#productId",
|
||||
permission = PRODUCT_QUERY_PERMISSION)
|
||||
public PageResult<ProductActivityRespVO> getProductActivities(Long productId, ProductActivityPageReqVO reqVO) {
|
||||
validateProductExists(productId);
|
||||
return productActivityQueryService.getProductActivities(productId, reqVO);
|
||||
}
|
||||
|
||||
private ProductDO validateProductExists(Long productId) {
|
||||
if (productId == null) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_NOT_EXISTS);
|
||||
}
|
||||
ProductDO product = productMapper.selectById(productId);
|
||||
if (product == null) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_NOT_EXISTS);
|
||||
}
|
||||
return product;
|
||||
}
|
||||
|
||||
private ProductSettingBaseInfoRespVO buildBaseInfo(ProductDO product) {
|
||||
ProductSettingBaseInfoRespVO baseInfo = new ProductSettingBaseInfoRespVO();
|
||||
baseInfo.setId(product.getId());
|
||||
baseInfo.setCode(product.getCode());
|
||||
baseInfo.setDirectionCode(product.getDirectionCode());
|
||||
baseInfo.setName(product.getName());
|
||||
baseInfo.setManagerUserId(product.getManagerUserId());
|
||||
baseInfo.setManagerUserNickname(getManagerNickname(product.getManagerUserId()));
|
||||
baseInfo.setDescription(product.getDescription());
|
||||
baseInfo.setStatusCode(product.getStatusCode());
|
||||
baseInfo.setLastStatusReason(product.getLastStatusReason());
|
||||
return baseInfo;
|
||||
}
|
||||
|
||||
private ProductSettingLifecycleRespVO buildLifecycle(ProductDO product) {
|
||||
return productStatusViewService.getLifecycle(product.getStatusCode(), product.getLastStatusReason());
|
||||
}
|
||||
|
||||
private String getManagerNickname(Long managerUserId) {
|
||||
if (managerUserId == null) {
|
||||
return null;
|
||||
}
|
||||
CommonResult<AdminUserRespDTO> result = adminUserApi.getUser(managerUserId);
|
||||
AdminUserRespDTO user = result == null ? null : result.getCheckedData();
|
||||
return user == null ? null : user.getNickname();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.njcn.rdms.module.project.service.product;
|
||||
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.setting.ProductSettingActionRespVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.setting.ProductSettingLifecycleRespVO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.status.ObjectStatusModelDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.status.ObjectStatusTransitionDO;
|
||||
import com.njcn.rdms.module.project.dal.mysql.status.ObjectStatusModelMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.status.ObjectStatusTransitionMapper;
|
||||
import com.njcn.rdms.module.project.enums.ErrorCodeConstants;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.njcn.rdms.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
@Service
|
||||
public class ProductStatusViewService {
|
||||
|
||||
private static final String PRODUCT_OBJECT_TYPE = "product";
|
||||
|
||||
@Resource
|
||||
private ObjectStatusModelMapper objectStatusModelMapper;
|
||||
@Resource
|
||||
private ObjectStatusTransitionMapper objectStatusTransitionMapper;
|
||||
|
||||
public ProductSettingLifecycleRespVO getLifecycle(String statusCode, String lastStatusReason) {
|
||||
ObjectStatusModelDO statusModel = objectStatusModelMapper
|
||||
.selectByObjectTypeAndStatusCodeEnabled(PRODUCT_OBJECT_TYPE, statusCode);
|
||||
if (statusModel == null) {
|
||||
throw exception(ErrorCodeConstants.PRODUCT_STATUS_MODEL_NOT_EXISTS_OR_DISABLED);
|
||||
}
|
||||
|
||||
ProductSettingLifecycleRespVO lifecycle = new ProductSettingLifecycleRespVO();
|
||||
lifecycle.setStatusCode(statusModel.getStatusCode());
|
||||
lifecycle.setStatusName(statusModel.getStatusName());
|
||||
lifecycle.setTerminal(statusModel.getTerminalFlag());
|
||||
lifecycle.setAllowEdit(statusModel.getAllowEdit());
|
||||
lifecycle.setLastStatusReason(lastStatusReason);
|
||||
lifecycle.setAvailableActions(buildAvailableActions(statusCode));
|
||||
return lifecycle;
|
||||
}
|
||||
|
||||
private List<ProductSettingActionRespVO> buildAvailableActions(String statusCode) {
|
||||
List<ObjectStatusTransitionDO> transitions = objectStatusTransitionMapper
|
||||
.selectListByObjectTypeAndFromStatus(PRODUCT_OBJECT_TYPE, statusCode);
|
||||
if (transitions == null || transitions.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return transitions.stream().map(transition -> {
|
||||
ProductSettingActionRespVO action = new ProductSettingActionRespVO();
|
||||
action.setActionCode(transition.getActionCode());
|
||||
action.setActionName(transition.getActionName());
|
||||
action.setNeedReason(transition.getNeedReason());
|
||||
return action;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.njcn.rdms.module.project.framework.security.aop;
|
||||
|
||||
import com.njcn.rdms.framework.test.core.ut.BaseMockitoUnitTest;
|
||||
import com.njcn.rdms.module.project.framework.security.annotation.CheckObjectPermission;
|
||||
import com.njcn.rdms.module.project.framework.security.service.ObjectPermissionService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.springframework.aop.aspectj.annotation.AspectJProxyFactory;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class ObjectPermissionAspectTest extends BaseMockitoUnitTest {
|
||||
|
||||
@Mock
|
||||
private ObjectPermissionService objectPermissionService;
|
||||
|
||||
@Test
|
||||
void around_shouldResolveProductIdFromMethodArgument() {
|
||||
when(objectPermissionService.getObjectType()).thenReturn("product");
|
||||
DemoService proxy = createProxy();
|
||||
|
||||
String result = proxy.getProduct(1001L);
|
||||
|
||||
assertEquals("ok", result);
|
||||
verify(objectPermissionService, times(1))
|
||||
.checkPermission(1001L, "project:product:query", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
void around_shouldResolveProductIdFromReqVoAndPassMemberOnlyFlag() {
|
||||
when(objectPermissionService.getObjectType()).thenReturn("product");
|
||||
DemoService proxy = createProxy();
|
||||
DemoReqVO reqVO = new DemoReqVO();
|
||||
reqVO.setId(1002L);
|
||||
|
||||
String result = proxy.getProductContext(reqVO);
|
||||
|
||||
assertEquals("context", result);
|
||||
verify(objectPermissionService, times(1))
|
||||
.checkPermission(1002L, "", true);
|
||||
}
|
||||
|
||||
private DemoService createProxy() {
|
||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new DemoService());
|
||||
proxyFactory.addAspect(new ObjectPermissionAspect(java.util.List.of(objectPermissionService)));
|
||||
return proxyFactory.getProxy();
|
||||
}
|
||||
|
||||
static class DemoService {
|
||||
|
||||
@CheckObjectPermission(objectType = "product", objectId = "#productId", permission = "project:product:query")
|
||||
public String getProduct(Long productId) {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@CheckObjectPermission(objectType = "product", objectId = "#reqVO.id", memberOnly = true)
|
||||
public String getProductContext(DemoReqVO reqVO) {
|
||||
return "context";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class DemoReqVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.njcn.rdms.module.project.framework.security.service;
|
||||
|
||||
import com.njcn.rdms.framework.common.exception.ServiceException;
|
||||
import com.njcn.rdms.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.njcn.rdms.framework.test.core.ut.BaseMockitoUnitTest;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.member.UserObjectRoleDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.permission.SystemMenuDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.permission.SystemRoleMenuDO;
|
||||
import com.njcn.rdms.module.project.dal.mysql.member.UserObjectRoleMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.permission.SystemMenuMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.permission.SystemRoleMenuMapper;
|
||||
import com.njcn.rdms.module.project.enums.ErrorCodeConstants;
|
||||
import com.njcn.rdms.module.system.enums.permission.MenuTypeEnum;
|
||||
import com.njcn.rdms.module.system.enums.permission.PermissionScopeTypeEnum;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockedStatic;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mockStatic;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class ProductObjectPermissionServiceTest extends BaseMockitoUnitTest {
|
||||
|
||||
@InjectMocks
|
||||
private ProductObjectPermissionService permissionService;
|
||||
@Mock
|
||||
private UserObjectRoleMapper userObjectRoleMapper;
|
||||
@Mock
|
||||
private SystemRoleMenuMapper systemRoleMenuMapper;
|
||||
@Mock
|
||||
private SystemMenuMapper systemMenuMapper;
|
||||
|
||||
@Test
|
||||
void checkPermission_whenMemberOnlyAndCurrentUserIsMember_shouldPass() {
|
||||
Long productId = 1001L;
|
||||
Long loginUserId = 2001L;
|
||||
when(userObjectRoleMapper.selectActiveByObjectAndUserId("product", productId, loginUserId))
|
||||
.thenReturn(createMember(productId, loginUserId, 3001L));
|
||||
|
||||
try (MockedStatic<SecurityFrameworkUtils> mockedStatic = mockLoginUser(loginUserId)) {
|
||||
assertDoesNotThrow(() -> permissionService.checkPermission(productId, null, true));
|
||||
}
|
||||
|
||||
verifyNoInteractions(systemRoleMenuMapper, systemMenuMapper);
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkPermission_whenQueryPermissionConfiguredOnMenuNode_shouldPass() {
|
||||
Long productId = 1002L;
|
||||
Long loginUserId = 2002L;
|
||||
when(userObjectRoleMapper.selectActiveByObjectAndUserId("product", productId, loginUserId))
|
||||
.thenReturn(createMember(productId, loginUserId, 3002L));
|
||||
when(systemRoleMenuMapper.selectListByRoleId(3002L))
|
||||
.thenReturn(List.of(createRoleMenu(3002L, 4002L)));
|
||||
when(systemMenuMapper.selectListByIdsAndScopeAndObjectType(any(),
|
||||
eq(PermissionScopeTypeEnum.OBJECT.getScopeType()), eq("product")))
|
||||
.thenReturn(List.of(createMenu(4002L, MenuTypeEnum.MENU.getType(), "project:product:query")));
|
||||
|
||||
try (MockedStatic<SecurityFrameworkUtils> mockedStatic = mockLoginUser(loginUserId)) {
|
||||
assertDoesNotThrow(() -> permissionService.checkPermission(productId, "project:product:query", false));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkPermission_whenCurrentRoleDoesNotContainPermission_shouldThrowException() {
|
||||
Long productId = 1003L;
|
||||
Long loginUserId = 2003L;
|
||||
when(userObjectRoleMapper.selectActiveByObjectAndUserId("product", productId, loginUserId))
|
||||
.thenReturn(createMember(productId, loginUserId, 3003L));
|
||||
when(systemRoleMenuMapper.selectListByRoleId(3003L))
|
||||
.thenReturn(List.of(createRoleMenu(3003L, 4003L)));
|
||||
when(systemMenuMapper.selectListByIdsAndScopeAndObjectType(any(),
|
||||
eq(PermissionScopeTypeEnum.OBJECT.getScopeType()), eq("product")))
|
||||
.thenReturn(List.of(createMenu(4003L, MenuTypeEnum.BUTTON.getType(), "project:product:update")));
|
||||
|
||||
try (MockedStatic<SecurityFrameworkUtils> mockedStatic = mockLoginUser(loginUserId)) {
|
||||
ServiceException ex = assertThrows(ServiceException.class,
|
||||
() -> permissionService.checkPermission(productId, "project:product:delete", false));
|
||||
assertEquals(ErrorCodeConstants.PRODUCT_OBJECT_PERMISSION_DENIED.getCode(), ex.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
private UserObjectRoleDO createMember(Long productId, Long loginUserId, Long roleId) {
|
||||
UserObjectRoleDO member = new UserObjectRoleDO();
|
||||
member.setId(9001L);
|
||||
member.setUserId(loginUserId);
|
||||
member.setObjectType("product");
|
||||
member.setObjectId(productId);
|
||||
member.setRoleId(roleId);
|
||||
member.setStatus(0);
|
||||
return member;
|
||||
}
|
||||
|
||||
private SystemRoleMenuDO createRoleMenu(Long roleId, Long menuId) {
|
||||
SystemRoleMenuDO roleMenu = new SystemRoleMenuDO();
|
||||
roleMenu.setId(9101L);
|
||||
roleMenu.setRoleId(roleId);
|
||||
roleMenu.setMenuId(menuId);
|
||||
return roleMenu;
|
||||
}
|
||||
|
||||
private SystemMenuDO createMenu(Long menuId, Integer type, String permission) {
|
||||
SystemMenuDO menu = new SystemMenuDO();
|
||||
menu.setId(menuId);
|
||||
menu.setType(type);
|
||||
menu.setPermission(permission);
|
||||
menu.setScopeType(PermissionScopeTypeEnum.OBJECT.getScopeType());
|
||||
menu.setObjectType("product");
|
||||
menu.setStatus(0);
|
||||
return menu;
|
||||
}
|
||||
|
||||
private MockedStatic<SecurityFrameworkUtils> mockLoginUser(Long loginUserId) {
|
||||
MockedStatic<SecurityFrameworkUtils> mockedStatic = mockStatic(SecurityFrameworkUtils.class);
|
||||
mockedStatic.when(SecurityFrameworkUtils::getLoginUserId).thenReturn(loginUserId);
|
||||
return mockedStatic;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.njcn.rdms.module.project.service.product;
|
||||
|
||||
import com.njcn.rdms.framework.common.pojo.PageResult;
|
||||
import com.njcn.rdms.framework.test.core.ut.BaseMockitoUnitTest;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.activity.ProductActivityPageReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.activity.ProductActivityRespVO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.audit.BizAuditLogDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.member.UserObjectRoleDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.product.ProductStatusLogDO;
|
||||
import com.njcn.rdms.module.project.dal.mysql.audit.BizAuditLogMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.member.UserObjectRoleMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.product.ProductStatusLogMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class ProductActivityQueryServiceTest extends BaseMockitoUnitTest {
|
||||
|
||||
@InjectMocks
|
||||
private ProductActivityQueryService productActivityQueryService;
|
||||
@Mock
|
||||
private ProductStatusLogMapper productStatusLogMapper;
|
||||
@Mock
|
||||
private BizAuditLogMapper bizAuditLogMapper;
|
||||
@Mock
|
||||
private UserObjectRoleMapper userObjectRoleMapper;
|
||||
|
||||
@Test
|
||||
void getProductActivities_shouldMergeStatusProductAndMemberActivities() {
|
||||
Long productId = 1001L;
|
||||
ProductActivityPageReqVO reqVO = new ProductActivityPageReqVO();
|
||||
reqVO.setPageNo(1);
|
||||
reqVO.setPageSize(10);
|
||||
|
||||
ProductStatusLogDO statusLog = new ProductStatusLogDO();
|
||||
statusLog.setId(11L);
|
||||
statusLog.setProductId(productId);
|
||||
statusLog.setActionType("pause");
|
||||
statusLog.setOperatorName("张三");
|
||||
statusLog.setReason("资源不足");
|
||||
statusLog.setCreateTime(LocalDateTime.of(2026, 4, 21, 10, 0, 0));
|
||||
|
||||
BizAuditLogDO productAudit = new BizAuditLogDO();
|
||||
productAudit.setId(22L);
|
||||
productAudit.setBizType("product");
|
||||
productAudit.setBizId(productId);
|
||||
productAudit.setActionType("update");
|
||||
productAudit.setOperatorName("李四");
|
||||
productAudit.setCreateTime(LocalDateTime.of(2026, 4, 21, 11, 0, 0));
|
||||
|
||||
BizAuditLogDO memberAudit = new BizAuditLogDO();
|
||||
memberAudit.setId(33L);
|
||||
memberAudit.setBizType("rdms_user_object_role");
|
||||
memberAudit.setBizId(9001L);
|
||||
memberAudit.setActionType("add_member");
|
||||
memberAudit.setOperatorName("王五");
|
||||
memberAudit.setCreateTime(LocalDateTime.of(2026, 4, 21, 12, 0, 0));
|
||||
|
||||
UserObjectRoleDO member = new UserObjectRoleDO();
|
||||
member.setId(9001L);
|
||||
member.setObjectType("product");
|
||||
member.setObjectId(productId);
|
||||
|
||||
when(productStatusLogMapper.selectListByProductId(productId, null, null))
|
||||
.thenReturn(List.of(statusLog));
|
||||
when(bizAuditLogMapper.selectListByBiz("product", productId, null, null))
|
||||
.thenReturn(List.of(productAudit));
|
||||
when(bizAuditLogMapper.selectListByBizType("rdms_user_object_role", null, null))
|
||||
.thenReturn(List.of(memberAudit));
|
||||
when(userObjectRoleMapper.selectListByIdsAndObject(List.of(9001L), "product", productId))
|
||||
.thenReturn(List.of(member));
|
||||
|
||||
PageResult<ProductActivityRespVO> result = productActivityQueryService.getProductActivities(productId, reqVO);
|
||||
|
||||
assertEquals(3L, result.getTotal());
|
||||
assertEquals("member", result.getList().get(0).getType());
|
||||
assertEquals("product", result.getList().get(1).getType());
|
||||
assertEquals("status", result.getList().get(2).getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getProductActivities_shouldIgnoreOrphanMemberAuditAndFilterByType() {
|
||||
Long productId = 1002L;
|
||||
ProductActivityPageReqVO reqVO = new ProductActivityPageReqVO();
|
||||
reqVO.setPageNo(1);
|
||||
reqVO.setPageSize(10);
|
||||
reqVO.setActivityType("member");
|
||||
|
||||
BizAuditLogDO orphanMemberAudit = new BizAuditLogDO();
|
||||
orphanMemberAudit.setId(44L);
|
||||
orphanMemberAudit.setBizType("rdms_user_object_role");
|
||||
orphanMemberAudit.setBizId(9900L);
|
||||
orphanMemberAudit.setActionType("remove_member");
|
||||
orphanMemberAudit.setCreateTime(LocalDateTime.of(2026, 4, 21, 9, 0, 0));
|
||||
|
||||
when(bizAuditLogMapper.selectListByBizType("rdms_user_object_role", null, null))
|
||||
.thenReturn(List.of(orphanMemberAudit));
|
||||
when(userObjectRoleMapper.selectListByIdsAndObject(List.of(9900L), "product", productId))
|
||||
.thenReturn(List.of());
|
||||
|
||||
PageResult<ProductActivityRespVO> result = productActivityQueryService.getProductActivities(productId, reqVO);
|
||||
|
||||
assertEquals(0L, result.getTotal());
|
||||
assertEquals(0, result.getList().size());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,448 @@
|
||||
package com.njcn.rdms.module.project.service.product;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.njcn.rdms.framework.common.exception.ServiceException;
|
||||
import com.njcn.rdms.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.njcn.rdms.framework.common.util.json.JsonUtils;
|
||||
import com.njcn.rdms.framework.test.core.ut.BaseMockitoUnitTest;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductDeleteReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductSaveReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.product.ProductStatusActionReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.setting.ProductSettingBaseInfoUpdateReqVO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.audit.BizAuditLogDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.member.UserObjectRoleDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.permission.SystemMenuDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.permission.SystemRoleMenuDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.product.ProductDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.product.ProductStatusLogDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.status.ObjectStatusTransitionDO;
|
||||
import com.njcn.rdms.module.project.dal.mysql.audit.BizAuditLogMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.member.UserObjectRoleMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.permission.SystemMenuMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.permission.SystemRoleMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.permission.SystemRoleMenuMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.product.ProductMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.product.ProductStatusLogMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.status.ObjectStatusTransitionMapper;
|
||||
import com.njcn.rdms.module.project.enums.ErrorCodeConstants;
|
||||
import com.njcn.rdms.module.system.api.user.AdminUserApi;
|
||||
import com.njcn.rdms.module.system.enums.permission.MenuTypeEnum;
|
||||
import com.njcn.rdms.module.system.enums.permission.PermissionScopeTypeEnum;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.Mock;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mockStatic;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class ProductServiceImplTest extends BaseMockitoUnitTest {
|
||||
|
||||
@InjectMocks
|
||||
private ProductServiceImpl productService;
|
||||
@Mock
|
||||
private ProductMapper productMapper;
|
||||
@Mock
|
||||
private ProductStatusLogMapper productStatusLogMapper;
|
||||
@Mock
|
||||
private BizAuditLogMapper bizAuditLogMapper;
|
||||
@Mock
|
||||
private ObjectStatusTransitionMapper objectStatusTransitionMapper;
|
||||
@Mock
|
||||
private UserObjectRoleMapper userObjectRoleMapper;
|
||||
@Mock
|
||||
private SystemRoleMapper systemRoleMapper;
|
||||
@Mock
|
||||
private SystemRoleMenuMapper systemRoleMenuMapper;
|
||||
@Mock
|
||||
private SystemMenuMapper systemMenuMapper;
|
||||
@Mock
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Test
|
||||
void updateProductBaseInfo_shouldOnlyUpdateBaseInfoAndRecordFieldChanges() {
|
||||
Long productId = 1002L;
|
||||
ProductDO product = createProduct(productId, "direction_value", "旧产品", 2003L, "旧描述", "active");
|
||||
ProductSettingBaseInfoUpdateReqVO reqVO = new ProductSettingBaseInfoUpdateReqVO();
|
||||
reqVO.setDirectionCode("direction_value_updated");
|
||||
reqVO.setName("新产品");
|
||||
reqVO.setDescription(" 新描述 ");
|
||||
|
||||
when(productMapper.selectById(productId)).thenReturn(product);
|
||||
when(productMapper.selectByName("新产品")).thenReturn(null);
|
||||
|
||||
productService.updateProductBaseInfo(productId, reqVO);
|
||||
|
||||
ProductDO updated = captureUpdatedProduct();
|
||||
assertProductBaseInfoUpdated(updated, "CNPD2026002", 2003L, "active",
|
||||
"direction_value_updated", "新产品", "新描述");
|
||||
|
||||
BizAuditLogDO auditLog = captureAuditLog();
|
||||
assertAuditFieldChanges(auditLog, productId, "direction_value", "direction_value_updated",
|
||||
"旧产品", "新产品", "旧描述", "新描述");
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateProduct_shouldReuseBaseInfoUpdateFlow() {
|
||||
Long productId = 1003L;
|
||||
ProductDO product = createProduct(productId, "direction_value", "旧产品", 2004L, "旧描述", "active");
|
||||
ProductSaveReqVO reqVO = new ProductSaveReqVO();
|
||||
reqVO.setId(productId);
|
||||
reqVO.setCode("CNPD2026003");
|
||||
reqVO.setDirectionCode("direction_value_updated");
|
||||
reqVO.setName("新产品");
|
||||
reqVO.setManagerUserId(2004L);
|
||||
reqVO.setDescription(" 新描述 ");
|
||||
|
||||
when(productMapper.selectById(productId)).thenReturn(product);
|
||||
when(productMapper.selectByName("新产品")).thenReturn(null);
|
||||
|
||||
productService.updateProduct(reqVO);
|
||||
|
||||
ProductDO updated = captureUpdatedProduct();
|
||||
assertProductBaseInfoUpdated(updated, "CNPD2026003", 2004L, "active",
|
||||
"direction_value_updated", "新产品", "新描述");
|
||||
|
||||
BizAuditLogDO auditLog = captureAuditLog();
|
||||
assertAuditFieldChanges(auditLog, productId, "direction_value", "direction_value_updated",
|
||||
"旧产品", "新产品", "旧描述", "新描述");
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateProduct_whenManagerUserIdChanged_shouldThrowException() {
|
||||
Long productId = 1002L;
|
||||
ProductDO product = createProduct(productId, "direction_value", "旧产品", 2005L, "旧描述", "active");
|
||||
ProductSaveReqVO reqVO = new ProductSaveReqVO();
|
||||
reqVO.setId(productId);
|
||||
reqVO.setCode("CNPD2026002");
|
||||
reqVO.setDirectionCode("direction_value_updated");
|
||||
reqVO.setName("新产品");
|
||||
reqVO.setManagerUserId(2006L);
|
||||
reqVO.setDescription("新描述");
|
||||
|
||||
when(productMapper.selectById(productId)).thenReturn(product);
|
||||
|
||||
ServiceException ex = assertThrows(ServiceException.class,
|
||||
() -> productService.updateProduct(reqVO));
|
||||
assertEquals(ErrorCodeConstants.PRODUCT_MANAGER_NOT_MODIFIABLE.getCode(), ex.getCode());
|
||||
verify(productMapper, never()).updateById(any(ProductDO.class));
|
||||
verify(bizAuditLogMapper, never()).insert(any(BizAuditLogDO.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateProductBaseInfo_whenPausedAndDirectionOrNameChanged_shouldThrowException() {
|
||||
Long productId = 1004L;
|
||||
ProductDO product = createProduct(productId, "direction_value", "暂停产品", 2007L, "旧描述", "paused");
|
||||
ProductSettingBaseInfoUpdateReqVO reqVO = new ProductSettingBaseInfoUpdateReqVO();
|
||||
reqVO.setDirectionCode("direction_value_updated");
|
||||
reqVO.setName("暂停产品");
|
||||
reqVO.setDescription("新描述");
|
||||
|
||||
when(productMapper.selectById(productId)).thenReturn(product);
|
||||
|
||||
ServiceException ex = assertThrows(ServiceException.class,
|
||||
() -> productService.updateProductBaseInfo(productId, reqVO));
|
||||
assertEquals(ErrorCodeConstants.PRODUCT_PAUSED_ONLY_ALLOW_LIMITED_UPDATE.getCode(), ex.getCode());
|
||||
verify(productMapper, never()).updateById(any(ProductDO.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void changeProductStatus_shouldUpdateStatusByConditionAndWriteLogs() {
|
||||
Long productId = 1006L;
|
||||
Long loginUserId = 3002L;
|
||||
ProductDO product = createProduct(productId, "direction_value", "产品B", 2009L, "旧描述", "active");
|
||||
ProductStatusActionReqVO reqVO = new ProductStatusActionReqVO();
|
||||
reqVO.setId(productId);
|
||||
reqVO.setActionCode("pause");
|
||||
reqVO.setReason("环境受限");
|
||||
|
||||
when(productMapper.selectById(productId)).thenReturn(product);
|
||||
when(objectStatusTransitionMapper.selectByObjectTypeAndFromStatusAndAction("product", "active", "pause"))
|
||||
.thenReturn(createTransition("pause", "paused", true));
|
||||
when(productMapper.updateStatusByIdAndStatus(productId, "active", "paused", "环境受限")).thenReturn(1);
|
||||
|
||||
try (MockedStatic<SecurityFrameworkUtils> mockedStatic = mockLoginUser(loginUserId, "测试人")) {
|
||||
productService.changeProductStatus(reqVO);
|
||||
}
|
||||
|
||||
verify(productMapper, times(1)).updateStatusByIdAndStatus(productId, "active", "paused", "环境受限");
|
||||
|
||||
ArgumentCaptor<ProductStatusLogDO> statusLogCaptor = ArgumentCaptor.forClass(ProductStatusLogDO.class);
|
||||
verify(productStatusLogMapper, times(1)).insert(statusLogCaptor.capture());
|
||||
assertEquals("pause", statusLogCaptor.getValue().getActionType());
|
||||
assertEquals("active", statusLogCaptor.getValue().getFromStatus());
|
||||
assertEquals("paused", statusLogCaptor.getValue().getToStatus());
|
||||
assertEquals("环境受限", statusLogCaptor.getValue().getReason());
|
||||
|
||||
BizAuditLogDO auditLog = captureAuditLog();
|
||||
assertEquals("pause", auditLog.getActionType());
|
||||
assertEquals("active", auditLog.getFromStatus());
|
||||
assertEquals("paused", auditLog.getToStatus());
|
||||
assertEquals("环境受限", auditLog.getReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
void changeProductStatus_whenConditionalUpdateReturnsZero_shouldThrowException() {
|
||||
Long productId = 1007L;
|
||||
Long loginUserId = 3003L;
|
||||
ProductDO product = createProduct(productId, "direction_value", "产品C", 2010L, "旧描述", "active");
|
||||
ProductStatusActionReqVO reqVO = new ProductStatusActionReqVO();
|
||||
reqVO.setId(productId);
|
||||
reqVO.setActionCode("pause");
|
||||
reqVO.setReason("环境受限");
|
||||
|
||||
when(productMapper.selectById(productId)).thenReturn(product);
|
||||
when(objectStatusTransitionMapper.selectByObjectTypeAndFromStatusAndAction("product", "active", "pause"))
|
||||
.thenReturn(createTransition("pause", "paused", true));
|
||||
when(productMapper.updateStatusByIdAndStatus(productId, "active", "paused", "环境受限")).thenReturn(0);
|
||||
|
||||
try (MockedStatic<SecurityFrameworkUtils> mockedStatic = mockLoginUser(loginUserId, "测试人")) {
|
||||
ServiceException ex = assertThrows(ServiceException.class,
|
||||
() -> productService.changeProductStatus(reqVO));
|
||||
assertEquals(ErrorCodeConstants.PRODUCT_STATUS_CONCURRENT_MODIFIED.getCode(), ex.getCode());
|
||||
verify(productStatusLogMapper, never()).insert(any(ProductStatusLogDO.class));
|
||||
verify(bizAuditLogMapper, never()).insert(any(BizAuditLogDO.class));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void changeProductStatus_whenActionNotAllowed_shouldThrowException() {
|
||||
Long productId = 1010L;
|
||||
ProductDO product = createProduct(productId, "direction_value", "产品F", 2013L, "旧描述", "archived");
|
||||
ProductStatusActionReqVO reqVO = new ProductStatusActionReqVO();
|
||||
reqVO.setId(productId);
|
||||
reqVO.setActionCode("pause");
|
||||
reqVO.setReason("再次暂停");
|
||||
|
||||
when(productMapper.selectById(productId)).thenReturn(product);
|
||||
when(objectStatusTransitionMapper.selectByObjectTypeAndFromStatusAndAction("product", "archived", "pause"))
|
||||
.thenReturn(null);
|
||||
|
||||
ServiceException ex = assertThrows(ServiceException.class,
|
||||
() -> productService.changeProductStatus(reqVO));
|
||||
assertEquals(ErrorCodeConstants.PRODUCT_STATUS_ACTION_NOT_ALLOWED.getCode(), ex.getCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void changeProductStatus_whenReasonRequiredButMissing_shouldThrowException() {
|
||||
Long productId = 1011L;
|
||||
ProductDO product = createProduct(productId, "direction_value", "产品G", 2014L, "旧描述", "active");
|
||||
ProductStatusActionReqVO reqVO = new ProductStatusActionReqVO();
|
||||
reqVO.setId(productId);
|
||||
reqVO.setActionCode("pause");
|
||||
reqVO.setReason(" ");
|
||||
|
||||
when(productMapper.selectById(productId)).thenReturn(product);
|
||||
when(objectStatusTransitionMapper.selectByObjectTypeAndFromStatusAndAction("product", "active", "pause"))
|
||||
.thenReturn(createTransition("pause", "paused", true));
|
||||
|
||||
ServiceException ex = assertThrows(ServiceException.class,
|
||||
() -> productService.changeProductStatus(reqVO));
|
||||
assertEquals(ErrorCodeConstants.PRODUCT_STATUS_ACTION_REASON_REQUIRED.getCode(), ex.getCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteProduct_whenConfirmTextInvalid_shouldThrowException() {
|
||||
Long productId = 1008L;
|
||||
Long loginUserId = 3004L;
|
||||
ProductDO product = createProduct(productId, "direction_value", "产品D", 2011L, "旧描述", "active");
|
||||
ProductDeleteReqVO reqVO = new ProductDeleteReqVO();
|
||||
reqVO.setId(productId);
|
||||
reqVO.setProductName("产品D");
|
||||
reqVO.setReason("录入错误");
|
||||
reqVO.setConfirmText("WRONG");
|
||||
|
||||
when(productMapper.selectById(productId)).thenReturn(product);
|
||||
|
||||
try (MockedStatic<SecurityFrameworkUtils> mockedStatic = mockLoginUser(loginUserId, "测试人")) {
|
||||
ServiceException ex = assertThrows(ServiceException.class,
|
||||
() -> productService.deleteProduct(reqVO));
|
||||
assertEquals(ErrorCodeConstants.PRODUCT_DELETE_CONFIRM_TEXT_INVALID.getCode(), ex.getCode());
|
||||
verify(productMapper, never()).deleteByIdAndStatus(any(Long.class), any(String.class));
|
||||
verify(productStatusLogMapper, never()).insert(any(ProductStatusLogDO.class));
|
||||
verify(bizAuditLogMapper, never()).insert(any(BizAuditLogDO.class));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteProduct_whenProductNameMismatch_shouldThrowException() {
|
||||
Long productId = 1012L;
|
||||
ProductDO product = createProduct(productId, "direction_value", "产品H", 2015L, "旧描述", "active");
|
||||
ProductDeleteReqVO reqVO = new ProductDeleteReqVO();
|
||||
reqVO.setId(productId);
|
||||
reqVO.setProductName("错误名称");
|
||||
reqVO.setReason("录入错误");
|
||||
reqVO.setConfirmText("DELETE");
|
||||
|
||||
when(productMapper.selectById(productId)).thenReturn(product);
|
||||
|
||||
ServiceException ex = assertThrows(ServiceException.class,
|
||||
() -> productService.deleteProduct(reqVO));
|
||||
assertEquals(ErrorCodeConstants.PRODUCT_DELETE_NAME_MISMATCH.getCode(), ex.getCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteProduct_shouldDeleteByConditionAndWriteLogs() {
|
||||
Long productId = 1009L;
|
||||
Long loginUserId = 3005L;
|
||||
ProductDO product = createProduct(productId, "direction_value", "产品E", 2012L, "旧描述", "active");
|
||||
ProductDeleteReqVO reqVO = new ProductDeleteReqVO();
|
||||
reqVO.setId(productId);
|
||||
reqVO.setProductName("产品E");
|
||||
reqVO.setReason("录入错误");
|
||||
reqVO.setConfirmText("DELETE");
|
||||
|
||||
when(productMapper.selectById(productId)).thenReturn(product);
|
||||
when(productMapper.deleteByIdAndStatus(productId, "active")).thenReturn(1);
|
||||
|
||||
try (MockedStatic<SecurityFrameworkUtils> mockedStatic = mockLoginUser(loginUserId, "测试人")) {
|
||||
productService.deleteProduct(reqVO);
|
||||
}
|
||||
|
||||
verify(productMapper, times(1)).deleteByIdAndStatus(productId, "active");
|
||||
|
||||
ArgumentCaptor<ProductStatusLogDO> statusLogCaptor = ArgumentCaptor.forClass(ProductStatusLogDO.class);
|
||||
verify(productStatusLogMapper, times(1)).insert(statusLogCaptor.capture());
|
||||
assertEquals("delete", statusLogCaptor.getValue().getActionType());
|
||||
assertEquals("active", statusLogCaptor.getValue().getFromStatus());
|
||||
assertNull(statusLogCaptor.getValue().getToStatus());
|
||||
assertEquals("录入错误", statusLogCaptor.getValue().getReason());
|
||||
|
||||
BizAuditLogDO auditLog = captureAuditLog();
|
||||
assertEquals("delete", auditLog.getActionType());
|
||||
assertEquals("active", auditLog.getFromStatus());
|
||||
assertNull(auditLog.getToStatus());
|
||||
assertEquals("录入错误", auditLog.getReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateProductBaseInfo_whenArchived_shouldThrowException() {
|
||||
Long productId = 1013L;
|
||||
ProductDO product = createProduct(productId, "direction_value", "归档产品", 2016L, "旧描述", "archived");
|
||||
ProductSettingBaseInfoUpdateReqVO reqVO = new ProductSettingBaseInfoUpdateReqVO();
|
||||
reqVO.setDirectionCode("direction_value");
|
||||
reqVO.setName("归档产品");
|
||||
reqVO.setDescription("新描述");
|
||||
|
||||
when(productMapper.selectById(productId)).thenReturn(product);
|
||||
|
||||
ServiceException ex = assertThrows(ServiceException.class,
|
||||
() -> productService.updateProductBaseInfo(productId, reqVO));
|
||||
assertEquals(ErrorCodeConstants.PRODUCT_STATUS_NOT_ALLOW_EDIT.getCode(), ex.getCode());
|
||||
}
|
||||
|
||||
private ProductDO createProduct(Long id, String directionCode, String name, Long managerUserId,
|
||||
String description, String statusCode) {
|
||||
ProductDO product = new ProductDO();
|
||||
product.setId(id);
|
||||
product.setCode("CNPD202600" + (id % 10));
|
||||
product.setDirectionCode(directionCode);
|
||||
product.setStatusCode(statusCode);
|
||||
product.setName(name);
|
||||
product.setManagerUserId(managerUserId);
|
||||
product.setDescription(description);
|
||||
return product;
|
||||
}
|
||||
|
||||
private void mockObjectPermission(Long productId, Long loginUserId, String permission) {
|
||||
UserObjectRoleDO currentMember = new UserObjectRoleDO();
|
||||
currentMember.setId(9001L);
|
||||
currentMember.setUserId(loginUserId);
|
||||
currentMember.setObjectType("product");
|
||||
currentMember.setObjectId(productId);
|
||||
currentMember.setRoleId(9101L);
|
||||
currentMember.setStatus(0);
|
||||
|
||||
SystemRoleMenuDO roleMenu = new SystemRoleMenuDO();
|
||||
roleMenu.setId(9201L);
|
||||
roleMenu.setRoleId(9101L);
|
||||
roleMenu.setMenuId(9301L);
|
||||
|
||||
SystemMenuDO menu = new SystemMenuDO();
|
||||
menu.setId(9301L);
|
||||
menu.setPermission(permission);
|
||||
menu.setScopeType(PermissionScopeTypeEnum.OBJECT.getScopeType());
|
||||
menu.setObjectType("product");
|
||||
menu.setType(MenuTypeEnum.BUTTON.getType());
|
||||
menu.setStatus(0);
|
||||
menu.setVisible(true);
|
||||
|
||||
when(userObjectRoleMapper.selectActiveByObjectAndUserId("product", productId, loginUserId))
|
||||
.thenReturn(currentMember);
|
||||
when(systemRoleMenuMapper.selectListByRoleId(9101L)).thenReturn(List.of(roleMenu));
|
||||
when(systemMenuMapper.selectListByIdsAndScopeAndObjectType(
|
||||
any(), eq(PermissionScopeTypeEnum.OBJECT.getScopeType()), eq("product")))
|
||||
.thenReturn(List.of(menu));
|
||||
}
|
||||
|
||||
private ObjectStatusTransitionDO createTransition(String actionCode, String toStatus, boolean needReason) {
|
||||
ObjectStatusTransitionDO transition = new ObjectStatusTransitionDO();
|
||||
transition.setActionCode(actionCode);
|
||||
transition.setToStatusCode(toStatus);
|
||||
transition.setNeedReason(needReason);
|
||||
return transition;
|
||||
}
|
||||
|
||||
private MockedStatic<SecurityFrameworkUtils> mockLoginUser(Long loginUserId, String nickname) {
|
||||
MockedStatic<SecurityFrameworkUtils> mockedStatic = mockStatic(SecurityFrameworkUtils.class);
|
||||
mockedStatic.when(SecurityFrameworkUtils::getLoginUserId).thenReturn(loginUserId);
|
||||
mockedStatic.when(SecurityFrameworkUtils::getLoginUserNickname).thenReturn(nickname);
|
||||
return mockedStatic;
|
||||
}
|
||||
|
||||
private ProductDO captureUpdatedProduct() {
|
||||
ArgumentCaptor<ProductDO> productCaptor = ArgumentCaptor.forClass(ProductDO.class);
|
||||
verify(productMapper, times(1)).updateById(productCaptor.capture());
|
||||
return productCaptor.getValue();
|
||||
}
|
||||
|
||||
private BizAuditLogDO captureAuditLog() {
|
||||
ArgumentCaptor<BizAuditLogDO> auditCaptor = ArgumentCaptor.forClass(BizAuditLogDO.class);
|
||||
verify(bizAuditLogMapper, times(1)).insert(auditCaptor.capture());
|
||||
return auditCaptor.getValue();
|
||||
}
|
||||
|
||||
private void assertProductBaseInfoUpdated(ProductDO updated, String code, Long managerUserId,
|
||||
String statusCode, String directionCode,
|
||||
String name, String description) {
|
||||
assertEquals(code, updated.getCode());
|
||||
assertEquals(managerUserId, updated.getManagerUserId());
|
||||
assertEquals(statusCode, updated.getStatusCode());
|
||||
assertEquals(directionCode, updated.getDirectionCode());
|
||||
assertEquals(name, updated.getName());
|
||||
assertEquals(description, updated.getDescription());
|
||||
assertNull(updated.getLastStatusReason());
|
||||
}
|
||||
|
||||
private void assertAuditFieldChanges(BizAuditLogDO auditLog, Long productId, String beforeDirectionCode,
|
||||
String afterDirectionCode, String beforeName, String afterName,
|
||||
String beforeDescription, String afterDescription) {
|
||||
assertEquals("product", auditLog.getBizType());
|
||||
assertEquals(productId, auditLog.getBizId());
|
||||
assertEquals("update", auditLog.getActionType());
|
||||
assertEquals("active", auditLog.getFromStatus());
|
||||
assertEquals("active", auditLog.getToStatus());
|
||||
|
||||
JsonNode fieldChanges = JsonUtils.parseTree(auditLog.getFieldChanges());
|
||||
assertEquals(beforeDirectionCode, fieldChanges.path("directionCode").path("before").asText());
|
||||
assertEquals(afterDirectionCode, fieldChanges.path("directionCode").path("after").asText());
|
||||
assertEquals(beforeName, fieldChanges.path("name").path("before").asText());
|
||||
assertEquals(afterName, fieldChanges.path("name").path("after").asText());
|
||||
assertEquals(beforeDescription, fieldChanges.path("description").path("before").asText());
|
||||
assertEquals(afterDescription, fieldChanges.path("description").path("after").asText());
|
||||
assertFalse(fieldChanges.has("managerUserId"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package com.njcn.rdms.module.project.service.product;
|
||||
|
||||
import com.njcn.rdms.framework.common.exception.ServiceException;
|
||||
import com.njcn.rdms.framework.common.pojo.CommonResult;
|
||||
import com.njcn.rdms.framework.common.pojo.PageResult;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.activity.ProductActivityPageReqVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.activity.ProductActivityRespVO;
|
||||
import com.njcn.rdms.framework.test.core.ut.BaseMockitoUnitTest;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.setting.ProductSettingLifecycleRespVO;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.setting.ProductSettingRespVO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.product.ProductDO;
|
||||
import com.njcn.rdms.module.project.dal.mysql.product.ProductMapper;
|
||||
import com.njcn.rdms.module.project.enums.ErrorCodeConstants;
|
||||
import com.njcn.rdms.module.system.api.user.AdminUserApi;
|
||||
import com.njcn.rdms.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class ProductSettingServiceImplTest extends BaseMockitoUnitTest {
|
||||
|
||||
@InjectMocks
|
||||
private ProductSettingServiceImpl productSettingService;
|
||||
@Mock
|
||||
private AdminUserApi adminUserApi;
|
||||
@Mock
|
||||
private ProductMapper productMapper;
|
||||
@Mock
|
||||
private ProductStatusViewService productStatusViewService;
|
||||
@Mock
|
||||
private ProductActivityQueryService productActivityQueryService;
|
||||
|
||||
@Test
|
||||
void getProductSettings_shouldAssembleBaseInfoAndLifecycleActions() {
|
||||
Long productId = 1001L;
|
||||
Long managerUserId = 2002L;
|
||||
ProductDO product = new ProductDO();
|
||||
product.setId(productId);
|
||||
product.setCode("CNPD2026001");
|
||||
product.setDirectionCode("direction_value");
|
||||
product.setName("统一交付平台");
|
||||
product.setManagerUserId(managerUserId);
|
||||
product.setDescription("产品描述");
|
||||
product.setStatusCode("active");
|
||||
product.setLastStatusReason("恢复正常推进");
|
||||
|
||||
AdminUserRespDTO manager = new AdminUserRespDTO();
|
||||
manager.setId(managerUserId);
|
||||
manager.setNickname("张三");
|
||||
|
||||
ProductSettingLifecycleRespVO lifecycle = new ProductSettingLifecycleRespVO();
|
||||
lifecycle.setStatusCode("active");
|
||||
lifecycle.setStatusName("启用");
|
||||
lifecycle.setTerminal(false);
|
||||
lifecycle.setAllowEdit(true);
|
||||
lifecycle.setLastStatusReason("恢复正常推进");
|
||||
lifecycle.setAvailableActions(Collections.emptyList());
|
||||
|
||||
when(productMapper.selectById(productId)).thenReturn(product);
|
||||
when(adminUserApi.getUser(managerUserId)).thenReturn(CommonResult.success(manager));
|
||||
when(productStatusViewService.getLifecycle("active", "恢复正常推进")).thenReturn(lifecycle);
|
||||
|
||||
ProductSettingRespVO result = productSettingService.getProductSettings(productId);
|
||||
|
||||
assertEquals("统一交付平台", result.getBaseInfo().getName());
|
||||
assertEquals("张三", result.getBaseInfo().getManagerUserNickname());
|
||||
assertEquals("启用", result.getLifecycle().getStatusName());
|
||||
assertEquals(false, result.getLifecycle().getTerminal());
|
||||
assertEquals(true, result.getLifecycle().getAllowEdit());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getProductSettings_shouldReturnNullManagerNicknameWhenManagerUserIdIsNull() {
|
||||
Long productId = 1002L;
|
||||
ProductDO product = new ProductDO();
|
||||
product.setId(productId);
|
||||
product.setCode("CNPD2026002");
|
||||
product.setDirectionCode("direction_value");
|
||||
product.setName("产品A");
|
||||
product.setManagerUserId(null);
|
||||
product.setStatusCode("active");
|
||||
ProductSettingLifecycleRespVO lifecycle = new ProductSettingLifecycleRespVO();
|
||||
lifecycle.setStatusCode("active");
|
||||
lifecycle.setAvailableActions(Collections.emptyList());
|
||||
|
||||
when(productMapper.selectById(productId)).thenReturn(product);
|
||||
when(productStatusViewService.getLifecycle("active", null)).thenReturn(lifecycle);
|
||||
|
||||
ProductSettingRespVO result = productSettingService.getProductSettings(productId);
|
||||
|
||||
assertNull(result.getBaseInfo().getManagerUserNickname());
|
||||
verifyNoInteractions(adminUserApi);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getProductSettings_shouldReturnEmptyActionsWhenNoStatusTransitions() {
|
||||
Long productId = 1003L;
|
||||
Long managerUserId = 2003L;
|
||||
ProductDO product = new ProductDO();
|
||||
product.setId(productId);
|
||||
product.setCode("CNPD2026003");
|
||||
product.setDirectionCode("direction_value");
|
||||
product.setName("产品B");
|
||||
product.setManagerUserId(managerUserId);
|
||||
product.setStatusCode("paused");
|
||||
|
||||
AdminUserRespDTO manager = new AdminUserRespDTO();
|
||||
manager.setId(managerUserId);
|
||||
manager.setNickname("李四");
|
||||
ProductSettingLifecycleRespVO lifecycle = new ProductSettingLifecycleRespVO();
|
||||
lifecycle.setStatusCode("paused");
|
||||
lifecycle.setAvailableActions(Collections.emptyList());
|
||||
|
||||
when(productMapper.selectById(productId)).thenReturn(product);
|
||||
when(adminUserApi.getUser(managerUserId)).thenReturn(CommonResult.success(manager));
|
||||
when(productStatusViewService.getLifecycle("paused", null)).thenReturn(lifecycle);
|
||||
|
||||
ProductSettingRespVO result = productSettingService.getProductSettings(productId);
|
||||
|
||||
assertNotNull(result.getLifecycle().getAvailableActions());
|
||||
assertTrue(result.getLifecycle().getAvailableActions().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getProductActivities_shouldValidateProductAndDelegate() {
|
||||
Long productId = 1004L;
|
||||
ProductDO product = new ProductDO();
|
||||
product.setId(productId);
|
||||
|
||||
ProductActivityPageReqVO reqVO = new ProductActivityPageReqVO();
|
||||
reqVO.setPageNo(1);
|
||||
reqVO.setPageSize(10);
|
||||
|
||||
ProductActivityRespVO respVO = new ProductActivityRespVO();
|
||||
respVO.setType("status");
|
||||
PageResult<ProductActivityRespVO> pageResult = new PageResult<>(List.of(respVO), 1L);
|
||||
|
||||
when(productMapper.selectById(productId)).thenReturn(product);
|
||||
when(productActivityQueryService.getProductActivities(productId, reqVO)).thenReturn(pageResult);
|
||||
|
||||
PageResult<ProductActivityRespVO> result = productSettingService.getProductActivities(productId, reqVO);
|
||||
|
||||
assertEquals(1L, result.getTotal());
|
||||
assertEquals("status", result.getList().get(0).getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getProductActivities_whenProductMissing_shouldThrowException() {
|
||||
Long productId = 1005L;
|
||||
ProductActivityPageReqVO reqVO = new ProductActivityPageReqVO();
|
||||
reqVO.setPageNo(1);
|
||||
reqVO.setPageSize(10);
|
||||
|
||||
when(productMapper.selectById(productId)).thenReturn(null);
|
||||
|
||||
ServiceException ex = assertThrows(ServiceException.class,
|
||||
() -> productSettingService.getProductActivities(productId, reqVO));
|
||||
assertEquals(ErrorCodeConstants.PRODUCT_NOT_EXISTS.getCode(), ex.getCode());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.njcn.rdms.module.project.service.product;
|
||||
|
||||
import com.njcn.rdms.framework.common.exception.ServiceException;
|
||||
import com.njcn.rdms.framework.test.core.ut.BaseMockitoUnitTest;
|
||||
import com.njcn.rdms.module.project.controller.admin.product.vo.setting.ProductSettingLifecycleRespVO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.status.ObjectStatusModelDO;
|
||||
import com.njcn.rdms.module.project.dal.dataobject.status.ObjectStatusTransitionDO;
|
||||
import com.njcn.rdms.module.project.dal.mysql.status.ObjectStatusModelMapper;
|
||||
import com.njcn.rdms.module.project.dal.mysql.status.ObjectStatusTransitionMapper;
|
||||
import com.njcn.rdms.module.project.enums.ErrorCodeConstants;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class ProductStatusViewServiceTest extends BaseMockitoUnitTest {
|
||||
|
||||
@InjectMocks
|
||||
private ProductStatusViewService productStatusViewService;
|
||||
@Mock
|
||||
private ObjectStatusModelMapper objectStatusModelMapper;
|
||||
@Mock
|
||||
private ObjectStatusTransitionMapper objectStatusTransitionMapper;
|
||||
|
||||
@Test
|
||||
void getLifecycle_shouldReturnStatusMetadataAndActions() {
|
||||
ObjectStatusModelDO statusModel = new ObjectStatusModelDO();
|
||||
statusModel.setObjectType("product");
|
||||
statusModel.setStatusCode("active");
|
||||
statusModel.setStatusName("启用");
|
||||
statusModel.setTerminalFlag(false);
|
||||
statusModel.setAllowEdit(true);
|
||||
statusModel.setStatus(0);
|
||||
|
||||
ObjectStatusTransitionDO transition = new ObjectStatusTransitionDO();
|
||||
transition.setActionCode("pause");
|
||||
transition.setActionName("暂停");
|
||||
transition.setNeedReason(true);
|
||||
|
||||
when(objectStatusModelMapper.selectByObjectTypeAndStatusCodeEnabled("product", "active"))
|
||||
.thenReturn(statusModel);
|
||||
when(objectStatusTransitionMapper.selectListByObjectTypeAndFromStatus("product", "active"))
|
||||
.thenReturn(List.of(transition));
|
||||
|
||||
ProductSettingLifecycleRespVO result =
|
||||
productStatusViewService.getLifecycle("active", "恢复正常推进");
|
||||
|
||||
assertEquals("active", result.getStatusCode());
|
||||
assertEquals("启用", result.getStatusName());
|
||||
assertFalse(result.getTerminal());
|
||||
assertTrue(result.getAllowEdit());
|
||||
assertEquals("恢复正常推进", result.getLastStatusReason());
|
||||
assertEquals(1, result.getAvailableActions().size());
|
||||
assertEquals("pause", result.getAvailableActions().get(0).getActionCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getLifecycle_whenStatusModelMissing_shouldThrowException() {
|
||||
when(objectStatusModelMapper.selectByObjectTypeAndStatusCodeEnabled("product", "active"))
|
||||
.thenReturn(null);
|
||||
|
||||
ServiceException ex = assertThrows(ServiceException.class,
|
||||
() -> productStatusViewService.getLifecycle("active", null));
|
||||
assertEquals(ErrorCodeConstants.PRODUCT_STATUS_MODEL_NOT_EXISTS_OR_DISABLED.getCode(), ex.getCode());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ public interface DictTypeConstants {
|
||||
String USER_SEX = "system_user_sex";
|
||||
String LOGIN_TYPE = "system_login_type";
|
||||
String LOGIN_RESULT = "system_login_result";
|
||||
String OBJECT_DIRECTION = "rdms_object_direction";
|
||||
|
||||
String JOB_STATUS = "infra_job_status";
|
||||
String JOB_LOG_STATUS = "infra_job_log_status";
|
||||
|
||||
@@ -26,7 +26,10 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.njcn.rdms.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
|
||||
@@ -79,13 +82,26 @@ public class DictDataController {
|
||||
|
||||
@GetMapping(value = {"/list-all-simple", "simple-list"})
|
||||
@Operation(summary = "获得全部字典数据列表", description = "一般用于管理后台缓存字典数据在本地")
|
||||
// 无需添加权限认证,因为前端全局都需要
|
||||
// 不额外校验菜单权限,前端在登录后可直接拉取并缓存
|
||||
public CommonResult<List<DictDataSimpleRespVO>> getSimpleDictDataList() {
|
||||
List<DictDataDO> list = dictDataService.getDictDataList(
|
||||
CommonStatusEnum.ENABLE.getStatus(), null);
|
||||
return success(BeanUtils.toBean(list, DictDataSimpleRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/frontend-cache")
|
||||
@Operation(summary = "获得前端运行时字典缓存")
|
||||
public CommonResult<Map<String, List<DictDataSimpleRespVO>>> getFrontendCache() {
|
||||
List<DictDataSimpleRespVO> list = BeanUtils.toBean(
|
||||
dictDataService.getDictDataList(CommonStatusEnum.ENABLE.getStatus(), null),
|
||||
DictDataSimpleRespVO.class);
|
||||
Map<String, List<DictDataSimpleRespVO>> result = new LinkedHashMap<>();
|
||||
// 基于 service 已排好序的结果分组,保证每个字典组内仍按 sort 升序返回。
|
||||
list.forEach(dictData -> result.computeIfAbsent(dictData.getDictType(),
|
||||
key -> new ArrayList<>()).add(dictData));
|
||||
return success(result);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得字典类型的分页")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
||||
|
||||
@@ -16,6 +16,9 @@ public class DictDataSimpleRespVO {
|
||||
@Schema(description = "字典标签", requiredMode = Schema.RequiredMode.REQUIRED, example = "男")
|
||||
private String label;
|
||||
|
||||
@Schema(description = "排序值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "颜色类型,default、primary、success、info、warning、danger", example = "default")
|
||||
private String colorType;
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.njcn.rdms.module.system.framework.cache;
|
||||
|
||||
import com.njcn.rdms.module.system.dal.redis.RedisKeyConstants;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统启动后清理权限相关缓存,避免 SQL 直改后继续命中旧权限数据。
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class PermissionCacheStartupCleaner implements ApplicationRunner {
|
||||
|
||||
private static final List<String> CACHE_NAMES = List.of(
|
||||
RedisKeyConstants.ROLE,
|
||||
RedisKeyConstants.USER_ROLE_ID_LIST,
|
||||
RedisKeyConstants.MENU_ROLE_ID_LIST,
|
||||
RedisKeyConstants.PERMISSION_MENU_ID_LIST
|
||||
);
|
||||
|
||||
private final CacheManager cacheManager;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
CACHE_NAMES.forEach(this::clearCacheQuietly);
|
||||
}
|
||||
|
||||
private void clearCacheQuietly(String cacheName) {
|
||||
Cache cache = cacheManager.getCache(cacheName);
|
||||
if (cache == null) {
|
||||
log.debug("[clearCacheQuietly][cacheName({}) 未注册,跳过清理]", cacheName);
|
||||
return;
|
||||
}
|
||||
cache.clear();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,6 @@ package com.njcn.rdms.module.system.service.permission;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.singleton;
|
||||
|
||||
/**
|
||||
* 权限 Service 接口
|
||||
* <p>
|
||||
@@ -61,9 +59,7 @@ public interface PermissionService {
|
||||
* @param roleId 角色编号
|
||||
* @return 菜单编号集合
|
||||
*/
|
||||
default Set<Long> getRoleMenuListByRoleId(Long roleId) {
|
||||
return getRoleMenuListByRoleId(singleton(roleId));
|
||||
}
|
||||
Set<Long> getRoleMenuListByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 获得角色们拥有的菜单编号集合
|
||||
|
||||
@@ -28,7 +28,10 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static com.njcn.rdms.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.njcn.rdms.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static com.njcn.rdms.module.system.enums.ErrorCodeConstants.ROLE_IS_DISABLE;
|
||||
import static com.njcn.rdms.module.system.enums.ErrorCodeConstants.ROLE_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 权限 Service 实现类
|
||||
@@ -179,8 +182,7 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
allEntries = true) // allEntries 清空所有缓存,主要一次更新涉及到的 menuIds 较多,反倒批量会更快
|
||||
})
|
||||
public void assignRoleMenu(Long roleId, Set<Long> menuIds) {
|
||||
roleService.validateRoleList(Collections.singleton(roleId), GLOBAL_SCOPE_TYPE, GLOBAL_OBJECT_TYPE);
|
||||
RoleDO role = roleService.getRole(roleId);
|
||||
RoleDO role = getEnabledRole(roleId);
|
||||
menuService.validateMenuList(menuIds, role.getScopeType(), role.getObjectType());
|
||||
// 获得角色拥有菜单编号
|
||||
Set<Long> dbMenuIds = convertSet(roleMenuMapper.selectListByRoleId(roleId), RoleMenuDO::getMenuId);
|
||||
@@ -224,6 +226,12 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
roleMenuMapper.deleteListByMenuId(menuId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Long> getRoleMenuListByRoleId(Long roleId) {
|
||||
RoleDO role = getEnabledRole(roleId);
|
||||
return getRoleMenuListByRoleId(Collections.singleton(roleId), role.getScopeType(), role.getObjectType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Long> getRoleMenuListByRoleId(Collection<Long> roleIds) {
|
||||
if (CollUtil.isEmpty(roleIds)) {
|
||||
@@ -338,6 +346,17 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
return CollUtil.isEmpty(menus) ? null : menus.get(0);
|
||||
}
|
||||
|
||||
private RoleDO getEnabledRole(Long roleId) {
|
||||
RoleDO role = roleService.getRole(roleId);
|
||||
if (role == null) {
|
||||
throw exception(ROLE_NOT_EXISTS);
|
||||
}
|
||||
if (!CommonStatusEnum.ENABLE.getStatus().equals(role.getStatus())) {
|
||||
throw exception(ROLE_IS_DISABLE, role.getName());
|
||||
}
|
||||
return role;
|
||||
}
|
||||
|
||||
private PermissionServiceImpl getSelf() {
|
||||
return SpringUtil.getBean(getClass());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.njcn.rdms.module.system.framework.cache;
|
||||
|
||||
import com.njcn.rdms.framework.test.core.ut.BaseMockitoUnitTest;
|
||||
import com.njcn.rdms.module.system.dal.redis.RedisKeyConstants;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class PermissionCacheStartupCleanerTest extends BaseMockitoUnitTest {
|
||||
|
||||
@Mock
|
||||
private CacheManager cacheManager;
|
||||
@Mock
|
||||
private Cache roleCache;
|
||||
@Mock
|
||||
private Cache userRoleCache;
|
||||
@Mock
|
||||
private Cache menuRoleCache;
|
||||
@Mock
|
||||
private Cache permissionMenuCache;
|
||||
|
||||
@InjectMocks
|
||||
private PermissionCacheStartupCleaner cleaner;
|
||||
|
||||
@Test
|
||||
void run_shouldClearPermissionRelatedCaches() throws Exception {
|
||||
when(cacheManager.getCache(RedisKeyConstants.ROLE)).thenReturn(roleCache);
|
||||
when(cacheManager.getCache(RedisKeyConstants.USER_ROLE_ID_LIST)).thenReturn(userRoleCache);
|
||||
when(cacheManager.getCache(RedisKeyConstants.MENU_ROLE_ID_LIST)).thenReturn(menuRoleCache);
|
||||
when(cacheManager.getCache(RedisKeyConstants.PERMISSION_MENU_ID_LIST)).thenReturn(permissionMenuCache);
|
||||
|
||||
cleaner.run(mock(ApplicationArguments.class));
|
||||
|
||||
verify(roleCache).clear();
|
||||
verify(userRoleCache).clear();
|
||||
verify(menuRoleCache).clear();
|
||||
verify(permissionMenuCache).clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
void run_shouldIgnoreMissingCaches() {
|
||||
when(cacheManager.getCache(RedisKeyConstants.ROLE)).thenReturn(roleCache);
|
||||
|
||||
assertDoesNotThrow(() -> cleaner.run(mock(ApplicationArguments.class)));
|
||||
|
||||
verify(roleCache).clear();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user