<?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.tmerclub.cloud.product.mapper.SpuDetailMapper">
  <resultMap id="spuDetailMap" type="com.tmerclub.cloud.product.model.SpuDetail">
    <id column="spu_id" property="spuId" />
    <result column="create_time" property="createTime"/>
    <result column="update_time" property="updateTime"/>
    <result column="detail" property="detail"/>
  </resultMap>
  <sql id="Vo_Column_List">
    `spu_id`,`create_time`,`update_time`,`detail`
  </sql>
  <update id="batchUpdate">
    <foreach collection="spuDetailList" item="spuDetail">
      update spu_detail set `detail` = #{spuDetail.detail}
      where spu_id = #{spuDetail.spuId} and lang = #{spuDetail.lang};
    </foreach>
  </update>
  <delete id="deleteById">
    delete from spu_detail where spu_id = #{spuId}
  </delete>

  <insert id="batchSave">
    <foreach collection="spuDetailList" item="spuDetail">
      insert into spu_detail (`spu_id`,`lang`,`detail`)
      values (#{spuDetail.spuId},#{spuDetail.lang},#{spuDetail.detail});
    </foreach>
  </insert>

  <delete id="deleteBatchBySpuIdAndLang">
    delete from spu_detail where spu_id = #{spuId} and lang in
    <foreach collection="langList" item="lang" open="(" close=")" separator=",">
      #{lang}
    </foreach>
  </delete>
</mapper>
