All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cloud-auth.mapper.RoleMapper.xml Maven / Gradle / Ivy

<?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="xin.yuki.auth.core.mapper.RoleMapper">
    <sql id="Base_Column_List">
        r.name,
        r.description,
        r.id,
        r.version
    </sql>

    <resultMap id="BaseResultMap" type="xin.yuki.auth.core.entity.RoleModel">
        <result column="name" property="name"/>
        <result column="description" property="description"/>
        <result column="id" property="id"/>
        <result column="version" property="version"/>
    </resultMap>

    <resultMap id="UserResultMap" type="xin.yuki.auth.core.entity.RoleModel" extends="BaseResultMap">
        <collection column="id" property="users" select="xin.yuki.auth.core.mapper.UserMapper.findByRoleId"/>
    </resultMap>

    <resultMap id="GroupsResultMap" type="xin.yuki.auth.core.entity.RoleModel" extends="BaseResultMap">
        <collection column="id" property="groups" select="xin.yuki.auth.core.mapper.GroupMapper.findByRoleId"/>
    </resultMap>

    <resultMap id="PermissionResultMap" type="xin.yuki.auth.core.entity.RoleModel" extends="BaseResultMap">
        <collection column="id" property="permissions"
                    select="xin.yuki.auth.core.mapper.PermissionMapper.findByRoleId"/>
    </resultMap>

    <resultMap id="FullResultMap" type="xin.yuki.auth.core.entity.RoleModel" extends="BaseResultMap">
        <collection column="id" property="users" select="xin.yuki.auth.core.mapper.UserMapper.findByRoleId"/>
        <collection column="id" property="groups" select="xin.yuki.auth.core.mapper.GroupMapper.findByRoleId"/>
        <collection column="id" property="permissions"
                    select="xin.yuki.auth.core.mapper.PermissionMapper.findByRoleId"/>
    </resultMap>


    <!--auto generated by codehelper on 2018-12-24-->
    <select id="findByUserId" resultMap="PermissionResultMap">
        select
        <include refid="Base_Column_List"/>
        from roles r
        left join users_roles ur on r.id=ur.role_id
        left join users u on u.id=ur.user_id
        where u.id=#{userId}
    </select>

    <select id="findByGroupId" resultMap="PermissionResultMap">
        select
        <include refid="Base_Column_List"/>
        from roles r
        left join groups_roles gr on r.id=gr.role_id
        left join groups g on g.id=gr.group_id
        where g.id=#{groupId}
    </select>
</mapper>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy