<?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.community.huiju.dao.RoleMapper">
    <select id="getRoleListByParams" resultType="com.community.huiju.model.SysRole">
        SELECT
            t.id,
            t.community_id as communityId,
            t.role_name AS roleName,
            t.description,
            t.create_user AS createUser,
            t.create_date AS createDate,
            t.update_user AS updateUser,
            t.update_date AS updateDate,
            u.user_name as createName,
            uu.user_name as updateName
        FROM
            tp_sys_role t
        LEFT JOIN tp_user u ON t.create_user = u.id AND u.community_id = #{role.communityId}
        LEFT JOIN tp_user uu ON t.update_user = uu.id AND uu.community_id = #{role.communityId}
        where
          1 = 1
        AND t.community_id = #{role.communityId}
        <if test="role.roleName != null and role.roleName != ''">
            and t.role_name like concat('%',#{role.roleName,jdbcType=VARCHAR},'%')
        </if>
        ORDER BY
            t.create_date DESC
    </select>

    <select id="selectByRoleName" resultType="com.community.huiju.model.SysRole">
        SELECT id,community_id,role_name,description from tp_sys_role where role_name = #{roleName,jdbcType=VARCHAR} and community_id = #{communityId}
    </select>
</mapper>
