chore: 并入 iotlcm-admin-svr 历史到 admin-svr/(原提交 49818c6)
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
CREATE TEMPORARY TABLE `tmp_agent_role_source_map` AS
|
||||
SELECT `tenant_id`, `dept_id`, MIN(`role_id`) AS `source_role_id`
|
||||
FROM `sys_role`
|
||||
WHERE `is_pass` = 1 AND `deleted_at` IS NULL
|
||||
GROUP BY `tenant_id`, `dept_id`
|
||||
HAVING COUNT(*) = 1;
|
||||
|
||||
UPDATE `sys_role` AS `child_role`
|
||||
JOIN `sys_dept` AS `child_dept`
|
||||
ON `child_dept`.`dept_id` = `child_role`.`dept_id`
|
||||
AND `child_dept`.`tenant_id` = `child_role`.`tenant_id`
|
||||
AND `child_dept`.`dept_role` = `child_role`.`role_id`
|
||||
AND `child_dept`.`dept_type` = 1
|
||||
JOIN `tmp_agent_role_source_map` AS `source_map`
|
||||
ON `source_map`.`tenant_id` = `child_dept`.`tenant_id`
|
||||
AND `source_map`.`dept_id` = `child_dept`.`parent_id`
|
||||
JOIN `sys_role` AS `source_role` ON `source_role`.`role_id` = `source_map`.`source_role_id`
|
||||
SET
|
||||
`child_role`.`source_role_id` = `source_role`.`role_id`,
|
||||
`child_role`.`source_dept_id` = `source_role`.`dept_id`
|
||||
WHERE `child_role`.`source_role_id` = 0
|
||||
AND `child_role`.`created_dept` = `source_role`.`dept_id`
|
||||
AND `child_role`.`role_key` = `source_role`.`role_key`
|
||||
AND `child_role`.`deleted_at` IS NULL;
|
||||
|
||||
DROP TEMPORARY TABLE `tmp_agent_role_source_map`;
|
||||
Reference in New Issue
Block a user