feat(brandgating): 品牌Gating库恢复独立菜单
V164 建菜单、V166 回滚后,按 2026-10-25 决定用 V174 恢复独立菜单, 不再作为「店铺数据重复检查」的第三页签;后端权限键同步改为 admin_brand_gating。
This commit is contained in:
+5
-6
@@ -33,9 +33,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* 品牌Gating库(管理后台):独立小网页后台(gating_web_admin.py)并入数富管理后台,
|
||||
* 共用主库同一张 biz_brand_gating 表。
|
||||
*
|
||||
* <p>本模块以「品牌Gating库」页签嵌在「店铺数据重复检查」页(DuplicateCheckPage.vue)里,
|
||||
* 不再占用独立菜单行(V164 菜单已由 V166 删除)。因此页面权限键跟随宿主页
|
||||
* {@code admin_shop_data_duplicate_check},经
|
||||
* <p>本模块占用独立菜单「品牌Gating库」{@code admin_brand_gating}(V164 建菜单、V166 回滚、
|
||||
* V174 恢复),页面权限键与菜单键一致,经
|
||||
* {@link PermissionMenuService#requireConsolePageAccess} 把门;鉴权第一道门由
|
||||
* AdminApiGuardFilter 的 /api/admin 前缀兜底(见 ApiGuardCoverageAuditor 口径)。</p>
|
||||
*/
|
||||
@@ -45,8 +44,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@Tag(name = "品牌Gating库(后台)", description = "品牌Gating库的列表/筛选/统计、单条新增、启停、删除与批量导入。")
|
||||
public class BrandGatingController {
|
||||
|
||||
/** 宿主页「店铺数据重复检查」的后台菜单权限键(columns.column_key)。 */
|
||||
private static final String PERMISSION_KEY = "admin_shop_data_duplicate_check";
|
||||
/** 「品牌Gating库」独立菜单的后台权限键(columns.column_key)。 */
|
||||
private static final String PERMISSION_KEY = "admin_brand_gating";
|
||||
private static final String DENIAL_MESSAGE = "无权访问品牌Gating库";
|
||||
|
||||
private final BrandGatingService brandGatingService;
|
||||
@@ -112,7 +111,7 @@ public class BrandGatingController {
|
||||
return ApiResponse.success(brandGatingService.importRows(body));
|
||||
}
|
||||
|
||||
/** 逐端点把门:登录态 + 宿主页后台菜单权限(admin_shop_data_duplicate_check)。 */
|
||||
/** 逐端点把门:登录态 + 「品牌Gating库」后台菜单权限(admin_brand_gating)。 */
|
||||
private void requireBrandGatingAccess(HttpServletRequest request) {
|
||||
AdminUserEntity operator = adminAuthSupport.requireUser(request);
|
||||
permissionMenuService.requireConsolePageAccess(operator, DENIAL_MESSAGE, PERMISSION_KEY);
|
||||
|
||||
+1
@@ -80,6 +80,7 @@ public class PermissionMenuSchemaInitializer {
|
||||
new DefaultAdminMenu("密钥用量统计", "admin_user_secret_usage", "account/user-secret-usage", 42, "admin_group_account"),
|
||||
new DefaultAdminMenu("去重数据汇总", "admin_dedupe_total_data", "dedupe-total-data", 30, "admin_group_data"),
|
||||
new DefaultAdminMenu("品牌数据库", "admin_invalid_asin_data", "invalid-asin-data", 35, "admin_group_data"),
|
||||
new DefaultAdminMenu("品牌Gating库", "admin_brand_gating", "brand-gating", 36, "admin_group_data"),
|
||||
new DefaultAdminMenu("查询ASIN", "admin_query_asin", "query-asin", 65, "admin_group_data"),
|
||||
new DefaultAdminMenu("商品类目", "admin_product_categories", "product-categories", 66, "admin_group_data"),
|
||||
new DefaultAdminMenu("店铺密钥管理", "admin_shop_keys", "shop-keys", 40, "admin_group_shop"),
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
-- =============================================================
|
||||
-- 迁移 V174__restore_admin_brand_gating_menu
|
||||
--
|
||||
-- 1. 变更目的:按 2026-10-25 决定,把「品牌Gating库」恢复为独立后台菜单
|
||||
-- (column_key='admin_brand_gating',route_path='brand-gating'),不再作为
|
||||
-- 「店铺数据重复检查」页的第三个页签。V164 首次落库、V166 回滚删除;已应用迁移
|
||||
-- 一个字节都不许改,故由本迁移重新插入。
|
||||
--
|
||||
-- 2. 口径:沿用 V164 的数据形状——挂在数据管理组 admin_group_data 下、排序 36,
|
||||
-- company_id = 1 为模板行,其余公司(含 status=0 的停用公司)逐家复制一份;
|
||||
-- 子行 parent_id 必须认本公司 admin_group_data 组行,严禁跨公司认父。
|
||||
-- 幂等守卫按 (company_id, column_key) 判存,同时防 (menu_type, route_path)
|
||||
-- 唯一键 uk_company_menu_type_route_path 撞行。
|
||||
--
|
||||
-- 3. 默认授权:本迁移不预授 user_column_permission;管理员角色链可直进,
|
||||
-- 普通账号由管理员在「菜单权限配置」里按公司分配。
|
||||
--
|
||||
-- 4. 影响表与数据量:columns +N 行(N = 公司数),字典小表,毫秒级,不碰锁热点表。
|
||||
--
|
||||
-- 5. 【可重跑性】两段 INSERT 都带 NOT EXISTS 守卫;重跑逐条 no-op。
|
||||
-- =============================================================
|
||||
|
||||
-- ---------- 1. 公司 1 模板行(认公司 1 的 admin_group_data 组行) ----------
|
||||
INSERT INTO `columns` (`name`, `column_key`, `menu_type`, `route_path`, `sort_order`, `parent_id`, `company_id`)
|
||||
SELECT '品牌Gating库', 'admin_brand_gating', 'admin', 'brand-gating', 36, grp.`id`, 1
|
||||
FROM `columns` grp
|
||||
WHERE grp.`company_id` = 1 AND grp.`column_key` = 'admin_group_data'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `columns`
|
||||
WHERE `company_id` = 1
|
||||
AND (`column_key` = 'admin_brand_gating'
|
||||
OR (`menu_type` = 'admin' AND `route_path` = 'brand-gating'))
|
||||
);
|
||||
|
||||
-- ---------- 2. 复制到其余公司(含停用公司),各自认本公司组行 ----------
|
||||
INSERT INTO `columns` (`name`, `column_key`, `menu_type`, `route_path`, `sort_order`, `parent_id`, `company_id`)
|
||||
SELECT '品牌Gating库', 'admin_brand_gating', 'admin', 'brand-gating', 36, grp.`id`, c.`id`
|
||||
FROM `company` c
|
||||
JOIN `columns` grp ON grp.`company_id` = c.`id` AND grp.`column_key` = 'admin_group_data'
|
||||
WHERE c.`id` <> 1
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `columns` col
|
||||
WHERE col.`company_id` = c.`id`
|
||||
AND (col.`column_key` = 'admin_brand_gating'
|
||||
OR (col.`menu_type` = 'admin' AND col.`route_path` = 'brand-gating'))
|
||||
);
|
||||
|
||||
-- ---------- 3. 自检闸门:不为 0 就抛 1048(列 must_be_zero NOT NULL) ----------
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS `_v174_gate` (`must_be_zero` INT NOT NULL);
|
||||
|
||||
-- 闸门 1:每家公司都必须恰好一行 admin_brand_gating(少一家也算错)
|
||||
INSERT INTO `_v174_gate`
|
||||
SELECT IF(COUNT(*) = 0, 0, NULL)
|
||||
FROM (
|
||||
SELECT c.`id`
|
||||
FROM `company` c
|
||||
LEFT JOIN `columns` col ON col.`company_id` = c.`id` AND col.`column_key` = 'admin_brand_gating'
|
||||
GROUP BY c.`id`
|
||||
HAVING COUNT(col.`id`) <> 1
|
||||
) bad;
|
||||
|
||||
-- 闸门 2:admin/brand-gating 路由不允许被别的 column_key 占行
|
||||
INSERT INTO `_v174_gate`
|
||||
SELECT IF(COUNT(*) = 0, 0, NULL)
|
||||
FROM `columns` col
|
||||
WHERE col.`menu_type` = 'admin'
|
||||
AND col.`route_path` = 'brand-gating'
|
||||
AND col.`column_key` <> 'admin_brand_gating';
|
||||
|
||||
-- 闸门 3:admin_brand_gating 行的父必须是本公司的 admin_group_data 组行
|
||||
INSERT INTO `_v174_gate`
|
||||
SELECT IF(COUNT(*) = 0, 0, NULL)
|
||||
FROM (
|
||||
SELECT col.`id`
|
||||
FROM `columns` col
|
||||
LEFT JOIN `columns` grp ON grp.`id` = col.`parent_id` AND grp.`column_key` = 'admin_group_data'
|
||||
WHERE col.`column_key` = 'admin_brand_gating'
|
||||
AND (grp.`id` IS NULL OR grp.`company_id` <> col.`company_id`)
|
||||
) bad;
|
||||
|
||||
DROP TEMPORARY TABLE `_v174_gate`;
|
||||
+2
-2
@@ -464,12 +464,12 @@ class BrandGatingServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("控制器契约:随宿主页用 admin_shop_data_duplicate_check 权限键、逐端点 requireUser + requireConsolePageAccess 把门")
|
||||
@DisplayName("控制器契约:独立菜单用 admin_brand_gating 权限键、逐端点 requireUser + requireConsolePageAccess 把门")
|
||||
void controllerGatesEveryEndpointWithPermissionKey() throws Exception {
|
||||
String source = Files.readString(Path.of(
|
||||
"src/main/java/com/nanri/aiimage/modules/brandgating/controller/BrandGatingController.java"),
|
||||
StandardCharsets.UTF_8);
|
||||
assertThat(source).contains("PERMISSION_KEY = \"admin_shop_data_duplicate_check\"");
|
||||
assertThat(source).contains("PERMISSION_KEY = \"admin_brand_gating\"");
|
||||
assertThat(source).contains("adminAuthSupport.requireUser(request)");
|
||||
assertThat(source).contains("requireConsolePageAccess(operator, DENIAL_MESSAGE, PERMISSION_KEY)");
|
||||
// 6 个端点方法都必须先过把门助手
|
||||
|
||||
Reference in New Issue
Block a user