<?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="cn.com.countrygarden.bi.main.dao.sys.UserRolesMapper">
    <resultMap id="BaseResultMap" type="cn.com.countrygarden.bi.main.model.sys.UserRoles">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="role_code" jdbcType="VARCHAR" property="roleCode"/>
        <result column="user_code" jdbcType="VARCHAR" property="userCode"/>
        <result column="created_date" jdbcType="TIMESTAMP" property="createdDate" javaType="java.util.Date"/>
        <result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
        <result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate" javaType="java.util.Date"/>
        <result column="updated_by" jdbcType="VARCHAR" property="updatedBy"/>
    </resultMap>

    <select id="searchByUserCodes" resultMap="BaseResultMap">
        <![CDATA[
      SELECT * FROM user_roles
      WHERE role_code =#{roleCode}
      AND user_code IN
    ]]>
        <foreach item="item" index="index" collection="userCodes" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>
    <select id="searchByUserCode" resultMap="BaseResultMap">
        <![CDATA[

      SELECT role_code FROM user_roles
      WHERE user_code =#{userCode}

        ]]>
    </select>

    <!--查询中心对接人，中心对接人查询接口，不包含user_target里面的数据-->
    <select id="selectperformanceCenter" resultType="java.lang.String">
    <![CDATA[

        select user_code from user_roles where role_code = 'performance_quota_broker' and user_code not in (select userCode from user_target)

        ]]>
  </select>
    <select id="selectUserCodes" resultType="java.lang.String">
    <![CDATA[

        select user_code from user_roles where role_code = #{roleCode}

        ]]>
  </select>
    <select id="countByUserCodeAndoleCode" resultType="java.lang.Integer">
        select count(1) from user_roles where role_code =#{roleCode} and user_code=#{userCode}
    </select>

</mapper>