CREATE TABLE `tab_menu` ( `MU_ID` int(10) NOT NULL AUTO_INCREMENT COMMENT ‘主键‘, `MU_NAME` varchar(255) NOT NULL COMMENT ‘菜单名‘, `MU_CODE` varchar(100) DEFAULT NULL COMMENT ‘菜单编码‘, `MU_CHAIN_NAME` varchar(255) NOT NULL COMMENT ‘菜单全名‘, `MU_PARENT_ID` int(10) NOT NULL COMMENT ‘上级菜单ID‘, `MU_URL` varchar(255) NOT NULL COMMENT ‘菜单URL‘, `STATUS` smallint(1) NOT NULL DEFAULT ‘1‘ COMMENT ‘状态;0:未启用 1:已启用,默认为1‘, `MU_ELEMENT_TYPE` varchar(40) NOT NULL COMMENT ‘所属元素类型‘, `MU_SCOPE` varchar(20) NOT NULL DEFAULT ‘common‘ COMMENT ‘菜单作用范围;‘, `CREATE_USER_ID` int(11) NOT NULL COMMENT ‘创建用户ID‘, `CREATE_TIME` datetime NOT NULL COMMENT ‘创建时间‘, `UPDATE_USER_ID` int(11) DEFAULT NULL COMMENT ‘修改用户ID‘, `UPDATE_TIME` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT ‘修改时间‘, `VERSION_NUMBER` int(11) NOT NULL DEFAULT ‘0‘ COMMENT ‘版本号:新增资料为 0,每次修改加 1‘, PRIMARY KEY (`MU_ID`), KEY `idx_menu_url` (`MU_URL`) ) ENGINE=InnoDB AUTO_INCREMENT=2040101 DEFAULT CHARSET=utf8 COMMENT=‘菜单‘;
CREATE DEFINER=`ggs`@`%` FUNCTION `pkg_pm_fun_get_children_branch`(menu_id int(10)) RETURNS text CHARSET utf8 COLLATE utf8_bin begin declare menu_ids TEXT; declare tmp_menu_ids text; set tmp_menu_ids =‘$‘; set menu_ids = cast(menu_id as char); while menu_ids is not null do set tmp_menu_ids = concat(tmp_menu_ids,‘,‘,menu_ids); select group_concat(mu_id) into menu_ids from tab_menu where find_in_set(mu_parent_id,menu_ids) > 0; end while; return tmp_menu_ids; end
时间: 2024-11-06 16:15:15