<?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.cyksj.mapper.GoodsDonCategoryRelateMapper">

    <insert id="saveBatchGoodsRelate">
        insert
        ignore into goods_don_category_relate(`goods_id`,`category`,`created_time`,`update_time`)
        values
        <foreach collection="list" item="item" separator=",">
            (#{goodsId},#{item},now(),now())
        </foreach>
    </insert>


    <select id="getCateGoryViewByGoodsId" resultType="com.cyksj.model.entity.GoodsDonCategory">
        select gc.* from goods_don_category gc left join goods_don_category_relate gcr on gcr.category = gc.id
        where gcr.goods_id = #{goodsId}
    </select>
</mapper>