<?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.CmcProjectProgressMapper">
    
    <resultMap type="CmcProjectProgress" id="CmcProjectProgressResult">
        <result property="progressId"    column="progress_id"    />
        <result property="projectId"    column="project_id"    />
        <result property="percentage"    column="percentage"    />
        <result property="date"    column="date"    />
        <result property="situation"    column="situation"    />
    </resultMap>

    <sql id="selectCmcProjectProgressVo">
        select progress_id, project_id, percentage, date, situation from cmc_project_progress
    </sql>

    <select id="selectCmcProjectProgressList" parameterType="CmcProjectProgress" resultMap="CmcProjectProgressResult">
        <include refid="selectCmcProjectProgressVo"/>
        <where>  
            <if test="projectId != null  and projectId != ''"> and project_id = #{projectId}</if>
            <if test="percentage != null  and percentage != ''"> and percentage = #{percentage}</if>
            <if test="date != null "> and date = #{date}</if>
            <if test="situation != null  and situation != ''"> and situation = #{situation}</if>
        </where>
    </select>
    
    <select id="selectCmcProjectProgressByProjectId" parameterType="String" resultMap="CmcProjectProgressResult">
        <include refid="selectCmcProjectProgressVo"/>
        where project_id = #{projectId}
        order by date asc
    </select>
        
    <insert id="insertCmcProjectProgress" parameterType="CmcProjectProgress">
        insert into cmc_project_progress
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="progressId != null">progress_id,</if>
            <if test="projectId != null">project_id,</if>
            <if test="percentage != null">percentage,</if>
            <if test="date != null">date,</if>
            <if test="situation != null">situation,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="progressId != null">#{progressId},</if>
            <if test="projectId != null">#{projectId},</if>
            <if test="percentage != null">#{percentage},</if>
            <if test="date != null">#{date},</if>
            <if test="situation != null">#{situation},</if>
         </trim>
    </insert>

    <update id="updateCmcProjectProgress" parameterType="CmcProjectProgress">
        update cmc_project_progress
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectId != null">project_id = #{projectId},</if>
            <if test="percentage != null">percentage = #{percentage},</if>
            <if test="date != null">date = #{date},</if>
            <if test="situation != null">situation = #{situation},</if>
        </trim>
        where progress_id = #{progressId}
    </update>

    <delete id="deleteCmcProjectProgressByProjectId" parameterType="String">
        delete from cmc_project_progress where project_id = #{projectId}
    </delete>

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