<?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.SysPlanMapper">
    
    <resultMap type="SysPlan" id="SysPlanResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="status"    column="status"    />
        <result property="section"    column="section"    />
        <result property="direction"    column="direction"    />
        <result property="startKm"    column="start_km"    />
        <result property="startHectometer"    column="start_hectometer"    />
        <result property="endKm"    column="end_km"    />
        <result property="endHectometer"    column="end_hectometer"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="dept"    column="dept"    />
        <result property="creatUser"    column="creat_user"    />
        <result property="createTime"    column="create_time"    />
        <result property="bridgeHeightWidth"    column="bridge_height_width"    />
        <result property="level"    column="level"    />
        <result property="fileUrl"    column="file_url"    />
        <result property="contentOne"    column="content_one"    />
        <result property="contentTwo"    column="content_two"    />
    </resultMap>

    <sql id="selectSysPlanVo">
        select id, name, status, section, direction, start_km, start_hectometer, end_km, end_hectometer, start_time, end_time, dept, creat_user, create_time, bridge_height_width, level, file_url, content_one, content_two from sys_plan
    </sql>

    <select id="selectSysPlanList" parameterType="SysPlan" resultMap="SysPlanResult">
        <include refid="selectSysPlanVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="section != null  and section != ''"> and section = #{section}</if>
            <if test="direction != null  and direction != ''"> and direction = #{direction}</if>
            <if test="startKm != null  and startKm != ''"> and start_km = #{startKm}</if>
            <if test="startHectometer != null  and startHectometer != ''"> and start_hectometer = #{startHectometer}</if>
            <if test="endKm != null  and endKm != ''"> and end_km = #{endKm}</if>
            <if test="endHectometer != null  and endHectometer != ''"> and end_hectometer = #{endHectometer}</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
            <if test="dept != null  and dept != ''"> and dept = #{dept}</if>
            <if test="creatUser != null  and creatUser != ''"> and creat_user = #{creatUser}</if>
            <if test="bridgeHeightWidth != null  and bridgeHeightWidth != ''"> and bridge_height_width = #{bridgeHeightWidth}</if>
            <if test="level != null  and level != ''"> and level = #{level}</if>
            <if test="fileUrl != null  and fileUrl != ''"> and file_url = #{fileUrl}</if>
            <if test="contentOne != null  and contentOne != ''"> and content_one = #{contentOne}</if>
            <if test="contentTwo != null  and contentTwo != ''"> and content_two = #{contentTwo}</if>
        </where>
    </select>
    
    <select id="selectSysPlanById" parameterType="Long" resultMap="SysPlanResult">
        <include refid="selectSysPlanVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSysPlan" parameterType="SysPlan">
        insert into sys_plan
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="name != null">name,</if>
            <if test="status != null">status,</if>
            <if test="section != null">section,</if>
            <if test="direction != null">direction,</if>
            <if test="startKm != null">start_km,</if>
            <if test="startHectometer != null">start_hectometer,</if>
            <if test="endKm != null">end_km,</if>
            <if test="endHectometer != null">end_hectometer,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="dept != null">dept,</if>
            <if test="creatUser != null">creat_user,</if>
            <if test="createTime != null">create_time,</if>
            <if test="bridgeHeightWidth != null">bridge_height_width,</if>
            <if test="level != null">level,</if>
            <if test="fileUrl != null">file_url,</if>
            <if test="contentOne != null">content_one,</if>
            <if test="contentTwo != null">content_two,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="name != null">#{name},</if>
            <if test="status != null">#{status},</if>
            <if test="section != null">#{section},</if>
            <if test="direction != null">#{direction},</if>
            <if test="startKm != null">#{startKm},</if>
            <if test="startHectometer != null">#{startHectometer},</if>
            <if test="endKm != null">#{endKm},</if>
            <if test="endHectometer != null">#{endHectometer},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="dept != null">#{dept},</if>
            <if test="creatUser != null">#{creatUser},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="bridgeHeightWidth != null">#{bridgeHeightWidth},</if>
            <if test="level != null">#{level},</if>
            <if test="fileUrl != null">#{fileUrl},</if>
            <if test="contentOne != null">#{contentOne},</if>
            <if test="contentTwo != null">#{contentTwo},</if>
         </trim>
    </insert>

    <update id="updateSysPlan" parameterType="SysPlan">
        update sys_plan
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="status != null">status = #{status},</if>
            <if test="section != null">section = #{section},</if>
            <if test="direction != null">direction = #{direction},</if>
            <if test="startKm != null">start_km = #{startKm},</if>
            <if test="startHectometer != null">start_hectometer = #{startHectometer},</if>
            <if test="endKm != null">end_km = #{endKm},</if>
            <if test="endHectometer != null">end_hectometer = #{endHectometer},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="dept != null">dept = #{dept},</if>
            <if test="creatUser != null">creat_user = #{creatUser},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="bridgeHeightWidth != null">bridge_height_width = #{bridgeHeightWidth},</if>
            <if test="level != null">level = #{level},</if>
            <if test="fileUrl != null">file_url = #{fileUrl},</if>
            <if test="contentOne != null">content_one = #{contentOne},</if>
            <if test="contentTwo != null">content_two = #{contentTwo},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysPlanById" parameterType="Long">
        delete from sys_plan where id = #{id}
    </delete>

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