<?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.leromro.core.mapper.BusinessPriceMapper">
    
    <resultMap type="BusinessPrice" id="BusinessPriceResult">
        <result property="businessPriceId"    column="business_price_id"    />
        <result property="businessPrice"    column="business_price"    />
        <result property="businessDuration"    column="business_duration"    />
        <result property="businessManagementId"    column="business_management_id"    />
        <result property="projectName"    column="project_name"    />
        <result property="projectTypeName"    column="project_type_name"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectBusinessPriceVo">
        select business_price_id, business_price, business_duration, business_management_id,project_name,project_type_name, create_by, create_time, update_by, update_time, remark from l_business_price
    </sql>

    
    <select id="selectBusinessPriceByBusinessPriceId" parameterType="Long" resultMap="BusinessPriceResult">
        <include refid="selectBusinessPriceVo"/>
        where business_price_id = #{businessPriceId}
    </select>
    <select id="selectBusinessPriceList" resultType="com.leromro.core.domain.vo.BusinessPriceVO">
        select * from l_business_price
        where 1=1
        <if test="businessPrice.businessManagementId != null">
            AND business_management_id in (select business_management_id from l_business_management where business_management_id = #{businessPrice.businessManagementId})
        </if>
    </select>

    <insert id="insertBusinessPrice" parameterType="BusinessPrice" useGeneratedKeys="true" keyProperty="businessPriceId">
        insert into l_business_price
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="businessPrice != null">business_price,</if>
            <if test="businessDuration != null">business_duration,</if>
            <if test="businessManagementId != null">business_management_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="businessPrice != null">#{businessPrice},</if>
            <if test="businessDuration != null">#{businessDuration},</if>
            <if test="businessManagementId != null">#{businessManagementId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateBusinessPrice" parameterType="BusinessPrice">
        update l_business_price
        <trim prefix="SET" suffixOverrides=",">
            <if test="businessPrice != null">business_price = #{businessPrice},</if>
            <if test="businessDuration != null">business_duration = #{businessDuration},</if>
            <if test="businessManagementId != null">business_management_id = #{businessManagementId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where business_price_id = #{businessPriceId}
    </update>

    <delete id="deleteBusinessPriceByBusinessPriceId" parameterType="Long">
        delete from l_business_price where business_price_id = #{businessPriceId}
    </delete>

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