Files
shanxia2.0/docs/sql/migrations/2026-09-26-mini-db-inventory-role-grant.sql
T
2026-09-26 11:59:39 +08:00

43 lines
1.3 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 移动端「地磅管理 → 出入库管理」授权给指定角色
-- 菜单:MINI_DB_INVENTORY(perms=mini:db:inventory:list)
-- 祖先:移动端(id=1)、地磅管理(MINI_DB_ROOT) — 选中子菜单须含祖先,否则侧栏/宫格不可见
-- 角色:管理员、销售主管、销售计划员、销售实录员、销售办证员、超级管理员
-- 执行环境:生产库(backend/.env.production)数据库名 shanxia2.0;可幂等重复执行
SET NAMES utf8mb4;
INSERT INTO `sys_role_menu` (
`id`, `role_id`, `menu_id`, `tenant_no`, `order_num`, `remark`,
`create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
)
SELECT
MD5(CONCAT(r.id, '|', m.menu_id, '|mini-db-inventory-grant|v1')),
r.id,
m.menu_id,
r.tenant_no,
0,
'移动端出入库管理授权',
'system',
'',
NOW(),
NULL,
NOW(),
0
FROM `sys_role` r
INNER JOIN (
SELECT '1' AS menu_id
UNION ALL SELECT 'MINI_DB_ROOT'
UNION ALL SELECT 'MINI_DB_INVENTORY'
) m
WHERE r.tenant_no = 'shanxia2.0'
AND r.del_flag = 0
AND r.role_name IN (
'管理员', '销售主管', '销售计划员', '销售实录员', '销售办证员', '超级管理员'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_menu` x
WHERE x.role_id = r.id
AND x.menu_id = m.menu_id
AND x.del_flag = 0
);