<?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.system.mapper.SysProjectProgressMapper">

    <resultMap type="SysProjectProgress" id="SysProjectProgressResult">
        <result property="id"    column="id"    />
        <result property="projectId"    column="project_id"    />
        <result property="projectName"    column="project_name"    />
        <result property="currentStatus"    column="current_status"    />
        <result property="currentAchievement"    column="current_achievement"    />
        <result property="progressDetail"    column="progress_detail"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="createBy"    column="create_by"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectSysProjectProgressVo">
        select id, project_id, project_name, current_status, current_achievement, progress_detail, update_time, create_time, create_by, update_by, remark from sys_project_progress
    </sql>

    <select id="selectSysProjectProgressList" parameterType="SysProjectProgress" resultMap="SysProjectProgressResult">
        <include refid="selectSysProjectProgressVo"/>
        <where>
            <if test="projectName != null and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
            <if test="currentStatus != null and currentStatus != ''"> and current_status = #{currentStatus}</if>
            <if test="params.beginTime != null and params.beginTime != ''">
                and date_format(update_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
            </if>
            <if test="params.endTime != null and params.endTime != ''">
                and date_format(update_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
            </if>
        </where>
        order by update_time desc
    </select>

    <select id="selectSysProjectProgressById" parameterType="Long" resultMap="SysProjectProgressResult">
        <include refid="selectSysProjectProgressVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysProjectProgress" parameterType="SysProjectProgress" useGeneratedKeys="true" keyProperty="id">
        insert into sys_project_progress
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectId != null">project_id,</if>
            <if test="projectName != null and projectName != ''">project_name,</if>
            <if test="currentStatus != null">current_status,</if>
            <if test="currentAchievement != null and currentAchievement != ''">current_achievement,</if>
            <if test="progressDetail != null">progress_detail,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="projectId != null">#{projectId},</if>
            <if test="projectName != null and projectName != ''">#{projectName},</if>
            <if test="currentStatus != null">#{currentStatus},</if>
            <if test="currentAchievement != null and currentAchievement != ''">#{currentAchievement},</if>
            <if test="progressDetail != null">#{progressDetail},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateSysProjectProgress" parameterType="SysProjectProgress">
        update sys_project_progress
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectId != null">project_id = #{projectId},</if>
            <if test="projectName != null and projectName != ''">project_name = #{projectName},</if>
            <if test="currentStatus != null">current_status = #{currentStatus},</if>
            <if test="currentAchievement != null and currentAchievement != ''">current_achievement = #{currentAchievement},</if>
            <if test="progressDetail != null">progress_detail = #{progressDetail},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysProjectProgressById" parameterType="Long">
        delete from sys_project_progress where id = #{id}
    </delete>

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

</mapper>
