<?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.ruoyi.oa.mapper.CmcSettleWorkMapper">
    
    <resultMap type="CmcSettleWork" id="CmcSettleWorkResult">
        <result property="workId"    column="work_id"    />
        <result property="settleId"    column="settle_id"    />
        <result property="content"    column="content"    />
        <result property="priceId"    column="price_id"    />
        <result property="workload"    column="workload"    />
        <result property="coefficient"    column="coefficient"    />
        <result property="groundType"    column="ground_type"    />
        <result property="settle"    column="settle"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectCmcSettleWorkVo">
        select work_id, settle_id, content, price_id, workload, coefficient, ground_type, settle, remark from cmc_settle_work
    </sql>

    <select id="selectCmcSettleWorkList" parameterType="CmcSettleWork" resultMap="CmcSettleWorkResult">
        <include refid="selectCmcSettleWorkVo"/>
        <where>  
            <if test="settleId != null  and settleId != ''"> and settle_id = #{settleId}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="priceId != null "> and price_id = #{priceId}</if>
            <if test="workload != null "> and workload = #{workload}</if>
            <if test="coefficient != null "> and coefficient = #{coefficient}</if>
            <if test="groundType != null  and groundType != ''"> and ground_type = #{groundType}</if>
            <if test="settle != null "> and settle = #{settle}</if>
        </where>
        order by work_id asc
    </select>
    
    <select id="selectCmcSettleWorkBySettleId" parameterType="String" resultMap="CmcSettleWorkResult">
        <include refid="selectCmcSettleWorkVo"/>
        where settle_id = #{settleId}
    </select>
        
    <insert id="insertCmcSettleWork" parameterType="CmcSettleWork">
        insert into cmc_settle_work
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="workId != null">work_id,</if>
            <if test="settleId != null">settle_id,</if>
            <if test="content != null">content,</if>
            <if test="priceId != null">price_id,</if>
            <if test="workload != null">workload,</if>
            <if test="coefficient != null">coefficient,</if>
            <if test="groundType != null">ground_type,</if>
            <if test="settle != null">settle,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="workId != null">#{workId},</if>
            <if test="settleId != null">#{settleId},</if>
            <if test="content != null">#{content},</if>
            <if test="priceId != null">#{priceId},</if>
            <if test="workload != null">#{workload},</if>
            <if test="coefficient != null">#{coefficient},</if>
            <if test="groundType != null">#{groundType},</if>
            <if test="settle != null">#{settle},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateCmcSettleWork" parameterType="CmcSettleWork">
        update cmc_settle_work
        <trim prefix="SET" suffixOverrides=",">
            <if test="settleId != null">settle_id = #{settleId},</if>
            <if test="content != null">content = #{content},</if>
            <if test="priceId != null">price_id = #{priceId},</if>
            <if test="workload != null">workload = #{workload},</if>
            <if test="coefficient != null">coefficient = #{coefficient},</if>
            <if test="groundType != null">ground_type = #{groundType},</if>
            <if test="settle != null">settle = #{settle},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where work_id = #{workId}
    </update>

    <delete id="deleteCmcSettleWorkBySettleId" parameterType="String">
        delete from cmc_settle_work where settle_id = #{settleId}
    </delete>

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