<?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.bonus.material.settlement.mapper.SltAgreementApplyMapper">
    <resultMap type="com.bonus.material.settlement.domain.SltAgreementApply" id="SltAgreementApplyResult">
        <result property="id"    column="id"    />
        <result property="code"    column="code"    />
        <result property="creator"    column="creator"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="auditor"    column="auditor"    />
        <result property="auditTime"    column="audit_time"    />
        <result property="status"    column="status"    />
        <result property="companyId"    column="company_id"    />
        <result property="cost"    column="cost"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectSltAgreementApplyVo">
        select id, code, creator, create_time, update_time, auditor, audit_time, status, company_id, cost, remark from slt_agreement_apply
    </sql>

    <select id="selectSltAgreementApplyList" parameterType="com.bonus.material.settlement.domain.SltAgreementApply" resultMap="SltAgreementApplyResult">
        <include refid="selectSltAgreementApplyVo"/>
        <where>  
            <if test="code != null  and code != ''"> and code = #{code}</if>
            <if test="creator != null  and creator != ''"> and creator = #{creator}</if>
            <if test="auditor != null  and auditor != ''"> and auditor = #{auditor}</if>
            <if test="auditTime != null "> and audit_time = #{auditTime}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="companyId != null "> and company_id = #{companyId}</if>
            <if test="cost != null "> and cost = #{cost}</if>
        </where>
    </select>
    
    <select id="selectSltAgreementApplyById" parameterType="Long" resultMap="SltAgreementApplyResult">
        <include refid="selectSltAgreementApplyVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSltAgreementApply" parameterType="com.bonus.material.settlement.domain.SltAgreementApply" useGeneratedKeys="true" keyProperty="id">
        insert into slt_agreement_apply
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="code != null">code,</if>
            <if test="creator != null">creator,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="auditor != null">auditor,</if>
            <if test="auditTime != null">audit_time,</if>
            <if test="status != null">status,</if>
            <if test="companyId != null">company_id,</if>
            <if test="cost != null">cost,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="code != null">#{code},</if>
            <if test="creator != null">#{creator},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="auditor != null">#{auditor},</if>
            <if test="auditTime != null">#{auditTime},</if>
            <if test="status != null">#{status},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="cost != null">#{cost},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateSltAgreementApply" parameterType="com.bonus.material.settlement.domain.SltAgreementApply">
        update slt_agreement_apply
        <trim prefix="SET" suffixOverrides=",">
            <if test="code != null">code = #{code},</if>
            <if test="creator != null">creator = #{creator},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="auditor != null">auditor = #{auditor},</if>
            <if test="auditTime != null">audit_time = #{auditTime},</if>
            <if test="status != null">status = #{status},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="cost != null">cost = #{cost},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSltAgreementApplyById" parameterType="Long">
        delete from slt_agreement_apply where id = #{id}
    </delete>

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