<?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.SltProjectMonthDetailMapper">
    <resultMap type="com.bonus.material.settlement.domain.SltProjectMonthDetail" id="SltProjectMonthDetailResult">
        <result property="id"    column="id"    />
        <result property="typeId"    column="type_id"    />
        <result property="maId"    column="ma_id"    />
        <result property="unit"    column="unit"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="sltDays"    column="slt_days"    />
        <result property="sltCosts"    column="slt_costs"    />
        <result property="monthTemporarilyCosts"    column="month_temporarily_costs"    />
        <result property="proMonthCostId"    column="pro_month_cost_id"    />
        <result property="num"    column="num"    />
        <result property="leasePrice"    column="lease_price"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectSltProjectMonthDetailVo">
        select id, type_id, ma_id, unit, start_time, end_time, slt_days, slt_costs, month_temporarily_costs, pro_month_cost_id, num, lease_price, create_time, update_time from slt_project_month_detail
    </sql>

    <select id="selectSltProjectMonthDetailList" parameterType="com.bonus.material.settlement.domain.SltProjectMonthDetail" resultMap="SltProjectMonthDetailResult">
        <include refid="selectSltProjectMonthDetailVo"/>
        <where>  
            <if test="typeId != null "> and type_id = #{typeId}</if>
            <if test="maId != null "> and ma_id = #{maId}</if>
            <if test="unit != null  and unit != ''"> and unit = #{unit}</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
            <if test="sltDays != null  and sltDays != ''"> and slt_days = #{sltDays}</if>
            <if test="sltCosts != null "> and slt_costs = #{sltCosts}</if>
            <if test="monthTemporarilyCosts != null "> and month_temporarily_costs = #{monthTemporarilyCosts}</if>
            <if test="proMonthCostId != null "> and pro_month_cost_id = #{proMonthCostId}</if>
            <if test="num != null "> and num = #{num}</if>
            <if test="leasePrice != null "> and lease_price = #{leasePrice}</if>
        </where>
    </select>
    
    <select id="selectSltProjectMonthDetailById" parameterType="Long" resultMap="SltProjectMonthDetailResult">
        <include refid="selectSltProjectMonthDetailVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSltProjectMonthDetail" parameterType="com.bonus.material.settlement.domain.SltProjectMonthDetail" useGeneratedKeys="true" keyProperty="id">
        insert into slt_project_month_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="typeId != null">type_id,</if>
            <if test="maId != null">ma_id,</if>
            <if test="unit != null">unit,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="sltDays != null">slt_days,</if>
            <if test="sltCosts != null">slt_costs,</if>
            <if test="monthTemporarilyCosts != null">month_temporarily_costs,</if>
            <if test="proMonthCostId != null">pro_month_cost_id,</if>
            <if test="num != null">num,</if>
            <if test="leasePrice != null">lease_price,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="typeId != null">#{typeId},</if>
            <if test="maId != null">#{maId},</if>
            <if test="unit != null">#{unit},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="sltDays != null">#{sltDays},</if>
            <if test="sltCosts != null">#{sltCosts},</if>
            <if test="monthTemporarilyCosts != null">#{monthTemporarilyCosts},</if>
            <if test="proMonthCostId != null">#{proMonthCostId},</if>
            <if test="num != null">#{num},</if>
            <if test="leasePrice != null">#{leasePrice},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateSltProjectMonthDetail" parameterType="com.bonus.material.settlement.domain.SltProjectMonthDetail">
        update slt_project_month_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="typeId != null">type_id = #{typeId},</if>
            <if test="maId != null">ma_id = #{maId},</if>
            <if test="unit != null">unit = #{unit},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="sltDays != null">slt_days = #{sltDays},</if>
            <if test="sltCosts != null">slt_costs = #{sltCosts},</if>
            <if test="monthTemporarilyCosts != null">month_temporarily_costs = #{monthTemporarilyCosts},</if>
            <if test="proMonthCostId != null">pro_month_cost_id = #{proMonthCostId},</if>
            <if test="num != null">num = #{num},</if>
            <if test="leasePrice != null">lease_price = #{leasePrice},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSltProjectMonthDetailById" parameterType="Long">
        delete from slt_project_month_detail where id = #{id}
    </delete>

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