<?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.IncomeSrmMapper">
    <resultMap id="BaseResultMap" type="com.jianshui.income.domain.entity.IncomeSrm">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="companyid" jdbcType="INTEGER" property="companyid"/>
        <result column="pch" jdbcType="VARCHAR" property="pch"/>
        <result column="request" jdbcType="VARCHAR" property="request"/>
        <result column="response" jdbcType="VARCHAR" property="response"/>
        <result column="status" jdbcType="TINYINT" property="status"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
    </resultMap>
    <sql id="Base_Column_List">
        id
        , companyid,pch, request, response, `status`, create_time, update_time
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from income_srm
        where id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete
        from income_srm
        where id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.jianshui.income.domain.entity.IncomeSrm"
            useGeneratedKeys="true">
        insert into income_srm (companyid, pch, request, response,
                                `status`, create_time, update_time)
        values (#{companyid,jdbcType=INTEGER}, #{pch,jdbcType=VARCHAR}, #{request,jdbcType=VARCHAR},
                #{response,jdbcType=VARCHAR},
                #{status,jdbcType=TINYINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id"
            parameterType="com.jianshui.income.domain.entity.IncomeSrm" useGeneratedKeys="true">
        insert into income_srm
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="companyid != null">
                companyid,
            </if>
            <if test="pch != null">
                pch,
            </if>
            <if test="request != null">
                request,
            </if>
            <if test="response != null">
                response,
            </if>
            <if test="status != null">
                `status`,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="updateTime != null">
                update_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="request != null">
                #{request,jdbcType=VARCHAR},
            </if>
            <if test="response != null">
                #{response,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                #{status,jdbcType=TINYINT},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.jianshui.income.domain.entity.IncomeSrm">
        update income_srm
        <set>
            <if test="companyid != null">
                companyid = #{companyid,jdbcType=INTEGER},
            </if>
            <if test="pch != null">
                pch = #{pch,jdbcType=VARCHAR},
            </if>
            <if test="request != null">
                request = #{request,jdbcType=VARCHAR},
            </if>
            <if test="response != null">
                response = #{response,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                `status` = #{status,jdbcType=TINYINT},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.jianshui.income.domain.entity.IncomeSrm">
        update income_srm
        set companyid   = #{companyid,jdbcType=INTEGER},
            pch     = #{pch,jdbcType=VARCHAR},
            request     = #{request,jdbcType=VARCHAR},
            response    = #{response,jdbcType=VARCHAR},
            `status`    = #{status,jdbcType=TINYINT},
            create_time = #{createTime,jdbcType=TIMESTAMP},
            update_time = #{updateTime,jdbcType=TIMESTAMP}
        where id = #{id,jdbcType=BIGINT}
    </update>

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