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

    <resultMap type="SysSciencePlan" id="SysSciencePlanResult">
        <id property="id" column="id" />
        <result property="title" column="title" />
        <result property="content" column="content" />
        <result property="sortOrder" column="sort_order" />
        <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="selectSysSciencePlanVo">
        select id, title, content, sort_order, create_by, create_time, update_by, update_time, remark
        from sys_science_plan
    </sql>

    <select id="selectSysSciencePlanById" parameterType="Long" resultMap="SysSciencePlanResult">
        <include refid="selectSysSciencePlanVo" />
        where id = #{id}
    </select>

    <select id="selectSysSciencePlanList" resultMap="SysSciencePlanResult">
        <include refid="selectSysSciencePlanVo" />
        order by sort_order asc, create_time desc
    </select>

    <insert id="insertSysSciencePlan" parameterType="SysSciencePlan" useGeneratedKeys="true" keyProperty="id">
        insert into sys_science_plan
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null and title != ''">title,</if>
            <if test="content != null">content,</if>
            <if test="sortOrder != null">sort_order,</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="title != null and title != ''">#{title},</if>
            <if test="content != null">#{content},</if>
            <if test="sortOrder != null">#{sortOrder},</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="updateSysSciencePlan" parameterType="SysSciencePlan">
        update sys_science_plan
        <set>
            <if test="title != null and title != ''">title = #{title},</if>
            <if test="content != null">content = #{content},</if>
            <if test="sortOrder != null">sort_order = #{sortOrder},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </set>
        where id = #{id}
    </update>

    <delete id="deleteSysSciencePlanById" parameterType="Long">
        delete from sys_science_plan where id = #{id}
    </delete>

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

</mapper>
