1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| CREATE PROCEDURE `kq`(IN roleId INT) begin declare i int default 0; declare j int default 0; declare k varchar(255) default ''; declare _next TEXT DEFAULT NULL; declare _nextlen INT DEFAULT NULL; declare _value TEXT DEFAULT NULL;
INSERT INTO `test`.`sys_menu`(`pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES ( NULL, 4, 0, '人员温度管理', NULL, NULL, 999, 'anq', 'kq', b'0', b'0', b'0', NULL, 'admin', 'admin', now(), null);
set i = LAST_INSERT_ID();
set k = i; INSERT INTO `test`.`sys_menu`( `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES (i, 0, 1, '异常记录', 'error', 'kq/error/index', 1, 'Steve-Jobs', 'error', b'0', b'0', b'0', 'errorRecord:list', 'admin', 'admin', now(), null); set k = CONCAT(k , ',' ,LAST_INSERT_ID()); INSERT INTO `test`.`sys_menu`( `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES (i, 0, 1, '测温异常 ', 'temperature', 'kq/temperature/index', 2, 'user', 'temperature', b'0', b'0', b'0', 'temperatureError:list', 'admin', 'admin', now(), null); set k = CONCAT(k , ',' ,LAST_INSERT_ID()); INSERT INTO `test`.`sys_menu`( `pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES (i, 0, 1, '出入记录', 'inOut', 'kq/inOut/index', 3, 'link', 'inOut', b'0', b'0', b'0', 'inOutRecord:list', 'admin', 'admin', now(), null); set k = CONCAT(k , ',' ,LAST_INSERT_ID()); INSERT INTO `test`.`sys_menu`(`pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES (i, 2, 1, '考勤统计', 'errorPerson', 'kq/errorPerson/index', 4, 'permission', 'errorPerson', b'0', b'0', b'0', 'kqCount:list', 'admin', 'admin', now(), null); set j = LAST_INSERT_ID(); set k = CONCAT(k , ',' ,j); INSERT INTO `test`.`sys_menu`(`pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES (j, 0, 2, '缺勤列表', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'notPerson:list', 'admin', 'admin', now(), null); set k = CONCAT(k , ',' ,LAST_INSERT_ID()); INSERT INTO `test`.`sys_menu`(`pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES (j, 0, 2, '异常列表', NULL, NULL, 999, NULL, NULL, b'0', b'0', b'0', 'errorPerson:list', 'admin', 'admin', now(), null); set k = CONCAT(k , ',' ,LAST_INSERT_ID());
iterator: LOOP IF LENGTH(TRIM(k)) = 0 OR k IS NULL THEN LEAVE iterator; END IF;
SET _next = SUBSTRING_INDEX(k,',',1);
SET _nextlen = LENGTH(_next);
SET _value = TRIM(_next);
INSERT INTO `test`.`sys_roles_menus`(`menu_id`, `role_id`) VALUES (_value, roleId );
SET k = INSERT(k,1,_nextlen + 1,''); END LOOP; commit; END
call kq(1);
DROP PROCEDURE kq;
|