<?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.younike.system.mapper.MerchantCategoryMapper">
    <update id="removeMerchantCategoryByMerchantId" parameterType="Long">
        update merchant_category
        set del_flag = 1
        where merchant_id = #{merchantId}
    </update>

    <insert id="insertBatch" parameterType="MerchantCategory" >
        insert into merchant_category
        (merchant_id, category_id, create_by, create_time)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.merchantId}, #{item.categoryId}, #{item.createBy}, #{item.createTime})
        </foreach>
        ;
    </insert>

    <select id="merchantCategoryList" parameterType="Long" resultMap="MerchantCategoryResult">
        <include refid="selectMerchantCategoryVo"/>
        <where>
            merchant_id = #{merchantId} and del_flag = 0
        </where>
    </select>
</mapper>