<?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.xxfc.platform.tour.mapper.TourGoodTagMapper">

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.xxfc.platform.tour.entity.TourGoodTag" id="tourGoodTagMap">
        <result property="id" column="id"/>
        <result property="goodId" column="good_id"/>
        <result property="tagId" column="tag_id"/>
        <result property="crtTime" column="crt_time"/>
        <result property="updTime" column="upd_time"/>
        <result property="isDel" column="is_del"/>
    </resultMap>

    <resultMap type="com.xxfc.platform.tour.dto.GoodTagDTO" id="GoodTagDTOMap">
        <result property="id" column="id"/>
        <result property="tagId" column="tag_id"/>
        <result property="name" column="name"/>
    </resultMap>

    <select id="getGoodTagList"  resultMap="GoodTagDTOMap">
       select tag.id,tag.tag_id,t.`name` FROM tour_good g
        LEFT JOIN tour_good_tag tag ON g.id=tag.good_id
         LEFT JOIN tour_tag t ON tag.tag_id=t.id
        WHERE g.id=#{goodId} and tag.is_del=0
  </select>

    <update id="delTag">
        update  tour_good_tag set  is_del=1
        where 1=1
        <if test="goodId !=null and  goodId >0 ">
            and good_id=#{goodId}

        </if>
        <if test="list!=null ">
            and id not in (
            <trim suffixOverrides=",">
                <foreach collection="list" item="id">
                    #{id},
                </foreach>
            </trim>
            )
        </if>
    </update>

</mapper>