<?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.kmall.admin.dao.ExportExceptionDataDao">

    <resultMap type="com.kmall.admin.entity.ExportExceptionDataEntity" id="exportExceptionDataMap">
        <result property="id" column="id"/>
        <result property="exportExceptionData" column="export_exception_data"/>
        <result property="exportDataType" column="export_data_type"/>
        <result property="userId" column="user_id"/>
		<result property="merchSn" column="merch_sn"/>
		<result property="storeId" column="store_id"/>
        <result property="createrSn" column="creater_sn"/>
        <result property="createTime" column="create_time"/>
        <result property="moderSn" column="moder_sn"/>
        <result property="modTime" column="mod_time"/>
        <result property="tstm" column="tstm"/>
    </resultMap>

	<select id="queryObject" resultType="com.kmall.admin.entity.ExportExceptionDataEntity">
		select
			`id`,
			`export_exception_data`,
			`export_data_type`,
			`user_id`,
			`merch_sn`,
			`store_id`,
			`creater_sn`,
			`create_time`,
			`moder_sn`,
			`mod_time`,
			`tstm`
		from mall_export_exception_data
		where id = #{id}
	</select>

	<select id="queryList" resultType="com.kmall.admin.entity.ExportExceptionDataEntity">
		select
    		`id`,
    		`export_exception_data`,
    		`export_data_type`,
    		`user_id`,
			`merch_sn`,
			`store_id`,
    		`creater_sn`,
    		`create_time`,
    		`moder_sn`,
    		`mod_time`,
    		`tstm`
		from mall_export_exception_data
		WHERE 1=1
		<if test="storeId != null and storeId != '' ">
			AND store_id = #{storeId}
		</if>
		<if test="merchSn != null and merchSn.trim() != '' ">
			AND merch_sn = #{merchSn}
		</if>
		<if test="name != null and name.trim() != ''">
			AND name LIKE concat('%',#{name},'%')
		</if>
        <choose>
            <when test="sidx != null and sidx.trim() != ''">
                order by ${sidx} ${order}
            </when>
			<otherwise>
                order by create_time desc
			</otherwise>
        </choose>
		<if test="offset != null and limit != null">
			limit #{offset}, #{limit}
		</if>
	</select>
	
 	<select id="queryTotal" resultType="int">
		select count(*) from mall_export_exception_data
		WHERE 1=1
        <if test="name != null and name.trim() != ''">
            AND name LIKE concat('%',#{name},'%')
        </if>
		<if test="storeId != null and storeId != '' ">
			AND store_id = #{storeId}
		</if>
		<if test="merchSn != null and merchSn.trim() != '' ">
			AND merch_sn = #{merchSn}
		</if>
	</select>
	 
	<insert id="save" parameterType="com.kmall.admin.entity.ExportExceptionDataEntity" useGeneratedKeys="true" keyProperty="id">
		insert into mall_export_exception_data(
			`export_exception_data`,
			`export_data_type`,
			`user_id`,
			`merch_sn`,
			`store_id`,
			`creater_sn`,
			`create_time`,
			`moder_sn`,
			`mod_time`,
			`tstm`)
		values(
			#{exportExceptionData},
			#{exportDataType},
			#{userId},
			#{merchSn},
			#{storeId},
			#{createrSn},
			#{createTime},
			#{moderSn},
			#{modTime},
			#{tstm})
	</insert>
	 
	<update id="update" parameterType="com.kmall.admin.entity.ExportExceptionDataEntity">
		update mall_export_exception_data 
		<set>
			<if test="exportExceptionData != null">`export_exception_data` = #{exportExceptionData}, </if>
			<if test="exportDataType != null">`export_data_type` = #{exportDataType}, </if>
			<if test="userId != null">`user_id` = #{userId}, </if>
			<if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
			<if test="storeId != null">`store_id` = #{storeId}, </if>
			<if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
			<if test="createTime != null">`create_time` = #{createTime}, </if>
			<if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
			<if test="modTime != null">`mod_time` = #{modTime}, </if>
			<if test="tstm != null">`tstm` = #{tstm}</if>
		</set>
		where id = #{id}
	</update>
	
	<delete id="delete">
		delete from mall_export_exception_data where id = #{value}
	</delete>
	
	<delete id="deleteBatch">
		delete from mall_export_exception_data where id in 
		<foreach item="id" collection="array" open="(" separator="," close=")">
			#{id}
		</foreach>
	</delete>

</mapper>