<?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.web.controller.master.product.mapper.ProdVoMapper">
    <resultMap type="ProdVo" id="ProdResult">
        <result property="id"                   column="id"                 />
        <result property="prodClassId"          column="prodClassId"        />
        <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"            />
        <result property="createUser"           column="createUser"         />
        <result property="createTime"           column="createTime"         />
        <result property="updateUser"           column="updateUser"         />
        <result property="updateTime"           column="updateTime"         />
        <result property="prodClass"            column="className"          />
        <result property="ipName"               column="ipName"             />
        <result property="designerName"         column="designerName"       />
    </resultMap>

    <sql id="selectProdVo">
        select m_prod.id
             , m_prod.prodClassId
             , m_prod.prodName
             , m_prod.ipId
             , m_prod.designerId
             , m_prod.description
             , m_prod.prodStatus
             , m_prod.thirdIdConfirmFlag
             , m_prod_class.className
             , m_designer.designerName
             , m_ipinfo.ipName
        from m_prod
        inner join m_prod_class on m_prod.prodClassId = m_prod_class.prodClassId
        inner join m_designer on m_prod.designerId = m_designer.id
        inner join m_ipinfo on m_prod.ipId = m_ipinfo.ipId
    </sql>

    <select id="selectProdVoList" parameterType="ProdVo" resultMap="ProdResult">
        <include refid="selectProdVo"/>
        <where>
            <if test="prodClassId != null "> and m_prod.prodClassId = #{prodClassId}</if>
            <if test="prodName != null  and prodName != ''"> and m_prod.prodName like concat('%', #{prodName}, '%')</if>
            <if test="ipId != null "> and ipId = #{ipId}</if>
            <if test="designerId != null "> and m_prod.designerId = #{designerId}</if>
            <if test="description != null  and description != ''"> and m_prod.description = #{description}</if>
            <if test="prodStatus != null  and prodStatus != ''"> and m_prod.prodStatus = #{prodStatus}</if>
            <if test="thirdIdConfirmFlag != null  and thirdIdConfirmFlag != ''"> and m_prod.thirdIdConfirmFlag = #{thirdIdConfirmFlag}</if>
            <if test="delFlag != null  and delFlag != ''"> and m_prod.delFlag = #{delFlag}</if>
            <if test="prodClass != null  and prodClass != ''"> and m_prod_class.className like concat('%', #{prodClass}, '%')</if>
            <if test="designerName != null  and designerName != ''"> and m_designer.designerName like concat('%', #{designerName}, '%')</if>
            <if test="ipName != null  and ipName != ''"> and m_ipinfo.ipName like concat('%', #{ipName}, '%')</if>
        </where>
    </select>
    
    <select id="selectProdVoById" parameterType="Long" resultMap="ProdResult">
        <include refid="selectProdVo"/>
        where m_prod.id = #{id}
    </select>

    <select id="selectProdClassList" parameterType="String" resultType="ProdClass">
        select * from m_prod_class where delFlag = '0'
    </select>

    <select id="selectDesignerList" parameterType="String" resultType="Designer">
        select * from m_designer where delFlag = '0'
    </select>
</mapper>