feat(iam): add exception order process permission

This commit is contained in:
2026-09-08 18:51:22 +08:00
parent d1090671ce
commit 75e67fa980
5 changed files with 36 additions and 21 deletions
@@ -18,6 +18,7 @@ BEGIN
OR (id = 5107093 AND permission_code <> 'platform:overseas-warehouse:outbound:cancel')
OR (id = 5107070 AND permission_code <> 'platform:overseas-warehouse:exception-order:list')
OR (id = 5107071 AND permission_code <> 'platform:overseas-warehouse:exception-order:create')
OR (id = 5107073 AND permission_code <> 'platform:overseas-warehouse:exception-order:process')
OR (id = 5107072 AND permission_code <> 'platform:overseas-warehouse:delivery:return')
OR (id = 5107080 AND permission_code <> 'platform:overseas-warehouse:customer-visit:list')
OR (id = 5107081 AND permission_code <> 'platform:overseas-warehouse:customer-visit:edit')
@@ -36,6 +37,7 @@ BEGIN
OR (permission_code = 'platform:overseas-warehouse:outbound:cancel' AND id <> 5107093)
OR (permission_code = 'platform:overseas-warehouse:exception-order:list' AND id <> 5107070)
OR (permission_code = 'platform:overseas-warehouse:exception-order:create' AND id <> 5107071)
OR (permission_code = 'platform:overseas-warehouse:exception-order:process' AND id <> 5107073)
OR (permission_code = 'platform:overseas-warehouse:delivery:return' AND id <> 5107072)
OR (permission_code = 'platform:overseas-warehouse:customer-visit:list' AND id <> 5107080)
OR (permission_code = 'platform:overseas-warehouse:customer-visit:edit' AND id <> 5107081)
@@ -60,6 +62,7 @@ VALUES
(5107018,0,'PLATFORM','BUTTON',5107064,'platform:overseas-warehouse:dispatch:transfer-delivery','排车转派送',NULL,'POST',718,'ACTIVE',1,0),
(5107070,0,'PLATFORM','MENU',0,'platform:overseas-warehouse:exception-order:list','海外异常订单','/overseas-warehouse/exception-orders','GET',770,'ACTIVE',1,0),
(5107071,0,'PLATFORM','BUTTON',5107070,'platform:overseas-warehouse:exception-order:create','新增海外异常订单',NULL,'POST',771,'ACTIVE',1,0),
(5107073,0,'PLATFORM','BUTTON',5107070,'platform:overseas-warehouse:exception-order:process','处理海外异常订单',NULL,'POST',773,'ACTIVE',1,0),
(5107072,0,'PLATFORM','BUTTON',5107092,'platform:overseas-warehouse:delivery:return','派送单标记退货',NULL,'POST',772,'ACTIVE',1,0),
(5107080,0,'PLATFORM','MENU',0,'platform:overseas-warehouse:customer-visit:list','客户回访','/overseas-warehouse/customer-visits','GET',780,'ACTIVE',1,0),
(5107081,0,'PLATFORM','BUTTON',5107080,'platform:overseas-warehouse:customer-visit:edit','保存客户回访',NULL,'PUT',781,'ACTIVE',1,0),
@@ -95,6 +98,7 @@ SELECT 0, role.id, permission.id, CURRENT_TIMESTAMP(3)
'platform:overseas-warehouse:delivery:list',
'platform:overseas-warehouse:exception-order:list',
'platform:overseas-warehouse:exception-order:create',
'platform:overseas-warehouse:exception-order:process',
'platform:overseas-warehouse:delivery:return',
'platform:overseas-warehouse:delivery:status',
'platform:overseas-warehouse:customer-visit:list',
@@ -119,6 +123,7 @@ INSERT INTO tmp_phase5_delivery_role_permission (role_code, permission_code) VAL
('WAREHOUSE_OPERATOR','platform:overseas-warehouse:delivery:list'),
('WAREHOUSE_OPERATOR','platform:overseas-warehouse:exception-order:list'),
('WAREHOUSE_OPERATOR','platform:overseas-warehouse:exception-order:create'),
('WAREHOUSE_OPERATOR','platform:overseas-warehouse:exception-order:process'),
('WAREHOUSE_OPERATOR','platform:overseas-warehouse:delivery:return'),
('WAREHOUSE_OPERATOR','platform:overseas-warehouse:delivery:status'),
('WAREHOUSE_OPERATOR','platform:overseas-warehouse:customer-visit:list'),
@@ -147,6 +152,7 @@ WHERE role.tenant_id=0 AND role.app_code='PLATFORM'
'platform:overseas-warehouse:delivery:list',
'platform:overseas-warehouse:exception-order:list',
'platform:overseas-warehouse:exception-order:create',
'platform:overseas-warehouse:exception-order:process',
'platform:overseas-warehouse:delivery:return',
'platform:overseas-warehouse:delivery:status',
'platform:overseas-warehouse:customer-visit:list',
@@ -194,12 +200,13 @@ BEGIN
'platform:overseas-warehouse:delivery:list',
'platform:overseas-warehouse:exception-order:list',
'platform:overseas-warehouse:exception-order:create',
'platform:overseas-warehouse:exception-order:process',
'platform:overseas-warehouse:delivery:return',
'platform:overseas-warehouse:delivery:status',
'platform:overseas-warehouse:customer-visit:list',
'platform:overseas-warehouse:customer-visit:edit',
'merchant:warehouse:delivery:list',
'merchant:warehouse:delivery:create')) <> 16 THEN
'merchant:warehouse:delivery:create')) <> 17 THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='五期海外派送权限初始化失败:权限目录不完整';
END IF;
IF (SELECT COUNT(*) FROM iam_role_permission grant_row
@@ -217,10 +224,11 @@ BEGIN
'platform:overseas-warehouse:delivery:list',
'platform:overseas-warehouse:exception-order:list',
'platform:overseas-warehouse:exception-order:create',
'platform:overseas-warehouse:exception-order:process',
'platform:overseas-warehouse:delivery:return',
'platform:overseas-warehouse:delivery:status',
'platform:overseas-warehouse:customer-visit:list',
'platform:overseas-warehouse:customer-visit:edit')) <> 14 THEN
'platform:overseas-warehouse:customer-visit:edit')) <> 15 THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='五期海外派送权限初始化失败:平台管理员授权不完整';
END IF;
IF EXISTS (SELECT 1 FROM iam_role role
@@ -241,17 +249,18 @@ BEGIN
'platform:overseas-warehouse:delivery:list',
'platform:overseas-warehouse:exception-order:list',
'platform:overseas-warehouse:exception-order:create',
'platform:overseas-warehouse:exception-order:process',
'platform:overseas-warehouse:delivery:return',
'platform:overseas-warehouse:delivery:status',
'platform:overseas-warehouse:customer-visit:list',
'platform:overseas-warehouse:customer-visit:edit')) <> 14) THEN
'platform:overseas-warehouse:customer-visit:edit')) <> 15) THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='五期海外派送权限初始化失败:平台自定义管理员授权不完整';
END IF;
SELECT COALESCE(SUM(role_code='WAREHOUSE_OPERATOR'),0),
COALESCE(SUM(role_code='WAREHOUSE_TALLY'),0)
INTO v_warehouse_operator_permission_count, v_warehouse_tally_permission_count
FROM tmp_phase5_delivery_role_permission;
IF v_warehouse_operator_permission_count <> 14
IF v_warehouse_operator_permission_count <> 15
OR v_warehouse_tally_permission_count <> 5 THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='五期海外派送权限初始化失败:仓库岗位最小权限矩阵异常';
END IF;
@@ -270,6 +279,7 @@ BEGIN
'platform:overseas-warehouse:delivery:list',
'platform:overseas-warehouse:exception-order:list',
'platform:overseas-warehouse:exception-order:create',
'platform:overseas-warehouse:exception-order:process',
'platform:overseas-warehouse:delivery:return',
'platform:overseas-warehouse:delivery:status',
'platform:overseas-warehouse:customer-visit:list',
+1 -1
View File
@@ -124,7 +124,7 @@ paths:
get:
tags: [IAM Resources / IAM 资源]
summary: 查询当前用户有效权限
description: 返回当前有效平台成员权限编码;只要求有效 PLATFORM JWT,不依赖 `platform:role:list`。入库单扣货与解除扣货返回独立写权限 `platform:firstleg:inbound:hold`,不会由 `platform:firstleg:inbound:list` 查看权限自动获得。资金账户充值审核与手工调账分别返回 `platform:finance:recharge:review`、`platform:finance:customer-account:adjust`,并与 `platform:finance:customer-account:list` 只读权限分离。海外仓返回 `platform:overseas-warehouse:dispatch:list`、`platform:overseas-warehouse:dispatch:edit`、`platform:overseas-warehouse:dispatch:cancel`、`platform:overseas-warehouse:dispatch:transfer-delivery`、`platform:overseas-warehouse:outbound:list`、`platform:overseas-warehouse:outbound:create`、`platform:overseas-warehouse:outbound:cancel`、`platform:overseas-warehouse:delivery:list`、`platform:overseas-warehouse:delivery:return`、`platform:overseas-warehouse:delivery:status`、`platform:overseas-warehouse:exception-order:list`、`platform:overseas-warehouse:exception-order:create`、`platform:overseas-warehouse:customer-visit:list`、`platform:overseas-warehouse:customer-visit:edit`;海外 PDA 盘点、移库、换标和现场查询统一返回 `lastleg:pda:operate`,且仅限 `OVERSEAS_WAREHOUSE_PDA_OPERATOR`。列表权限包含详情和只读辅助接口,写操作独立授权。
description: 返回当前有效平台成员权限编码;只要求有效 PLATFORM JWT,不依赖 `platform:role:list`。入库单扣货与解除扣货返回独立写权限 `platform:firstleg:inbound:hold`,不会由 `platform:firstleg:inbound:list` 查看权限自动获得。资金账户充值审核与手工调账分别返回 `platform:finance:recharge:review`、`platform:finance:customer-account:adjust`,并与 `platform:finance:customer-account:list` 只读权限分离。海外仓返回 `platform:overseas-warehouse:dispatch:list`、`platform:overseas-warehouse:dispatch:edit`、`platform:overseas-warehouse:dispatch:cancel`、`platform:overseas-warehouse:dispatch:transfer-delivery`、`platform:overseas-warehouse:outbound:list`、`platform:overseas-warehouse:outbound:create`、`platform:overseas-warehouse:outbound:cancel`、`platform:overseas-warehouse:delivery:list`、`platform:overseas-warehouse:delivery:return`、`platform:overseas-warehouse:delivery:status`、`platform:overseas-warehouse:exception-order:list`、`platform:overseas-warehouse:exception-order:create`、`platform:overseas-warehouse:exception-order:process`、`platform:overseas-warehouse:customer-visit:list`、`platform:overseas-warehouse:customer-visit:edit`;海外 PDA 盘点、移库、换标和现场查询统一返回 `lastleg:pda:operate`,且仅限 `OVERSEAS_WAREHOUSE_PDA_OPERATOR`。列表权限包含详情和只读辅助接口,写操作独立授权。
responses:
'200':
description: 当前平台成员权限查询成功
@@ -31,6 +31,7 @@ class IamOpenApiContractTest {
.contains("platform:overseas-warehouse:delivery:status")
.contains("platform:overseas-warehouse:exception-order:list")
.contains("platform:overseas-warehouse:exception-order:create")
.contains("platform:overseas-warehouse:exception-order:process")
.contains("platform:overseas-warehouse:customer-visit:list")
.contains("platform:overseas-warehouse:customer-visit:edit")
.contains("platform:overseas-warehouse:outbound:cancel")
@@ -25,6 +25,7 @@ class Phase5DeliveryPermissionSqlContractTest {
"platform:overseas-warehouse:delivery:list",
"platform:overseas-warehouse:exception-order:list",
"platform:overseas-warehouse:exception-order:create",
"platform:overseas-warehouse:exception-order:process",
"platform:overseas-warehouse:delivery:return",
"platform:overseas-warehouse:delivery:status",
"platform:overseas-warehouse:customer-visit:list",
@@ -54,6 +55,7 @@ class Phase5DeliveryPermissionSqlContractTest {
"'platform:overseas-warehouse:dispatch:cancel','取消海外排车',NULL,'DELETE'",
"'platform:overseas-warehouse:exception-order:list','海外异常订单','/overseas-warehouse/exception-orders','GET'",
"'platform:overseas-warehouse:exception-order:create','新增海外异常订单',NULL,'POST'",
"'platform:overseas-warehouse:exception-order:process','处理海外异常订单',NULL,'POST'",
"'platform:overseas-warehouse:delivery:return','派送单标记退货',NULL,'POST'",
"'platform:overseas-warehouse:delivery:status','编辑派送单状态',NULL,'PUT'",
"'platform:overseas-warehouse:customer-visit:list','客户回访','/overseas-warehouse/customer-visits','GET'",
@@ -75,6 +77,7 @@ class Phase5DeliveryPermissionSqlContractTest {
"('WAREHOUSE_OPERATOR','platform:overseas-warehouse:dispatch:edit')",
"('WAREHOUSE_OPERATOR','platform:overseas-warehouse:outbound:create')",
"('WAREHOUSE_OPERATOR','platform:overseas-warehouse:exception-order:create')",
"('WAREHOUSE_OPERATOR','platform:overseas-warehouse:exception-order:process')",
"('WAREHOUSE_OPERATOR','platform:overseas-warehouse:delivery:return')",
"('WAREHOUSE_OPERATOR','platform:overseas-warehouse:delivery:status')",
"('WAREHOUSE_OPERATOR','platform:overseas-warehouse:customer-visit:edit')",
@@ -89,6 +92,7 @@ class Phase5DeliveryPermissionSqlContractTest {
"('WAREHOUSE_TALLY','platform:overseas-warehouse:dispatch:edit')",
"('WAREHOUSE_TALLY','platform:overseas-warehouse:outbound:create')",
"('WAREHOUSE_TALLY','platform:overseas-warehouse:exception-order:create')",
"('WAREHOUSE_TALLY','platform:overseas-warehouse:exception-order:process')",
"('WAREHOUSE_TALLY','platform:overseas-warehouse:delivery:return')",
"('WAREHOUSE_TALLY','platform:overseas-warehouse:delivery:status')",
"('WAREHOUSE_TALLY','platform:overseas-warehouse:customer-visit:edit')",
@@ -106,7 +110,7 @@ class Phase5DeliveryPermissionSqlContractTest {
"SELECT COALESCE(SUM(role_code='WAREHOUSE_OPERATOR'),0)",
"COALESCE(SUM(role_code='WAREHOUSE_TALLY'),0)",
"INTO v_warehouse_operator_permission_count, v_warehouse_tally_permission_count",
"IF v_warehouse_operator_permission_count <> 14",
"IF v_warehouse_operator_permission_count <> 15",
"OR v_warehouse_tally_permission_count <> 5 THEN",
"IF EXISTS (SELECT 1 FROM iam_role role",
"AND UPPER(role.role_code)='PLATFORM_CUSTOM_ADMIN'",
@@ -160,7 +164,7 @@ class Phase5DeliveryPermissionSqlContractTest {
"海外排车、出库与派送权限",
"测试和部署只执行固定入口,不再单独执行模块脚本",
"排车列表/编辑/取消/转派送",
"异常订单列表/创建和客户回访列表/编辑十四项权限",
"异常订单列表/创建/处理和客户回访列表/编辑十五项权限",
"merchant:warehouse:delivery:list",
"merchant:warehouse:delivery:create",
"PDA 岗位不得获得上述后台权限");
@@ -37,12 +37,12 @@ class Phase5DeliveryPermissionSqlExecutionTest {
assertThat(customAdministratorViolations(connection)).isEqualTo(1);
executeGrant(connection);
assertThat(grantCount(connection, 11L)).isEqualTo(14);
assertThat(grantCount(connection, 11L)).isEqualTo(15);
assertThat(customAdministratorViolations(connection)).isZero();
executeGrant(connection);
assertThat(grantCount(connection, 11L)).isEqualTo(14);
assertThat(totalGrantCount(connection)).isEqualTo(14);
assertThat(grantCount(connection, 11L)).isEqualTo(15);
assertThat(totalGrantCount(connection)).isEqualTo(15);
}
}
@@ -51,14 +51,14 @@ class Phase5DeliveryPermissionSqlExecutionTest {
try (Connection connection = database()) {
insertRole(connection, 21L, "PLATFORM_CUSTOM_ADMIN");
insertRole(connection, 22L, "Platform_Custom_Admin");
grantFirstPermissions(connection, 21L, 14);
grantFirstPermissions(connection, 22L, 13);
grantFirstPermissions(connection, 21L, 15);
grantFirstPermissions(connection, 22L, 14);
assertThat(customAdministratorViolations(connection)).isEqualTo(1);
executeGrant(connection);
assertThat(grantCount(connection, 21L)).isEqualTo(14);
assertThat(grantCount(connection, 22L)).isEqualTo(14);
assertThat(grantCount(connection, 21L)).isEqualTo(15);
assertThat(grantCount(connection, 22L)).isEqualTo(15);
assertThat(customAdministratorViolations(connection)).isZero();
}
}
@@ -68,16 +68,16 @@ class Phase5DeliveryPermissionSqlExecutionTest {
try (Connection connection = database()) {
insertRole(connection, 31L, "PLATFORM_CUSTOM_ADMIN");
insertRole(connection, 32L, "platform_custom_admin");
grantFirstPermissions(connection, 31L, 14);
grantFirstPermissions(connection, 32L, 14);
grantFirstPermissions(connection, 31L, 15);
grantFirstPermissions(connection, 32L, 15);
assertThat(customAdministratorViolations(connection)).isZero();
executeGrant(connection);
executeGrant(connection);
assertThat(grantCount(connection, 31L)).isEqualTo(14);
assertThat(grantCount(connection, 32L)).isEqualTo(14);
assertThat(totalGrantCount(connection)).isEqualTo(28);
assertThat(grantCount(connection, 31L)).isEqualTo(15);
assertThat(grantCount(connection, 32L)).isEqualTo(15);
assertThat(totalGrantCount(connection)).isEqualTo(30);
}
}
@@ -182,7 +182,7 @@ class Phase5DeliveryPermissionSqlExecutionTest {
AND (SELECT COUNT(*) FROM iam_role_permission grant_row
JOIN iam_permission permission ON permission.id=grant_row.permission_id
WHERE grant_row.role_id=role.id AND grant_row.tenant_id=role.tenant_id
AND permission.permission_code IN (%s)) <> 14
AND permission.permission_code IN (%s)) <> 15
""".formatted(placeholders);
try (PreparedStatement query = connection.prepareStatement(sql)) {
int index = 1;
@@ -209,7 +209,7 @@ class Phase5DeliveryPermissionSqlExecutionTest {
LinkedHashSet<String> codes = new LinkedHashSet<>();
String grant = administratorGrantSql();
PLATFORM_CODE.matcher(grant).results().map(result -> result.group()).forEach(codes::add);
assertThat(codes).hasSize(14);
assertThat(codes).hasSize(15);
return codes;
}