fix: 对齐QQBot消息推送菜单授权

This commit is contained in:
sunlei 2026-07-24 04:49:33 +08:00
parent b33b753ffc
commit 832046b3bc
3 changed files with 33 additions and 11 deletions

View File

@ -1173,10 +1173,20 @@ ON DUPLICATE KEY UPDATE `pid`=VALUES(`pid`),`path`=VALUES(`path`),`component`=VA
INSERT IGNORE INTO `admin_role_menu` (`role_id`, `menu_id`)
SELECT role.`id`, menu.`id`
FROM `admin_role` role
JOIN `admin_menu` menu ON menu.`name` LIKE 'QqBot%'
CROSS JOIN `admin_menu` menu
WHERE role.`role_code` IN ('super', 'admin')
AND role.`status` = 1
AND role.`is_deleted` = 0
AND menu.`id` IN (
2041700000000100413, 2041700000000100414,
2041700000000120461, 2041700000000120462, 2041700000000120463,
2041700000000120464, 2041700000000120465, 2041700000000120471,
2041700000000120472, 2041700000000120473, 2041700000000120474,
2041700000000120475, 2041700000000120476, 2041700000000120481,
2041700000000120482, 2041700000000120483, 2041700000000120484,
2041700000000120485
)
AND menu.`status` = 1
AND menu.`is_deleted` = 0;
SET FOREIGN_KEY_CHECKS = 1;

View File

@ -425,10 +425,20 @@ ON DUPLICATE KEY UPDATE
INSERT IGNORE INTO `admin_role_menu` (`role_id`, `menu_id`)
SELECT role.`id`, menu.`id`
FROM `admin_role` role
JOIN `admin_menu` menu ON menu.`name` LIKE 'QqBot%'
CROSS JOIN `admin_menu` menu
WHERE role.`role_code` IN ('super', 'admin')
AND role.`status` = 1
AND role.`is_deleted` = 0
AND menu.`id` IN (
2041700000000100413, 2041700000000100414,
2041700000000120461, 2041700000000120462, 2041700000000120463,
2041700000000120464, 2041700000000120465, 2041700000000120471,
2041700000000120472, 2041700000000120473, 2041700000000120474,
2041700000000120475, 2041700000000120476, 2041700000000120481,
2041700000000120482, 2041700000000120483, 2041700000000120484,
2041700000000120485
)
AND menu.`status` = 1
AND menu.`is_deleted` = 0;
SET FOREIGN_KEY_CHECKS = 1;

View File

@ -467,15 +467,17 @@ describe('QQBot message-push SQL contract', () => {
}
});
it('grants only the seeded message-push menus to active super and admin roles after refactor seeding', () => {
const roleGrant = extractMessagePushMenuRoleGrantStatement(seedSql);
expect(roleGrant).toContain('insert ignore into admin_role_menu (role_id, menu_id)');
expect(extractMenuRoleGrantIds(roleGrant)).toEqual(menuEntries.map(([id]) => id));
expect(roleGrant).toContain("role.role_code in ('super', 'admin')");
expect(roleGrant).toContain('role.status = 1');
expect(roleGrant).toContain('role.is_deleted = 0');
expect(roleGrant).toContain('menu.status = 1');
expect(roleGrant).toContain('menu.is_deleted = 0');
it('grants only the seeded message-push menus to active super and admin roles after every menu seed', () => {
for (const sql of [bootstrapSql, seedSql, vbenSql]) {
const roleGrant = extractMessagePushMenuRoleGrantStatement(sql);
expect(roleGrant).toContain('insert ignore into admin_role_menu (role_id, menu_id)');
expect(extractMenuRoleGrantIds(roleGrant)).toEqual(menuEntries.map(([id]) => id));
expect(roleGrant).toContain("role.role_code in ('super', 'admin')");
expect(roleGrant).toContain('role.status = 1');
expect(roleGrant).toContain('role.is_deleted = 0');
expect(roleGrant).toContain('menu.status = 1');
expect(roleGrant).toContain('menu.is_deleted = 0');
}
});
it('uses an exact mismatch CTE and null-safe predicates for every stable menu tuple', () => {