<?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.SysMilestoneMapper">

    <resultMap type="SysMilestone" id="SysMilestoneResult">
        <result property="id"    column="id"    />
        <result property="eventName"    column="event_name"    />
        <result property="eventTime"    column="event_time"    />
        <result property="eventDescription"    column="event_description"    />
        <result property="status"    column="status"    />
        <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="selectSysMilestoneVo">
        select id, event_name, event_time, event_description, status, create_by, create_time, update_by, update_time, remark from sys_milestone
    </sql>

    <select id="selectSysMilestoneList" parameterType="SysMilestone" resultMap="SysMilestoneResult">
        <include refid="selectSysMilestoneVo"/>
        <where>
            <if test="eventName != null  and eventName != ''"> and event_name like concat('%', #{eventName}, '%')</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="params.beginTime != null and params.beginTime != ''">
                and date_format(event_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
            </if>
            <if test="params.endTime != null and params.endTime != ''">
                and date_format(event_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
            </if>
        </where>
        order by event_time desc
    </select>

    <select id="selectSysMilestoneById" parameterType="Long" resultMap="SysMilestoneResult">
        <include refid="selectSysMilestoneVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysMilestone" parameterType="SysMilestone" useGeneratedKeys="true" keyProperty="id">
        insert into sys_milestone
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="eventName != null and eventName != ''">event_name,</if>
            <if test="eventTime != null">event_time,</if>
            <if test="eventDescription != null">event_description,</if>
            <if test="status != null">status,</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="eventName != null and eventName != ''">#{eventName},</if>
            <if test="eventTime != null">#{eventTime},</if>
            <if test="eventDescription != null">#{eventDescription},</if>
            <if test="status != null">#{status},</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="updateSysMilestone" parameterType="SysMilestone">
        update sys_milestone
        <trim prefix="SET" suffixOverrides=",">
            <if test="eventName != null and eventName != ''">event_name = #{eventName},</if>
            <if test="eventTime != null">event_time = #{eventTime},</if>
            <if test="eventDescription != null">event_description = #{eventDescription},</if>
            <if test="status != null">status = #{status},</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 id = #{id}
    </update>

    <delete id="deleteSysMilestoneById" parameterType="Long">
        delete from sys_milestone where id = #{id}
    </delete>

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

</mapper>
