<?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.order.mapper.PurchaseOrderItemLangMapper">
  <resultMap id="purchaseOrderItemLangMap" type="com.tmerclub.cloud.order.model.PurchaseOrderItemLang">
    <id column="purchase_item_id" property="purchaseItemId" />
    <result column="lang" property="lang"/>
    <result column="spu_name" property="spuName"/>
    <result column="sku_name" property="skuName"/>
  </resultMap>
  <sql id="Vo_Column_List">
    `purchase_item_id`,`lang`,`spu_name`,`sku_name`
  </sql>
  <select id="list" resultMap="purchaseOrderItemLangMap">
    select <include refid="Vo_Column_List"/> from purchase_order_item_lang order by purchase_item_id desc
  </select>
  <select id="getByPurchaseItemId" resultMap="purchaseOrderItemLangMap">
    select <include refid="Vo_Column_List"/> from purchase_order_item_lang where purchase_item_id = #{purchaseItemId}
  </select>
  <insert id="save">
    insert into purchase_order_item_lang (`lang`,`spu_name`,`sku_name`)
    values (#{purchaseOrderItemLang.lang},#{purchaseOrderItemLang.spuName},#{purchaseOrderItemLang.skuName});
  </insert>
  <insert id="saveBatch">
    insert into purchase_order_item_lang (`purchase_item_id`,`lang`,`spu_name`,`sku_name`) values
    <foreach collection="orderItemLangList" item="orderItemLang" separator=",">
     (#{orderItemLang.purchaseItemId},#{orderItemLang.lang},#{orderItemLang.spuName},#{orderItemLang.skuName})
    </foreach>
  </insert>
  <update id="update">
    update purchase_order_item_lang
    <set>
      <if test="purchaseOrderItemLang.lang != null">
        `lang` = #{purchaseOrderItemLang.lang},
      </if>
      <if test="purchaseOrderItemLang.spuName != null">
        `spu_name` = #{purchaseOrderItemLang.spuName},
      </if>
      <if test="purchaseOrderItemLang.skuName != null">
        `sku_name` = #{purchaseOrderItemLang.skuName},
      </if>
    </set>
    where purchase_item_id = #{purchaseOrderItemLang.purchaseItemId}
  </update>
  <delete id="deleteById">
    delete from purchase_order_item_lang where purchase_item_id = #{purchaseItemId}
  </delete>

</mapper>
