<?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">
<!-- 不使用namespace的话sql搜索定位会比较方便 -->
<mapper namespace="com.blueland.dao.Role2userDao">

    <resultMap id="RM_RoleId" type="com.blueland.bo.AppIdUserIdAppIdRoleIdDTO">
        <result column="APP_ID" property="appId"/>
        <result column="USER_ID" property="userId"/>
        <collection property="list" ofType="java.lang.String">
            <result column="APP_ID_ROLE_ID"/>
        </collection>
    </resultMap>

    <select id="findListRoleId" resultMap="RM_RoleId">
        SELECT APP_ID,USER_ID,CONCAT(APP_ID,':',ROLE_ID) APP_ID_ROLE_ID FROM t_pf_role2user
        WHERE STATUS = 'Y'
        <if test="appId != null and appId != ''">
            and APP_ID = #{appId}
        </if>
    </select>

    <delete id="deleteByAppId">
        delete from t_pf_role2user where app_id = #{appId}
    </delete>

    <select id="selectListByAppId" resultType="com.blueland.model.TPfRole2user">
        SELECT
            ROLE_ID AS roleId,
            USER_ID AS userId,
            STATUS AS STATUS,
            CREATOR_ID AS creatorId,
            CREATE_DATE AS createDate,
            UPDATOR_ID AS updatorId,
            UPDATE_DATE AS updateDate,
            ORG_ID AS orgId,
            ORG_NAME AS orgName,
            TITLE_ID AS titleId,
            APP_ID AS appId,
            staff_post_code AS staffPostCode
        FROM
            t_pf_role2user
        WHERE STATUS = "Y" and APP_ID =#{appId}
    </select>

</mapper>

