<?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.zm.order.tool.server.hintnew.NewHintOrderItemBatchingDao">
    <resultMap id="ResultMap" type="com.zm.order.tool.server.model.OrderItemBatching">
		<id column="id" jdbcType="BIGINT" property="id"/>
		<result column="seller_id" jdbcType="BIGINT" property="sellerId"/>
		<result column="store_id" jdbcType="BIGINT" property="storeId"/>
		<result column="user_id" jdbcType="BIGINT" property="userId"/>
		<result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
		<result column="batching_id" jdbcType="VARCHAR" property="batchingId"/>
		<result column="batching_name" jdbcType="VARCHAR" property="batchingName"/>
		<result column="code" jdbcType="VARCHAR" property="code"/>
		<result column="num" jdbcType="INTEGER" property="num"/>
		<result column="price" jdbcType="DECIMAL" property="price"/>
		<result column="order_item_id" jdbcType="BIGINT" property="orderItemId"/>
		<result column="created_at" jdbcType="TIMESTAMP" property="createdAt"/>
		<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt"/>
		<result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
		<result column="features" jdbcType="VARCHAR" property="features"/>
	</resultMap>

	<sql id="tb">
        order_item_batching
    </sql>

    <sql id="cols_all">
        id,
		seller_id,
		store_id,
		user_id,
		order_no,
		batching_id,
		batching_name,
		code,
		num,
		price,
		order_item_id,
		created_at,
		updated_at,
		is_deleted,
		features
    </sql>

    <sql id="values">
    	#{id,jdbcType=BIGINT},
		#{sellerId,jdbcType=BIGINT},
		#{storeId,jdbcType=BIGINT},
		#{userId,jdbcType=BIGINT},
		#{orderNo,jdbcType=VARCHAR},
		#{batchingId,jdbcType=VARCHAR},
		#{batchingName,jdbcType=VARCHAR},
		#{code,jdbcType=VARCHAR},
		#{num,jdbcType=INTEGER},
		#{price,jdbcType=DECIMAL},
		#{orderItemId,jdbcType=BIGINT},
		#{createdAt,jdbcType=TIMESTAMP},
		#{updatedAt,jdbcType=TIMESTAMP},
		#{isDeleted,jdbcType=INTEGER},
		#{features,jdbcType=LONGVARCHAR}
    </sql>

	<update id="update" parameterType="map">
		update
		<include refid="tb"/>
		<set>
			seller_id = #{sellerId},
			store_id = #{storeId},
			user_id = #{userId},
			order_no = #{orderNo},
			batching_id = #{batchingId},
			batching_name = #{batchingName},
			code = #{code},
			num = #{num},
			price = #{price},
			order_item_id = #{orderItemId},
			created_at = #{createdAt},
			updated_at = #{updatedAt},
			is_deleted = #{isDeleted},
			features = #{features}
		</set>
		where id = #{id}
	</update>

    <insert id="insert" parameterType="com.zm.order.tool.server.model.OrderItemBatching"
                        keyColumn="id" keyProperty="id" useGeneratedKeys="true">
        insert into
        <include refid="tb"/>
        (<include refid="cols_all"/>)
        values
        (<include refid="values"/>)
    </insert>

	<select id="count" parameterType="map" resultType="int">
		select
		count(1)
		from
		<include refid="tb"/>
	</select>

	<insert id="replaceList" parameterType="list">
		replace into
		<include refid="tb"/>
		(<include refid="cols_all"/>)
		values
		<foreach collection="list" item="batching" index="index" separator=",">
			(
			#{batching.id,jdbcType=BIGINT},
			#{batching.sellerId,jdbcType=BIGINT},
			#{batching.storeId,jdbcType=BIGINT},
			#{batching.userId,jdbcType=BIGINT},
			#{batching.orderNo,jdbcType=VARCHAR},
			#{batching.batchingId,jdbcType=VARCHAR},
			#{batching.batchingName,jdbcType=VARCHAR},
			#{batching.code,jdbcType=VARCHAR},
			#{batching.num,jdbcType=INTEGER},
			#{batching.price,jdbcType=DECIMAL},
			#{batching.orderItemId,jdbcType=BIGINT},
			#{batching.createdAt},
			#{batching.updatedAt},
			#{batching.isDeleted},
			#{batching.features,jdbcType=LONGVARCHAR}
			)
		</foreach>
	</insert>

	<select id="selectListById" parameterType="map" resultMap="ResultMap">
		select
		<include refid="cols_all"/>
		from
		<include refid="tb"/>
		<where>
			id in
			<foreach collection="list" item="param" index="index" open="(" close=")" separator=",">
				#{param}
			</foreach>
		</where>
	</select>
</mapper>