<?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.IncomeInvoiceAuthDetailMapper">
    
    <resultMap type="IncomeInvoiceAuthDetail" id="IncomeInvoiceAuthDetailResult">
        <result property="id"    column="id"    />
        <result property="invoiceId"    column="invoice_id"    />
        <result property="xh"    column="xh"    />
        <result property="spmc"    column="spmc"    />
        <result property="spbm"    column="spbm"    />
        <result property="spbmjc"    column="spbmjc"    />
        <result property="cph"    column="cph"    />
        <result property="lx"    column="lx"    />
        <result property="txsjq"    column="txsjq"    />
        <result property="txsjz"    column="txsjz"    />
        <result property="je"    column="je"    />
        <result property="sl"    column="sl"    />
        <result property="se"    column="se"    />
        <result property="ggxh"    column="ggxh"    />
        <result property="dw"    column="dw"    />
        <result property="spsl"    column="spsl"    />
        <result property="dj"    column="dj"    />
    </resultMap>

    <sql id="selectIncomeInvoiceAuthDetailVo">
        select id, invoice_id, xh, spmc, spbm, spbmjc, cph, lx, txsjq, txsjz, je, sl, se, ggxh, dw, spsl, dj from income_invoice_auth_detail
    </sql>

    <select id="selectIncomeInvoiceAuthDetailList" parameterType="IncomeInvoiceAuthDetail" resultMap="IncomeInvoiceAuthDetailResult">
        <include refid="selectIncomeInvoiceAuthDetailVo"/>
        <where>  
            <if test="invoiceId != null  and invoiceId != ''"> and invoice_id = #{invoiceId}</if>
            <if test="xh != null  and xh != ''"> and xh = #{xh}</if>
            <if test="spmc != null  and spmc != ''"> and spmc = #{spmc}</if>
            <if test="spbm != null  and spbm != ''"> and spbm = #{spbm}</if>
            <if test="spbmjc != null  and spbmjc != ''"> and spbmjc = #{spbmjc}</if>
            <if test="cph != null  and cph != ''"> and cph = #{cph}</if>
            <if test="lx != null  and lx != ''"> and lx = #{lx}</if>
            <if test="txsjq != null  and txsjq != ''"> and txsjq = #{txsjq}</if>
            <if test="txsjz != null  and txsjz != ''"> and txsjz = #{txsjz}</if>
            <if test="je != null  and je != ''"> and je = #{je}</if>
            <if test="sl != null  and sl != ''"> and sl = #{sl}</if>
            <if test="se != null  and se != ''"> and se = #{se}</if>
            <if test="ggxh != null  and ggxh != ''"> and ggxh = #{ggxh}</if>
            <if test="dw != null  and dw != ''"> and dw = #{dw}</if>
            <if test="spsl != null  and spsl != ''"> and spsl = #{spsl}</if>
            <if test="dj != null  and dj != ''"> and dj = #{dj}</if>
        </where>
    </select>
    
    <select id="selectIncomeInvoiceAuthDetailById" parameterType="String" resultMap="IncomeInvoiceAuthDetailResult">
        <include refid="selectIncomeInvoiceAuthDetailVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertIncomeInvoiceAuthDetail" parameterType="IncomeInvoiceAuthDetail">
        insert into income_invoice_auth_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="invoiceId != null and invoiceId != ''">invoice_id,</if>
            <if test="xh != null">xh,</if>
            <if test="spmc != null">spmc,</if>
            <if test="spbm != null">spbm,</if>
            <if test="spbmjc != null">spbmjc,</if>
            <if test="cph != null">cph,</if>
            <if test="lx != null">lx,</if>
            <if test="txsjq != null">txsjq,</if>
            <if test="txsjz != null">txsjz,</if>
            <if test="je != null">je,</if>
            <if test="sl != null">sl,</if>
            <if test="se != null">se,</if>
            <if test="ggxh != null">ggxh,</if>
            <if test="dw != null">dw,</if>
            <if test="spsl != null">spsl,</if>
            <if test="dj != null">dj,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="invoiceId != null and invoiceId != ''">#{invoiceId},</if>
            <if test="xh != null">#{xh},</if>
            <if test="spmc != null">#{spmc},</if>
            <if test="spbm != null">#{spbm},</if>
            <if test="spbmjc != null">#{spbmjc},</if>
            <if test="cph != null">#{cph},</if>
            <if test="lx != null">#{lx},</if>
            <if test="txsjq != null">#{txsjq},</if>
            <if test="txsjz != null">#{txsjz},</if>
            <if test="je != null">#{je},</if>
            <if test="sl != null">#{sl},</if>
            <if test="se != null">#{se},</if>
            <if test="ggxh != null">#{ggxh},</if>
            <if test="dw != null">#{dw},</if>
            <if test="spsl != null">#{spsl},</if>
            <if test="dj != null">#{dj},</if>
         </trim>
    </insert>

    <update id="updateIncomeInvoiceAuthDetail" parameterType="IncomeInvoiceAuthDetail">
        update income_invoice_auth_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="invoiceId != null and invoiceId != ''">invoice_id = #{invoiceId},</if>
            <if test="xh != null">xh = #{xh},</if>
            <if test="spmc != null">spmc = #{spmc},</if>
            <if test="spbm != null">spbm = #{spbm},</if>
            <if test="spbmjc != null">spbmjc = #{spbmjc},</if>
            <if test="cph != null">cph = #{cph},</if>
            <if test="lx != null">lx = #{lx},</if>
            <if test="txsjq != null">txsjq = #{txsjq},</if>
            <if test="txsjz != null">txsjz = #{txsjz},</if>
            <if test="je != null">je = #{je},</if>
            <if test="sl != null">sl = #{sl},</if>
            <if test="se != null">se = #{se},</if>
            <if test="ggxh != null">ggxh = #{ggxh},</if>
            <if test="dw != null">dw = #{dw},</if>
            <if test="spsl != null">spsl = #{spsl},</if>
            <if test="dj != null">dj = #{dj},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteIncomeInvoiceAuthDetailById" parameterType="String">
        delete from income_invoice_auth_detail where id = #{id}
    </delete>

    <delete id="deleteIncomeInvoiceAuthDetailByIds" parameterType="String">
        delete from income_invoice_auth_detail where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>