<?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.jianshui.income.mapper.IncomeCallbackMapper">
    <resultMap id="BaseResultMap" type="com.jianshui.income.domain.entity.IncomeCallback">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="companyid" jdbcType="INTEGER" property="companyid"/>
        <result column="pch" jdbcType="VARCHAR" property="pch"/>
        <result column="reback_url" jdbcType="VARCHAR" property="rebackUrl"/>
        <result column="status" jdbcType="INTEGER" property="status"/>
        <result column="times" jdbcType="INTEGER" property="times"/>
        <result column="raw_data" jdbcType="VARCHAR" property="rawData"/>
        <result column="result_data" jdbcType="VARCHAR" property="resultData"/>
        <result column="error_msg" jdbcType="VARCHAR" property="errorMsg"/>
        <result column="reback_consumer" jdbcType="VARCHAR" property="rebackConsumer"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
    </resultMap>
    <sql id="Base_Column_List">
        id
        , companyid, pch, reback_url, `status`, times, raw_data, result_data, error_msg,reback_consumer,
    create_time
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from income_callback
        where id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete
        from income_callback
        where id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.jianshui.income.domain.entity.IncomeCallback"
            useGeneratedKeys="true">
        insert into income_callback (companyid, pch, reback_url,
                                     `status`, times, raw_data,
                                     result_data, error_msg, reback_consumer, create_time)
        values (#{companyid,jdbcType=INTEGER}, #{pch,jdbcType=VARCHAR}, #{rebackUrl,jdbcType=VARCHAR},
                #{status,jdbcType=INTEGER}, #{times,jdbcType=INTEGER}, #{rawData,jdbcType=VARCHAR},
                #{resultData,jdbcType=VARCHAR}, #{errorMsg,jdbcType=VARCHAR}, #{rebackConsumer,jdbcType=VARCHAR},
                #{createTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id"
            parameterType="com.jianshui.income.domain.entity.IncomeCallback" useGeneratedKeys="true">
        insert into income_callback
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="companyid != null">
                companyid,
            </if>
            <if test="pch != null">
                pch,
            </if>
            <if test="rebackUrl != null">
                reback_url,
            </if>
            <if test="status != null">
                `status`,
            </if>
            <if test="times != null">
                times,
            </if>
            <if test="rawData != null">
                raw_data,
            </if>
            <if test="resultData != null">
                result_data,
            </if>
            <if test="errorMsg != null">
                error_msg,
            </if>
            <if test="rebackConsumer != null">
                reback_consumer,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="companyid != null">
                #{companyid,jdbcType=INTEGER},
            </if>
            <if test="pch != null">
                #{pch,jdbcType=VARCHAR},
            </if>
            <if test="rebackUrl != null">
                #{rebackUrl,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                #{status,jdbcType=INTEGER},
            </if>
            <if test="times != null">
                #{times,jdbcType=INTEGER},
            </if>
            <if test="rawData != null">
                #{rawData,jdbcType=VARCHAR},
            </if>
            <if test="resultData != null">
                #{resultData,jdbcType=VARCHAR},
            </if>
            <if test="errorMsg != null">
                #{errorMsg,jdbcType=VARCHAR},
            </if>
            <if test="rebackConsumer != null">
                #{rebackConsumer,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.jianshui.income.domain.entity.IncomeCallback">
        update income_callback
        <set>
            <if test="companyid != null">
                companyid = #{companyid,jdbcType=INTEGER},
            </if>
            <if test="pch != null">
                pch = #{pch,jdbcType=VARCHAR},
            </if>
            <if test="rebackUrl != null">
                reback_url = #{rebackUrl,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                `status` = #{status,jdbcType=INTEGER},
            </if>
            <if test="times != null">
                times = #{times,jdbcType=INTEGER},
            </if>
            <if test="rawData != null">
                raw_data = #{rawData,jdbcType=VARCHAR},
            </if>
            <if test="resultData != null">
                result_data = #{resultData,jdbcType=VARCHAR},
            </if>
            <if test="errorMsg != null">
                error_msg = #{errorMsg,jdbcType=VARCHAR},
            </if>
            <if test="rebackConsumer != null">
                reback_consumer = #{rebackConsumer,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.jianshui.income.domain.entity.IncomeCallback">
        update income_callback
        set companyid       = #{companyid,jdbcType=INTEGER},
            pch             = #{pch,jdbcType=VARCHAR},
            reback_url      = #{rebackUrl,jdbcType=VARCHAR},
            `status`        = #{status,jdbcType=INTEGER},
            times           = #{times,jdbcType=INTEGER},
            raw_data        = #{rawData,jdbcType=VARCHAR},
            result_data     = #{resultData,jdbcType=VARCHAR},
            error_msg       = #{errorMsg,jdbcType=VARCHAR},
            reback_consumer = #{rebackConsumer,jdbcType=VARCHAR},
            create_time     = #{createTime,jdbcType=TIMESTAMP}
        where id = #{id,jdbcType=BIGINT}
    </update>

    <select id="selectByPchAndCompanyId" parameterType="com.jianshui.income.domain.entity.IncomeCallback" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from income_callback
        where pch = #{pch,jdbcType=VARCHAR} and companyid = #{companyid,jdbcType=INTEGER}
        limit 1
    </select>
</mapper>