wms/nflg-wms-repository/src/main/resources/mapper/MenuMapper.xml

48 lines
2.0 KiB
XML
Raw Normal View History

2025-06-03 17:18:11 +08:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nflg.wms.repository.mapper.MenuMapper">
2025-06-30 17:39:23 +08:00
<select id="getButtonsByMenuId" resultType="com.nflg.wms.common.pojo.vo.ButtonVO">
SELECT DISTINCT mb.id,mb.name, mb.code
2025-06-30 17:39:23 +08:00
FROM role r
INNER JOIN role_button_map rbm ON r.id = rbm.role_id
2025-07-01 10:34:04 +08:00
INNER JOIN menu_button mb ON rbm.button_id = mb.id
2025-06-30 17:39:23 +08:00
INNER JOIN user_role_map urm ON urm.role_id = r.id
2025-07-01 10:34:04 +08:00
WHERE mb.enable = TRUE
2025-06-30 17:39:23 +08:00
AND mb.menu_id = #{menuId}
AND urm.user_id = #{userId}
2025-09-26 18:04:00 +08:00
order by mb.id
2025-06-30 17:39:23 +08:00
</select>
<select id="menuIsSelected" resultType="java.lang.Boolean">
SELECT EXISTS(SELECT 1
FROM role_menu_map
WHERE menu_id = #{menuId}
AND role_id = #{roleId})
</select>
2025-09-03 12:33:36 +08:00
<select id="getAllDataForAuthorize" resultType="com.nflg.wms.common.pojo.vo.MenuAuthorizeVO">
select id,parent_id,"name",CONCAT('menu-', id) as key,sort,1 as type
,case when b.menu_id is null then false else true end as selected
2025-09-03 12:33:36 +08:00
from menu a
left join (select menu_id from role_menu_map where role_id = #{roleId}) b on a.id = b.menu_id
2025-09-03 12:33:36 +08:00
where "enable" = true
UNION
select id,menu_id,"name",CONCAT('button-', id) as key,sort,2 as type
,case when b.button_id is null then false else true end as selected
2025-09-03 12:33:36 +08:00
from menu_button a
left join (select button_id from role_button_map where role_id = #{roleId}) b on a.id = b.button_id
2025-09-03 12:33:36 +08:00
where "enable" = true
order by sort;
</select>
<select id="getMenuIdsByRoleIds" resultType="java.lang.Long">
SELECT menu_id
FROM role_menu_map
WHERE role_id IN
<foreach item="roleId" collection="roleIds" separator="," open="(" close=")">
#{roleId}
</foreach>
</select>
2025-06-03 17:18:11 +08:00
</mapper>