/*
将超级管理员同步到新的权限管理表中,可重复执行,已存在将不在添加
/
drop procedure if exists historysuperadmin;
create procedure historysuperadmin()
BEGIN
DECLARE no_more_record INT DEFAULT 0;
declare userid VARCHAR(255);
declare rolename VARCHAR(255);
DECLARE rolecount INT DEFAULT 0;
DECLARE cur_record CURSOR FOR select a.id,a.role_id from user a where role_id='role0';
DECLARE CONTINUE HANDLER FOR NOT FOUND SET no_more_record = 1;
OPEN cur_record;
FETCH cur_record INTO userid, rolename;
WHILE no_more_record != 1 DO
select count() into rolecount from r_user_role where role_id='superadmin' AND user_id=userid; /查询是否已存在,存在就不再添加/
if rolecount =0 THEN
insert into r_user_role (id,role_id,user_id) values (UUID(),"superadmin",userid);
end if;
FETCH cur_record INTO userid, rolename;
END WHILE;
CLOSE cur_record;
END
CALL historysuperadmin();
drop procedure if exists historysuperadmin;
版权归属:
王小木人个人技术文章记录
许可协议:
本文使用《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》协议授权
评论区