<?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.ruixuan.live.mapper.KuaishouLiveCustomerInvoiceMapper">

    <resultMap type="com.ruixuan.live.entity.KuaishouLiveCustomerInvoice" id="KuaishouLiveCustomerInvoiceResult">
        <result property="id" column="id"/>
        <result property="ksId" column="ks_id"/>
        <result property="mainBodyName" column="main_body_name"/>
        <result property="type" column="type"/>
        <result property="permitUrl" column="permit_url"/>
        <result property="taxpayerUrl" column="taxpayer_url"/>
        <result property="bank" column="bank"/>
        <result property="bankCode" column="bank_code"/>
        <result property="taxpayerIdentificationNumber" column="taxpayer_identification_number"/>
        <result property="address" column="address"/>
        <result property="phone" column="phone"/>
        <result property="createrId" column="creater_id"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectKuaishouLiveCustomerInvoiceVo">
        select id,
               ks_id,
               main_body_name,
               `type`,
               permit_url,
               taxpayer_url,
               bank,
               bank_code,
               taxpayer_identification_number,
               address,
               phone,
               creater_id,
               create_time,
               update_time
        from kuaishou_live_customer_invoice
    </sql>

    <select id="selectKuaishouLiveCustomerInvoiceList"
            parameterType="com.ruixuan.live.entity.KuaishouLiveCustomerInvoice"
            resultMap="KuaishouLiveCustomerInvoiceResult">
        <include refid="selectKuaishouLiveCustomerInvoiceVo"/>
        <where>
            <if test="ksId != null ">and ks_id = #{ksId}</if>
            <if test="mainBodyName != null  and mainBodyName != ''">and main_body_name like concat('%', #{mainBodyName},
                '%')
            </if>
            <if test="permitUrl != null  and permitUrl != ''">and permit_url = #{permitUrl}</if>
            <if test="type != null  and type != ''">and `type` = #{type}</if>
            <if test="taxpayerUrl != null  and taxpayerUrl != ''">and taxpayer_url = #{taxpayerUrl}</if>
            <if test="bank != null  and bank != ''">and bank = #{bank}</if>
            <if test="bankCode != null  and bankCode != ''">and bank_code = #{bankCode}</if>
            <if test="taxpayerIdentificationNumber != null  and taxpayerIdentificationNumber != ''">and
                taxpayer_identification_number = #{taxpayerIdentificationNumber}
            </if>
            <if test="address != null  and address != ''">and address = #{address}</if>
            <if test="phone != null  and phone != ''">and phone = #{phone}</if>
            <if test="createrId != null  and createrId != ''">and creater_id = #{createrId}</if>
        </where>
    </select>

    <select id="getByKsIdAndName" resultMap="KuaishouLiveCustomerInvoiceResult">
        <include refid="selectKuaishouLiveCustomerInvoiceVo"/>
        where ks_id = #{ksId}
        and main_body_name = #{mainBodyName}
    </select>

    <insert id="insertKuaishouLiveCustomerInvoice" parameterType="com.ruixuan.live.entity.KuaishouLiveCustomerInvoice">
        insert into kuaishou_live_customer_invoice
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="ksId != null">ks_id,</if>
            <if test="mainBodyName != null">main_body_name,</if>
            <if test="type != null">`type`,</if>
            <if test="permitUrl != null">permit_url,</if>
            <if test="taxpayerUrl != null">taxpayer_url,</if>
            <if test="bank != null">bank,</if>
            <if test="bankCode != null">bank_code,</if>
            <if test="taxpayerIdentificationNumber != null">taxpayer_identification_number,</if>
            <if test="address != null">address,</if>
            <if test="phone != null">phone,</if>
            <if test="createrId != null">creater_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="ksId != null">#{ksId},</if>
            <if test="mainBodyName != null">#{mainBodyName},</if>
            <if test="type != null">#{type},</if>
            <if test="permitUrl != null">#{permitUrl},</if>
            <if test="taxpayerUrl != null">#{taxpayerUrl},</if>
            <if test="bank != null">#{bank},</if>
            <if test="bankCode != null">#{bankCode},</if>
            <if test="taxpayerIdentificationNumber != null">#{taxpayerIdentificationNumber},</if>
            <if test="address != null">#{address},</if>
            <if test="phone != null">#{phone},</if>
            <if test="createrId != null">#{createrId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
        </trim>
    </insert>

    <update id="updateKuaishouLiveCustomerInvoice" parameterType="com.ruixuan.live.entity.KuaishouLiveCustomerInvoice">
        update kuaishou_live_customer_invoice
        <trim prefix="SET" suffixOverrides=",">
            <if test="ksId != null">ks_id = #{ksId},</if>
            <if test="mainBodyName != null">main_body_name = #{mainBodyName},</if>
            <if test="type != null">`type` = #{type},</if>
            <if test="permitUrl != null">permit_url = #{permitUrl},</if>
            <if test="taxpayerUrl != null">taxpayer_url = #{taxpayerUrl},</if>
            <if test="bank != null">bank = #{bank},</if>
            <if test="bankCode != null">bank_code = #{bankCode},</if>
            <if test="taxpayerIdentificationNumber != null">taxpayer_identification_number =
                #{taxpayerIdentificationNumber},
            </if>
            <if test="address != null">address = #{address},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="createrId != null">creater_id = #{createrId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteKuaishouLiveCustomerInvoiceById" parameterType="String">
        delete
        from kuaishou_live_customer_invoice
        where id = #{id}
    </delete>

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