<?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.seer.teach.mall.mapper.GoodsMapper">

    <update id="updateDeleteBatchByIds">
        update mall_goods set deleted =#{deleteFlag},update_time=#{goods.updateTime},update_by = #{goods.updateBy}
        where
        <choose>
            <when test="ids != null and ids.size() > 0">
                id in
                <foreach collection="ids" item="id" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </when>
            <otherwise>1=2</otherwise>
        </choose>
    </update>

    <update id="batchUpdateSaleByIds" >
        update mall_goods set update_time=#{goods.updateTime},update_by = #{goods.updateBy}
            <if test="goods.isOnSale != null ">
                ,is_on_sale =#{goods.isOnSale}
            </if>
            <if test="goods.onSaleTime != null  ">
                ,on_sale_time =#{goods.onSaleTime}
            </if>
            <if test="goods.offSaleTime != null  ">
                ,off_sale_time =#{goods.offSaleTime}
            </if>
        where
            <choose>
                <when test="idList != null and idList.size() > 0">
                    id in
                    <foreach collection="idList" item="id" open="(" close=")" separator=",">
                        #{id}
                    </foreach>
                </when>
                <otherwise>1=2</otherwise>
            </choose>
    </update>

</mapper>
