<?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.TourTagBannerMapper">

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.xxfc.platform.tour.entity.TourTagBanner" id="tourTagBannerMap">
        <result property="id" column="id"/>
        <result property="title" column="title"/>
        <result property="cover" column="cover"/>
        <result property="crtName" column="crt_name"/>
        <result property="crtTime" column="crt_time"/>
        <result property="updName" column="upd_name"/>
        <result property="updTime" column="upd_time"/>
        <result property="url" column="url"/>
        <result property="isDel" column="is_del"/>
    </resultMap>

    <resultMap id="tourTagBannerDTOMap" type="com.xxfc.platform.tour.dto.TourTagBannerDTO">
        <result property="id" column="id"/>
        <result property="title" column="title"/>
        <result property="cover" column="cover"/>
        <result property="crtName" column="crt_name"/>
        <result property="crtTime" column="crt_time"/>
        <result property="updName" column="upd_name"/>
        <result property="updTime" column="upd_time"/>
        <result property="url" column="url"/>
        <result property="isDel" column="is_del"/>
    </resultMap>

    <delete id="updateTourBannerStatusByTagannerIdsAndTagId">
        update  tour_tag_banner set `is_del`=#{status} where tag_id=#{tagId} and id not in
        <foreach collection="tourTagBannerIds" item="id" index="index" open="(" close=")" separator=",">
            #{id}
        </foreach>
    </delete>

    <select id="findByTagIdsAndStatus" resultMap="tourTagBannerDTOMap">
        select * from `tour_tag_banner` where `is_del`=#{status} and `tag_id` in
        <foreach collection="tagIds" item="tagId" separator="," close=")" open="(">
            #{tagId}
        </foreach>
    </select>

    <insert id="insertBatch" keyProperty="id" keyColumn="id" useGeneratedKeys="true">
        insert into `tour_tag_banner`(`title`,`cover`,`crt_name`,`tag_id`,`crt_time`)values
        <foreach collection="tourTagBanners" item="tagbanner" separator=",">
            (#{tagbanner.title},#{tagbanner.cover},#{tagbanner.crtName},#{tagbanner.tagId} ,#{tagbanner.crtTime})
        </foreach>
    </insert>
</mapper>