Ver código fonte

update 菜单页面查询 子菜单关联查询

bzd_lxf 4 semanas atrás
pai
commit
053c477013

+ 23 - 0
health-system/src/main/resources/mapper/system/SysMenuMapper.xml

@@ -86,10 +86,33 @@
 	</select>
 
 	<select id="selectMenuList" parameterType="SysMenu" resultMap="SysMenuResult">
+		<if test="menuName != null and menuName != ''">
+			WITH RECURSIVE menu_tree AS (
+		</if>
 		<include refid="selectMenuVo"/>
 		<where>
 			<if test="menuName != null and menuName != ''">
 				AND menu_name like concat('%', #{menuName}, '%')
+				UNION ALL -- 递归地选择子菜单
+				SELECT
+				m.menu_id,
+				m.menu_name,
+				m.parent_id,
+				m.order_num,
+				m.url,
+				m.target,
+				m.menu_type,
+				m.visible,
+				m.is_refresh,
+				ifnull( m.perms, '' ) AS perms,
+				m.icon,
+				m.create_by,
+				m.create_time
+				FROM
+				sys_menu AS m
+				INNER JOIN menu_tree AS parent ON m.parent_id = parent.menu_id
+				where m.menu_name LIKE concat( '%', #{menuName}, '%' )
+				) SELECT DISTINCT * FROM menu_tree
 			</if>
 			<if test="visible != null and visible != ''">
 				AND visible = #{visible}