<?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.lantone.security.mapper.UserRoleMapper">
    <select id="getUserRoles" resultType="com.lantone.security.dto.UserRoleDTO">
        SELECT
            r.id roleId,
          r.`name` roleName
        FROM
            sys_user_role ur,
            sys_role r
        WHERE
            r.`status` = '1'
        and ur.role_id = r.id
        AND ur.is_deleted = 'N'
        AND r.is_deleted = 'N'
        AND ur.user_id = #{userId}
    </select>
    <select id="getUserRoleById" resultType="java.lang.Long">
        SELECT
            r.id
        FROM
            sys_role r,
            sys_user_role ur
        WHERE
            r.is_deleted = 'N'
        AND ur.is_deleted = 'N'
        AND r.id = ur.role_id
        AND r.remark = 'ManagementRole'
        AND ur.user_id = #{userId}
    </select>
</mapper>