<?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.FaceLivenessRecognitionReturnDataDao">

    <resultMap type="com.kmall.admin.entity.FaceLivenessRecognitionReturnDataEntity" id="faceLivenessRecognitionReturnDataMap">
        <result property="id" column="id"/>
        <result property="merchOrderSn" column="merch_order_sn"/>
        <result property="isTempNoti" column="is_temp_noti"/>
        <result property="isFaceCheck" column="is_face_check"/>
        <result property="userId" column="user_id"/>
        <result property="tempNotiMsg" column="temp_noti_msg"/>
		<result property="recognitionReturnMsg" column="recognition_return_msg"/>
		<result property="failCount" column="fail_count"/>
		<result property="checkOperatorType" column="check_operator_type"/>
		<result property="checkOperatorSn" column="check_operator_sn"/>
		<result property="checkOperatorTime" column="check_operator_time"/>
        <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.FaceLivenessRecognitionReturnDataEntity">
		select
			`id`,
			`merch_order_sn`,
			`order_sn`,
			`is_temp_noti`,
			`is_face_check`,
			`user_id`,
			`temp_noti_msg`,
			recognition_return_msg,
			fail_count,
			check_operator_type,
			check_operator_sn,
			check_operator_time,
			`creater_sn`,
			`create_time`,
			`moder_sn`,
			`mod_time`,
			`tstm`
		from face_liveness_recognition_return_data
		where id = #{id}
	</select>

	<select id="queryList" resultType="com.kmall.admin.entity.FaceLivenessRecognitionReturnDataEntity">
		select
    		`id`,
    		`merch_order_sn`,
			`order_sn`,
    		`is_temp_noti`,
    		`is_face_check`,
    		`user_id`,
    		`temp_noti_msg`,
			recognition_return_msg,
			fail_count,
			check_operator_type,
			check_operator_sn,
			check_operator_time,
    		`creater_sn`,
    		`create_time`,
    		`moder_sn`,
    		`mod_time`,
    		`tstm`
		from face_liveness_recognition_return_data
		WHERE 1=1
		<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 id desc
			</otherwise>
        </choose>
		<if test="offset != null and limit != null">
			limit #{offset}, #{limit}
		</if>
	</select>

 	<select id="queryTotal" resultType="int">
		select count(*) from face_liveness_recognition_return_data
		WHERE 1=1
        <if test="name != null and name.trim() != ''">
            AND name LIKE concat('%',#{name},'%')
        </if>
	</select>

	<insert id="save" parameterType="com.kmall.admin.entity.FaceLivenessRecognitionReturnDataEntity" useGeneratedKeys="true" keyProperty="id">
		insert into face_liveness_recognition_return_data(
			`merch_order_sn`,
			`order_sn`,
			`is_temp_noti`,
			`is_face_check`,
			`user_id`,
			`temp_noti_msg`,
			recognition_return_msg,
			fail_count,
			check_operator_type,
			check_operator_sn,
			check_operator_time,
			`creater_sn`,
			`create_time`,
			`moder_sn`,
			`mod_time`,
			`tstm`)
		values(
			#{merchOrderSn},
			#{orderSn},
			#{isTempNoti},
			#{isFaceCheck},
			#{userId},
			#{tempNotiMsg},
			#{recognitionReturnMsg},
			#{failCount},
			#{checkOperatorType},
			#{checkOperatorSn},
			#{checkOperatorTime},
			#{createrSn},
			#{createTime},
			#{moderSn},
			#{modTime},
			#{tstm})
	</insert>

	<update id="update" parameterType="com.kmall.admin.entity.FaceLivenessRecognitionReturnDataEntity">
		update face_liveness_recognition_return_data
		<set>
			<if test="merchOrderSn != null">`merch_order_sn` = #{merchOrderSn}, </if>
			<if test="orderSn != null">`order_sn` = #{orderSn}, </if>
			<if test="isTempNoti != null">`is_temp_noti` = #{isTempNoti}, </if>
			<if test="isFaceCheck != null">`is_face_check` = #{isFaceCheck}, </if>
			<if test="userId != null">`user_id` = #{userId}, </if>
			<if test="tempNotiMsg != null">`temp_noti_msg` = #{tempNotiMsg}, </if>
			<if test="recognitionReturnMsg != null">`recognition_return_msg` = #{recognitionReturnMsg}, </if>
			<if test="failCount != null">`fail_count` = #{failCount}, </if>
			<if test="checkOperatorType != null">`check_operator_type` = #{checkOperatorType}, </if>
			<if test="checkOperatorSn != null">`check_operator_sn` = #{checkOperatorSn}, </if>
			<if test="checkOperatorTime != null">`check_operator_time` = #{checkOperatorTime}, </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 face_liveness_recognition_return_data where id = #{value}
	</delete>

	<delete id="deleteBatch">
		delete from face_liveness_recognition_return_data where id in
		<foreach item="id" collection="array" open="(" separator="," close=")">
			#{id}
		</foreach>
	</delete>

	<update id="updateByMerchOrderSn" parameterType="com.kmall.admin.entity.FaceLivenessRecognitionReturnDataEntity">
		update face_liveness_recognition_return_data
		<set>
			<if test="isTempNoti != null">`is_temp_noti` = #{isTempNoti}, </if>
			<if test="isFaceCheck != null">`is_face_check` = #{isFaceCheck}, </if>
			<if test="userId != null">`user_id` = #{userId}, </if>
			<if test="recognitionReturnMsg != null">`recognition_return_msg` = #{recognitionReturnMsg}, </if>
			<if test="failCount != null">`fail_count` = #{failCount}, </if>
			<if test="checkOperatorType != null">`check_operator_type` = #{checkOperatorType}, </if>
		</set>
		where order_sn = #{orderSn}
	</update>

	<update id="updateOrderByTempNoti" parameterType="map">
		update face_liveness_recognition_return_data
		<set>
			<if test="isTempNoti != null and isTempNoti != ''">
				is_temp_noti = #{isTempNoti},
			</if>
			<if test="tempNotiMsg != null and tempNotiMsg != ''">
				temp_noti_msg = #{tempNotiMsg}
			</if>
		</set>
		where order_sn = #{orderSn}
	</update>

	<select id="getFaceByOrderSn" resultType="com.kmall.admin.entity.FaceLivenessRecognitionReturnDataEntity">
		select
			`id`,
			`merch_order_sn`,
			`order_sn`,
			`is_temp_noti`,
			`is_face_check`,
			`user_id`,
			`temp_noti_msg`,
			recognition_return_msg,
			fail_count,
			check_operator_type,
			check_operator_sn,
			check_operator_time,
			`creater_sn`,
			`create_time`,
			`moder_sn`,
			`mod_time`,
			`tstm`
		from face_liveness_recognition_return_data
		where order_sn = #{orderSn}
	</select>
</mapper>
