<!-- 角色权限修改时-->
<resultMap id="ResultMenuPermissionWithRoleMap"
type="com.water.net.system.vo.MenuPermissionVo" >
<id column="menu_id" property="menuId" jdbcType="VARCHAR" />
<result column="menu_name" property="menuName" jdbcType="VARCHAR" />
<result column="parent_id" property="parentId" jdbcType="VARCHAR" />
<result column="actions" property="actions" jdbcType="VARCHAR" />
<result column="role_id" property="roleId" jdbcType="VARCHAR" />
<result column="menu_permission" property="menuPermission" jdbcType="CHAR" />
<result column="action_permission" property="actionPermission" jdbcType="VARCHAR" />
<collection column="{menuId=menu_id, roleId=role_id}" property="children"
ofType="com.water.net.system.vo.MenuPermissionVo"
javaType="java.util.ArrayList"
select="selectMenuChildrenWithPermissionByRole"/>
</resultMap>
<select id="selectMenuPermissionByRole" resultMap="ResultMenuPermissionWithRoleMap"
parameterType="java.lang.String" >
select tm.menu_id, menu_name, parent_id, actions,
role_id, menu_permission, action_permission
from t_sys_menu tm join t_sys_permission tp on tm.menu_id = tp.menu_id
where tp.role_id = #{roleId,jdbcType=VARCHAR}
and tm.parent_id = '000000' and tm.is_display = '1'
order by tm.menu_id
</select>
<!-- 递归查询下一级菜单 -->
<select id="selectMenuChildrenWithPermissionByRole"
resultMap="ResultMenuPermissionWithRoleMap" parameterType="java.util.Map">
select tm.menu_id, menu_name, parent_id, actions,
role_id, menu_permission, action_permission
from t_sys_menu tm
join t_sys_permission tp on tm.menu_id = tp.menu_id
where tp.role_id = #{roleId,jdbcType=VARCHAR}
and tm.parent_id = #{menuId,jdbcType=VARCHAR}
and tm.is_display = '1'
order by tm.menu_id
</select>
mtbatis 递归查询下一级
最新推荐文章于 2023-12-28 23:20:25 发布