<?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.xingxi.api.data.mapper.WxApiProductMapper">

    <resultMap id="MercProdResponse" type="MercProdResponse">
        <id property="mercProdId"    column="mercProdId"/>
        <result property="mercId" column="mercId"/>
        <result property="prodClassId"    column="prodClassId"/>
        <result property="prodId"    column="prodId"/>
        <result property="prodName"    column="prodName"/>
        <result property="ipId"    column="ipId"/>
        <result property="designerId"    column="designerId"/>
        <result property="description"    column="description"/>
        <result property="prodStatus"    column="prodStatus"/>
        <result property="thirdIdConfirmFlag"    column="thirdIdConfirmFlag"/>
        <result property="delFlag"    column="delFlag"/>
    </resultMap>

    <select id="selectProductList" parameterType="MercProdRequest" resultMap="MercProdResponse">
        SELECT mmp.mercProdId,mmp.mercId,mp.prodClassId,mmp.prodId,mp.prodName,mp.idId,mp.designerId,mp.description,mp.prodStatus,mmp.delFlag
        FROM m_merchant_prod mmp
        LEFT JOIN m_prod mp ON mmp.prodId = mp.id
        <where>
            mmp.shelfFlag = '1'
            AND mmp.delFlag = '0'
            <if test="mercProdId != null ">AND mmp.mercProdId = #{mercProdId}</if>
            <if test="mercId != null ">AND mmp.mercId = #{mercId}</if>
            <if test="prodId != null ">AND mmp.prodId = #{prodId}</if>
            <if test="prodAttrId != null">AND mmp.prodAttrId = #{prodAttrId} </if>
            <if test="prodClassId != null">AND mp.prodClassId = #{prodClassId} </if>
            <if test="ipId != null">AND mp.ipId = #{ipId} </if>
            <if test="prodName != null and prodName != ''">AND mp.prodName like concat('%',#{prodName},'%')</if>
        </where>
    </select>
</mapper>
