<?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.reptileclient.jlifeapp.dao.jz.HmRightsItemMapper">
  <resultMap id="BaseResultMap" type="com.reptileclient.jlifeapp.entity.jz.HmRightsItem">
    <!--@mbg.generated-->
    <!--@Table hm_rights_item-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="shop_code" jdbcType="VARCHAR" property="shopCode" />
    <result column="item_id" jdbcType="BIGINT" property="itemId" />
    <result column="sku_code" jdbcType="VARCHAR" property="skuCode" />
    <result column="sku_name" jdbcType="VARCHAR" property="skuName" />
    <result column="supply_code" jdbcType="VARCHAR" property="supplyCode" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, shop_code, item_id, sku_code, sku_name, supply_code
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from hm_rights_item
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from hm_rights_item
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.reptileclient.jlifeapp.entity.jz.HmRightsItem" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into hm_rights_item (shop_code, item_id, sku_code, 
      sku_name, supply_code)
    values (#{shopCode,jdbcType=VARCHAR}, #{itemId,jdbcType=BIGINT}, #{skuCode,jdbcType=VARCHAR}, 
      #{skuName,jdbcType=VARCHAR}, #{supplyCode,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.reptileclient.jlifeapp.entity.jz.HmRightsItem" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into hm_rights_item
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="shopCode != null">
        shop_code,
      </if>
      <if test="itemId != null">
        item_id,
      </if>
      <if test="skuCode != null">
        sku_code,
      </if>
      <if test="skuName != null">
        sku_name,
      </if>
      <if test="supplyCode != null">
        supply_code,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="shopCode != null">
        #{shopCode,jdbcType=VARCHAR},
      </if>
      <if test="itemId != null">
        #{itemId,jdbcType=BIGINT},
      </if>
      <if test="skuCode != null">
        #{skuCode,jdbcType=VARCHAR},
      </if>
      <if test="skuName != null">
        #{skuName,jdbcType=VARCHAR},
      </if>
      <if test="supplyCode != null">
        #{supplyCode,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.reptileclient.jlifeapp.entity.jz.HmRightsItem">
    <!--@mbg.generated-->
    update hm_rights_item
    <set>
      <if test="shopCode != null">
        shop_code = #{shopCode,jdbcType=VARCHAR},
      </if>
      <if test="itemId != null">
        item_id = #{itemId,jdbcType=BIGINT},
      </if>
      <if test="skuCode != null">
        sku_code = #{skuCode,jdbcType=VARCHAR},
      </if>
      <if test="skuName != null">
        sku_name = #{skuName,jdbcType=VARCHAR},
      </if>
      <if test="supplyCode != null">
        supply_code = #{supplyCode,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.reptileclient.jlifeapp.entity.jz.HmRightsItem">
    <!--@mbg.generated-->
    update hm_rights_item
    set shop_code = #{shopCode,jdbcType=VARCHAR},
      item_id = #{itemId,jdbcType=BIGINT},
      sku_code = #{skuCode,jdbcType=VARCHAR},
      sku_name = #{skuName,jdbcType=VARCHAR},
      supply_code = #{supplyCode,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateBatch" parameterType="java.util.List">
    <!--@mbg.generated-->
    update hm_rights_item
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="shop_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.shopCode,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="item_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.itemId,jdbcType=BIGINT}
        </foreach>
      </trim>
      <trim prefix="sku_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.skuCode,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="sku_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.skuName,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="supply_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.supplyCode,jdbcType=VARCHAR}
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=BIGINT}
    </foreach>
  </update>
  <update id="updateBatchSelective" parameterType="java.util.List">
    <!--@mbg.generated-->
    update hm_rights_item
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="shop_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.shopCode != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.shopCode,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="item_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.itemId != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.itemId,jdbcType=BIGINT}
          </if>
        </foreach>
      </trim>
      <trim prefix="sku_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.skuCode != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.skuCode,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="sku_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.skuName != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.skuName,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="supply_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.supplyCode != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.supplyCode,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=BIGINT}
    </foreach>
  </update>
  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into hm_rights_item
    (shop_code, item_id, sku_code, sku_name, supply_code)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.shopCode,jdbcType=VARCHAR}, #{item.itemId,jdbcType=BIGINT}, #{item.skuCode,jdbcType=VARCHAR}, 
        #{item.skuName,jdbcType=VARCHAR}, #{item.supplyCode,jdbcType=VARCHAR})
    </foreach>
  </insert>
</mapper>