<?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.srs.routine.mapper.RtFuSoltMapper">

    <resultMap type="RtFuSolt" id="RtFuSoltResult">
        <result property="id"    column="id"    />
        <result property="roType"    column="ro_type"    />
        <result property="soRule"    column="so_rule"    />
        <result property="roWeekday"    column="ro_weekday"    />
        <result property="soNo"    column="so_no"    />
        <result property="roStartTime"    column="ro_startTime"    />
        <result property="roEndTime"    column="ro_endTime"    />
    </resultMap>

    <sql id="selectRtFuSoltVo">
        select distinct id, ro_type, so_rule,ro_weekday, so_no, ro_startTime, ro_endTime from rt_fu_solt
    </sql>

    <select id="selectRtFuSoltRule" resultType="com.srs.routine.domain.vo.RtfuRuleVo">
        select id,ro_type,ro_weekday,ro_startTime,ro_endTime from rt_fu_solt
        <where>
            <if test="roType != null  and roType != ''"> and ro_type = #{roType}</if>
            <if test="roWeekday != null  and roWeekday != ''"> and ro_weekday = #{roWeekday}</if>
<!--            <if test="roEndTime != null  and roEndTime != ''"> and ro_endTime = #{roEndTime}</if>-->
        </where>
    </select>

    <select id="selectRtFuSoltList" parameterType="RtFuSolt" resultMap="RtFuSoltResult">
        <include refid="selectRtFuSoltVo"/>
        <where>
            <if test="roType != null  and roType != ''"> and ro_type = #{roType}</if>
            <if test="roWeekday != null  and roWeekday != ''"> and ro_weekday = #{roWeekday}</if>
            <if test="soRule != null  and soRule != ''"> and so_rule = #{soRule}</if>
            <if test="soNo != null  and soNo != ''"> and so_no = #{soNo}</if>
            <if test="roStartTime != null "> and ro_startTime = #{roStartTime}</if>
            <if test="roEndTime != null  and roEndTime != ''"> and ro_endTime = #{roEndTime}</if>
        </where>
    </select>

    <select id="selectRtFuSoltLists" resultType="com.srs.routine.domain.vo.RtfuRuleVo">
        <include refid="selectRtFuSoltVo"/>
        <where>
            <if test="roType != null  and roType != ''"> and ro_type = #{roType}</if>
            <if test="soRule != null  and soRule != ''"> and so_rule = #{soRule}</if>
            <if test="roWeekday != null  and roWeekday != ''"> and ro_weekday = #{roWeekday}</if>
            <if test="soNo != null  and soNo != ''"> and so_no = #{soNo}</if>
            <if test="roStartTime != null "> and ro_startTime = #{roStartTime}</if>
            <if test="roEndTime != null  and roEndTime != ''"> and ro_endTime = #{roEndTime}</if>
        </where>
    </select>

    <select id="selectRtFSoles" parameterType="RtFuSolt" resultMap="RtFuSoltResult">
        <include refid="selectRtFuSoltVo"/>
        <where>
            <if test="roType != null  and roType != ''"> and ro_type = #{roType}</if>
            <if test="soRule != null  and soRule != ''"> and so_rule = #{soRule}</if>
            <if test="roWeekday != null  and roWeekday != ''"> and ro_weekday = #{roWeekday}</if>
            <if test="soNo != null  and soNo != ''"> and so_no = #{soNo}</if>
            <if test="roStartTime != null "> and ro_startTime = #{roStartTime}</if>
            <if test="roEndTime != null  and roEndTime != ''"> and ro_endTime = #{roEndTime}</if>
        </where>
    </select>

    <select id="selectRtFuSoltById" parameterType="Long" resultMap="RtFuSoltResult">
        <include refid="selectRtFuSoltVo"/>
        where id = #{id}
    </select>

    <insert id="insertRtFuSolt" parameterType="RtFuSolt" useGeneratedKeys="true" keyProperty="id">
        insert into rt_fu_solt
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="roType != null">ro_type,</if>
            <if test="roWeekday != null">ro_weekday,</if>
            <if test="soRule != null">so_rule,</if>
            <if test="soNo != null">so_no,</if>
            <if test="roStartTime != null">ro_startTime,</if>
            <if test="roEndTime != null">ro_endTime,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="roType != null">#{roType},</if>
            <if test="roWeekday != null">#{roWeekday},</if>
            <if test="soRule != null">#{soRule},</if>
            <if test="soNo != null">#{soNo},</if>
            <if test="roStartTime != null">#{roStartTime},</if>
            <if test="roEndTime != null">#{roEndTime},</if>
        </trim>
    </insert>

    <update id="updateRtFuSolt" parameterType="RtFuSolt">
        update rt_fu_solt
        <trim prefix="SET" suffixOverrides=",">
            <if test="roType != null">ro_type = #{roType},</if>
            <if test="roWeekday != null">ro_weekday = #{roWeekday},</if>
            <if test="soRule != null">so_rule = #{soRule},</if>
            <if test="soNo != null">so_no = #{soNo},</if>
            <if test="roStartTime != null">ro_startTime = #{roStartTime},</if>
            <if test="roEndTime != null">ro_endTime = #{roEndTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRtFuSoltById" parameterType="Long">
        delete from rt_fu_solt where id = #{id}
    </delete>

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