fix: align phase5 overseas permissions

This commit is contained in:
2026-09-01 20:00:49 +08:00
parent a5d787b279
commit d88e5cffce
13 changed files with 459 additions and 55 deletions
@@ -20,7 +20,19 @@ class IamOpenApiContractTest {
assertThat(document).contains("/api/platform/v1/iam/authorization/permissions:")
.contains("/api/merchant/v1/iam/authorization/permissions:")
.contains("platform:overseas-warehouse:dispatch:list")
.contains("platform:overseas-warehouse:dispatch:edit")
.contains("platform:overseas-warehouse:dispatch:cancel")
.contains("platform:overseas-warehouse:dispatch:transfer-delivery")
.contains("platform:overseas-warehouse:outbound:list")
.contains("platform:overseas-warehouse:outbound:create")
.contains("platform:overseas-warehouse:delivery:list")
.contains("platform:overseas-warehouse:delivery:return")
.contains("platform:overseas-warehouse:delivery:status")
.contains("platform:overseas-warehouse:exception-order:list")
.contains("platform:overseas-warehouse:exception-order:create")
.contains("platform:overseas-warehouse:customer-visit:list")
.contains("platform:overseas-warehouse:customer-visit:edit")
.contains("platform:overseas-warehouse:outbound:cancel")
.contains("merchant:warehouse:delivery:list")
.contains("merchant:warehouse:delivery:create")
@@ -15,6 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class Phase5DeliveryPermissionSqlContractTest {
private static final Pattern CODE = Pattern.compile("(?:platform:overseas-warehouse|merchant:warehouse):[a-z0-9:-]+");
private static final Set<String> REQUIRED = Set.of(
"platform:overseas-warehouse:dispatch:list",
"platform:overseas-warehouse:dispatch:edit",
"platform:overseas-warehouse:dispatch:cancel",
"platform:overseas-warehouse:dispatch:transfer-delivery",
@@ -22,6 +23,12 @@ class Phase5DeliveryPermissionSqlContractTest {
"platform:overseas-warehouse:outbound:create",
"platform:overseas-warehouse:outbound:cancel",
"platform:overseas-warehouse:delivery:list",
"platform:overseas-warehouse:exception-order:list",
"platform:overseas-warehouse:exception-order:create",
"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");
@@ -38,6 +45,25 @@ class Phase5DeliveryPermissionSqlContractTest {
"列表权限同时覆盖列表和详情只读");
}
@Test
void keepsMenuRoutesAndHttpMethodsAlignedWithTheFrozenAdminAndClientContracts() throws Exception {
String sql = sql();
assertThat(sql).contains(
"'platform:overseas-warehouse:dispatch:list','海外排车单','/overseas-warehouse/dispatches','GET'",
"'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:delivery:return','派送单标记退货',NULL,'POST'",
"'platform:overseas-warehouse:delivery:status','编辑派送单状态',NULL,'PUT'",
"'platform:overseas-warehouse:customer-visit:list','客户回访','/overseas-warehouse/customer-visits','GET'",
"'platform:overseas-warehouse:customer-visit:edit','保存客户回访',NULL,'PUT'",
"'merchant:warehouse:delivery:list','海外仓派送单','/orders/delivery','GET'");
assertThat(sql).doesNotContain(
"'platform:overseas-warehouse:dispatch:cancel','取消海外排车',NULL,'POST'",
"'merchant:warehouse:delivery:list','海外仓派送单','/overseas-warehouse/delivery-orders'");
}
@Test
void grantsAdministratorsAndWarehouseRolesByTheFrozenMinimumMatrix() throws Exception {
String sql = sql();
@@ -45,15 +71,27 @@ class Phase5DeliveryPermissionSqlContractTest {
assertThat(sql).contains(
"UPPER(role.role_code) IN ('PLATFORM_ADMIN','PLATFORM_CUSTOM_ADMIN')",
"tmp_phase5_delivery_role_permission",
"('WAREHOUSE_OPERATOR','platform:overseas-warehouse:dispatch:list')",
"('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:delivery:return')",
"('WAREHOUSE_OPERATOR','platform:overseas-warehouse:delivery:status')",
"('WAREHOUSE_OPERATOR','platform:overseas-warehouse:customer-visit:edit')",
"('WAREHOUSE_TALLY','platform:overseas-warehouse:dispatch:list')",
"('WAREHOUSE_TALLY','platform:overseas-warehouse:outbound:list')",
"('WAREHOUSE_TALLY','platform:overseas-warehouse:delivery:list')",
"('WAREHOUSE_TALLY','platform:overseas-warehouse:exception-order:list')",
"('WAREHOUSE_TALLY','platform:overseas-warehouse:customer-visit:list')",
"role.role_code IN ('OVERSEAS_WAREHOUSE_PDA_OPERATOR','CN_FIRSTLEG_PDA_OPERATOR')",
"PDA岗位错误获得后台权限");
assertThat(sql).doesNotContain(
"('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:delivery:return')",
"('WAREHOUSE_TALLY','platform:overseas-warehouse:delivery:status')",
"('WAREHOUSE_TALLY','platform:overseas-warehouse:customer-visit:edit')",
"('OVERSEAS_WAREHOUSE_PDA_OPERATOR','platform:overseas-warehouse:",
"('CN_FIRSTLEG_PDA_OPERATOR','platform:overseas-warehouse:");
}
@@ -68,8 +106,9 @@ 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 <> 7",
"OR v_warehouse_tally_permission_count <> 2 THEN");
"IF v_warehouse_operator_permission_count <> 14",
"OR v_warehouse_tally_permission_count <> 5 THEN",
"平台自定义管理员授权不完整");
assertThat(sql).doesNotContain(
"IF (SELECT COUNT(*) FROM tmp_phase5_delivery_role_permission",
"OR (SELECT COUNT(*) FROM tmp_phase5_delivery_role_permission");
@@ -116,6 +155,8 @@ class Phase5DeliveryPermissionSqlContractTest {
assertThat(readme).contains(
"五期海外排车、出库与派送权限",
"测试和部署只执行固定入口,不再单独执行模块脚本",
"排车列表/编辑/取消/转派送",
"异常订单列表/创建和客户回访列表/编辑十四项权限",
"merchant:warehouse:delivery:list",
"merchant:warehouse:delivery:create",
"PDA 岗位不得获得上述后台权限");