<?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.njzscloud.dispose.sys.role.mapper.RoleMapper">

    <select id="paging" resultType="com.njzscloud.dispose.sys.role.pojo.entity.RoleEntity">
        SELECT id,
        role_code,
        role_name,
        memo
        FROM sys_role
        <if test="ew != null and ew.customSqlSegment != null and ew.customSqlSegment !=''">
            ${ew.customSqlSegment}
        </if>
    </select>
    <select id="listUserRole" resultType="com.njzscloud.dispose.sys.role.pojo.entity.RoleEntity">
        SELECT a.role_code, a.id, a.role_name, a.memo
        FROM sys_role a
                 INNER JOIN sys_user_role b ON b.role_id = a.id AND b.user_id = #{userId}
    </select>
    <select id="candel" resultType="java.lang.Boolean">
        SELECT COUNT(*) = 0
        FROM sys_role a
        INNER JOIN sys_user_role b ON b.role_id = a.id
        <if test="ew != null and ew.customSqlSegment != null and ew.customSqlSegment !=''">
            ${ew.customSqlSegment}
        </if>
    </select>
    <select id="users" resultType="java.lang.Long">
        SELECT b.user_id
        FROM sys_role a
                 INNER JOIN sys_user_role b ON b.role_id = a.id
        WHERE a.id = #{id}
    </select>
</mapper>
