<?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.api.dao.ApiPinganResponseMapper">

    <resultMap type="com.kmall.common.utils.pingan.dto.PinganResponseDto" id="pinganResponseMap">
        <result property="id" column="id"/>
        <result property="outNo" column="out_no"/>
        <result property="reqInterface" column="req_interface"/>
        <result property="errcode" column="errcode"/>
        <result property="msg" column="msg"/>
        <result property="data" column="data"/>
        <result property="sign" column="sign"/>
        <result property="datajson" column="datajson"/>
		<result property="timestamp" column="timestamp"/>
        <result property="createTime" column="create_time"/>
        <result property="tstm" column="tstm"/>
    </resultMap>

	<select id="queryObject" resultType="com.kmall.common.utils.pingan.dto.PinganResponseDto">
		select
			`id`,
			`out_no`,
			`req_interface`,
			`errcode`,
			`msg`,
			`data`,
			`sign`,
			`datajson`,
			`timestamp`,
			`create_time`,
			`tstm`
		from pingan_response
		where id = #{id}
	</select>

	<select id="queryList" resultType="com.kmall.common.utils.pingan.dto.PinganResponseDto">
		select
    		`id`,
    		`out_no`,
    		`req_interface`,
    		`errcode`,
    		`msg`,
    		`data`,
    		`sign`,
    		`datajson`,
			`timestamp`,
    		`create_time`,
    		`tstm`
		from pingan_response
		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 pingan_response
		WHERE 1=1
        <if test="name != null and name.trim() != ''">
            AND name LIKE concat('%',#{name},'%')
        </if>
	</select>
	 
	<insert id="save" parameterType="com.kmall.common.utils.pingan.dto.PinganResponseDto">
		insert into pingan_response(
			`id`,
			`out_no`,
			`req_interface`,
			`errcode`,
			`msg`,
			`data`,
			`sign`,
			`datajson`,
			`timestamp`,
			`create_time`,
			`tstm`)
		values(
			#{id},
			#{outNo},
			#{reqInterface},
			#{errcode},
			#{msg},
			#{data},
			#{sign},
			#{datajson},
			#{timestamp},
			#{createTime},
			#{tstm})
	</insert>
	 
	<update id="update" parameterType="com.kmall.common.utils.pingan.dto.PinganResponseDto">
		update pingan_response 
		<set>
			<if test="outNo != null">`out_no` = #{outNo}, </if>
			<if test="reqInterface != null">`req_interface` = #{reqInterface}, </if>
			<if test="errcode != null">`errcode` = #{errcode}, </if>
			<if test="msg != null">`msg` = #{msg}, </if>
			<if test="data != null">`data` = #{data}, </if>
			<if test="sign != null">`sign` = #{sign}, </if>
			<if test="datajson != null">`datajson` = #{datajson}, </if>
			<if test="timestamp != null">`timestamp` = #{timestamp}, </if>
			<if test="createTime != null">`create_time` = #{createTime}, </if>
			<if test="tstm != null">`tstm` = #{tstm}</if>
		</set>
		where id = #{id}
	</update>
	
	<delete id="delete">
		delete from pingan_response where id = #{value}
	</delete>
	
	<delete id="deleteBatch">
		delete from pingan_response where id in 
		<foreach item="id" collection="array" open="(" separator="," close=")">
			#{id}
		</foreach>
	</delete>

</mapper>