<?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.freemud.order.mapper.OpenPlatformPartnerDao">
    <resultMap id="BaseResultMap" type="cn.freemud.order.entity.OpenPlatformPartner">
        <id column="id" jdbcType="BIGINT" property="id" />
        <result column="partner_id" jdbcType="VARCHAR" property="partnerId" />
        <result column="status" jdbcType="TINYINT" property="status" />
        <result column="open_appid" jdbcType="VARCHAR" property="openAppid" />
        <result column="partner_name" jdbcType="VARCHAR" property="partnerName" />
        <result column="subject_name" jdbcType="VARCHAR" property="subjectName" />
        <result column="partner_logo" jdbcType="VARCHAR" property="partnerLogo" />
        <result column="company_name" jdbcType="VARCHAR" property="companyName" />
        <result column="create_name" jdbcType="VARCHAR" property="createName" />
        <result column="gmt_created" jdbcType="TIMESTAMP" property="gmtCreated" />
        <result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified" />
    </resultMap>
    <sql id="all_column">
        id,
        partner_id,
        status,
        open_appid,
        partner_name,
        subject_name,
        partner_logo,
        company_name,
        create_name,
        gmt_created,
        gmt_modified
    </sql>

    <select id="selectOpenPlatformPartnerList" resultMap="BaseResultMap">
        SELECT
        <include refid="all_column"/>
        FROM open_platform_partner
       WHERE 1=1
       <if test="partnerIdList.size >0">
           AND partner_id IN
           <foreach collection="partnerIdList" index="index" item="item" open="(" separator="," close=")">
               #{item}
           </foreach>
       </if>
        AND status =1
    </select>

    <select id="selectOpenPlatformPartner" resultMap="BaseResultMap">
        SELECT
        <include refid="all_column"/>
        FROM open_platform_partner
        WHERE partner_id = #{partnerId}
        order by gmt_created DESC
    </select>
</mapper>