<?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.campsite.mapper.CampsiteShopCarouselMapper">

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.xxfc.platform.campsite.entity.CampsiteShopCarousel" id="campsiteShopCarouselMap">
        <result property="id" column="id"/>
        <result property="shopId" column="shop_id"/>
        <result property="url" column="url"/>
        <result property="imgUrl" column="img_url"/>
        <result property="name" column="name"/>
        <result property="isDel" column="is_del"/>
    </resultMap>

    <!--根据营地id查询全部-->
    <select id="findAllCarousesByShopId" resultType="com.xxfc.platform.campsite.dto.CampsiteShopCarouselDetailDTO">
        select `id` as `id`,`img_url`as `imgUrl`,`url`as `url` from `campsite_shop_carousel` where shop_id=#{shopId} and `is_del`=0;
    </select>

    <!--更新轮播图状态-->
    <update id="updateCarouseStatusByIdsAndShopId">
        update `campsite_shop_carousel` set `is_del`=#{status} where `shop_id`=#{shopId}
        <if test="ids != null and ids.size() != 0">
            and `id` not in <foreach collection="ids" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
        </if>
    </update>

    <!--批量保存-->
    <insert id="saveBatch" >
        insert into `campsite_shop_carousel` (`shop_id`,`img_url`)values
        <foreach collection="sc" item="s" separator=",">
            (#{s.shopId} ,#{s.imgUrl} )
        </foreach>;
    </insert>
</mapper>