<?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.ProdTagVoMapper">
    <resultMap type="ProdTagVo" id="ProdTagResult">
        <result property="prodId"               column="prodId"             />
        <result property="tagId"                column="tagId"              />
        <result property="tagName"              column="tagName"            />
    </resultMap>

    <sql id="selectProdTagVo">
        select m_prod_tag.id
             , m_prod_tag.prodId
             , m_prod_tag.tagId
             , m_tag.tagName
        from m_prod
        inner join m_prod_tag on m_prod.id = m_prod_tag.prodId
        inner join m_tag on m_tag.tagId = m_prod_tag.tagId
    </sql>

    <select id="selectProdTagVoList" parameterType="ProdTagVo" resultMap="ProdTagResult">
        <include refid="selectProdTagVo"/>
        <where>
            <if test="prodId != null "> and m_prod_tag.prodId = #{prodId}</if>
            <if test="tagId != null "> and m_prod_tag.tagId = #{tagId}</if>
            <if test="delFlag != null  and delFlag != ''"> and m_prod_tag.delFlag = #{delFlag}</if>
        </where>
    </select>

    <update id="logicDeleteProdTagByCondition" parameterType="ProdTag">
        update m_prod_tag
        <trim prefix="SET" suffixOverrides=",">
            delFlag = '1',
            <if test="updateUser != null">updateUser = #{updateUser},</if>
            <if test="updateTime != null">updateTime = #{updateTime},</if>
        </trim>
        <where>
            <if test="prodId != null "> and prodId = #{prodId}</if>
            <if test="id != null "> and id = #{id}</if>
            <if test="tagId != null "> and tagId = #{tagId}</if>
        </where>
    </update>
</mapper>