1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 15:01:23 +08:00
Files
Pinnacle-OA/Pinnacle/src/main/resources/mapper/RoleMapper.xml

92 lines
4.2 KiB
XML

<?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.cfive.pinnacle.mapper.RoleMapper">
<select id="getAll" resultMap="roleMap">
select t_role.id as role_id,
t_role.name as role_name,
t_role.deleted as role_deleted,
t_role.version as role_version,
tm.id as menu_id,
tm.name as menu_name,
tm.url as menu_url,
tm.power_id as menu_power_id,
tm.parent_id as menu_parent_id,
te.id as element_id,
te.name as element_name,
te.power_id as element_power_id,
te.menu_id as element_menu_id,
t.id as operation_id,
t.name as operation_name,
t.code as operation_code,
t.power_id as operation_power_id,
t.element_id as operation_element_id,
t.parent_id as operation_parent_id
from t_role
left join t_power_role tpr on t_role.id = tpr.role_id
left join t_power tp on tp.id = tpr.power_id
left join t_menu tm on tp.id = tm.power_id
left join t_element te on tp.id = te.power_id
left join t_operation t on tp.id = t.power_id
where t_role.deleted = 0 and (tpr.deleted = 0 or tpr.deleted is null);
</select>
<select id="getOneById" resultMap="roleMap">
select t_role.id as role_id,
t_role.name as role_name,
t_role.deleted as role_deleted,
t_role.version as role_version,
tm.id as menu_id,
tm.name as menu_name,
tm.url as menu_url,
tm.power_id as menu_power_id,
tm.parent_id as menu_parent_id,
te.id as element_id,
te.name as element_name,
te.power_id as element_power_id,
te.menu_id as element_menu_id,
t.id as operation_id,
t.name as operation_name,
t.code as operation_code,
t.power_id as operation_power_id,
t.element_id as operation_element_id,
t.parent_id as operation_parent_id
from t_role
left join t_power_role tpr on t_role.id = tpr.role_id
left join t_power tp on tp.id = tpr.power_id
left join t_menu tm on tp.id = tm.power_id
left join t_element te on tp.id = te.power_id
left join t_operation t on tp.id = t.power_id
where t_role.deleted = 0
and tpr.deleted = 0
and t_role.id = #{id};
</select>
<resultMap id="roleMap" type="role">
<id property="id" column="role_id"/>
<result property="name" column="role_name"/>
<result property="deleted" column="role_deleted"/>
<result property="version" column="role_version"/>
<collection property="menus" ofType="menu">
<id property="id" column="menu_id"/>
<result property="name" column="menu_name"/>
<result property="url" column="menu_url"/>
<result property="powerId" column="menu_power_id"/>
<result property="parentId" column="menu_parent_id"/>
</collection>
<collection property="elements" ofType="element">
<id property="id" column="element_id"/>
<result property="name" column="element_name"/>
<result property="powerId" column="element_power_id"/>
<result property="menuId" column="element_menu_id"/>
</collection>
<collection property="operations" ofType="operation">
<id property="id" column="operation_id"/>
<result property="name" column="operation_name"/>
<result property="code" column="operation_code"/>
<result property="powerId" column="operation_power_id"/>
<result property="elementId" column="operation_element_id"/>
<result property="parentId" column="operation_parent_id"/>
</collection>
</resultMap>
</mapper>