<?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.ExamineScheduleMapper">
    
    <resultMap type="ExamineSchedule" id="ExamineScheduleResult">
        <result property="id"    column="id"    />
        <result property="newsId"    column="news_id"    />
        <result property="examineNameOne"    column="examine_name_one"    />
        <result property="examineTimeOne"    column="examine_time_one"    />
        <result property="examineNameTwo"    column="examine_name_two"    />
        <result property="examineTimeTwo"    column="examine_time_two"    />
        <result property="examineNameThr"    column="examine_name_thr"    />
        <result property="examineTimeThr"    column="examine_time_thr"    />
        <result property="examineLevel"    column="examine_level"    />
        <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="selectExamineScheduleVo">
        select id, news_id, examine_name_one, examine_time_one, examine_name_two, examine_time_two, examine_name_thr, examine_time_thr, examine_level, create_by, create_time, update_by, update_time, remark from examine_schedule
    </sql>

    <select id="selectExamineScheduleList" parameterType="ExamineSchedule" resultMap="ExamineScheduleResult">
        <include refid="selectExamineScheduleVo"/>
        <where>  
            <if test="examineNameOne != null  and examineNameOne != ''"> and examine_name_one = #{examineNameOne}</if>
            <if test="examineNameTwo != null  and examineNameTwo != ''"> and examine_name_two = #{examineNameTwo}</if>
            <if test="examineNameThr != null  and examineNameThr != ''"> and examine_name_thr = #{examineNameThr}</if>
            <if test="examineLevel != null  and examineLevel != ''"> and examine_level = #{examineLevel}</if>
        </where>
    </select>
    
    <select id="selectExamineScheduleById" parameterType="Long" resultMap="ExamineScheduleResult">
        <include refid="selectExamineScheduleVo"/>
        where id = #{id}
    </select>

    <select id="selectExamineScheduleByNewId" parameterType="Long" resultMap="ExamineScheduleResult">
        <include refid="selectExamineScheduleVo"/>
        where news_id = #{id}
    </select>
        
    <insert id="insertExamineSchedule" parameterType="ExamineSchedule" useGeneratedKeys="true" keyProperty="id">
        insert into examine_schedule
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="newsId != null">news_id,</if>
            <if test="examineNameOne != null">examine_name_one,</if>
            <if test="examineTimeOne != null">examine_time_one,</if>
            <if test="examineNameTwo != null">examine_name_two,</if>
            <if test="examineTimeTwo != null">examine_time_two,</if>
            <if test="examineNameThr != null">examine_name_thr,</if>
            <if test="examineTimeThr != null">examine_time_thr,</if>
            <if test="examineLevel != null">examine_level,</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="newsId != null">#{newsId},</if>
            <if test="examineNameOne != null">#{examineNameOne},</if>
            <if test="examineTimeOne != null">#{examineTimeOne},</if>
            <if test="examineNameTwo != null">#{examineNameTwo},</if>
            <if test="examineTimeTwo != null">#{examineTimeTwo},</if>
            <if test="examineNameThr != null">#{examineNameThr},</if>
            <if test="examineTimeThr != null">#{examineTimeThr},</if>
            <if test="examineLevel != null">#{examineLevel},</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="updateExamineSchedule" parameterType="ExamineSchedule">
        update examine_schedule
        <trim prefix="SET" suffixOverrides=",">
            <if test="newsId != null">news_id = #{newsId},</if>
            <if test="examineNameOne != null">examine_name_one = #{examineNameOne},</if>
            <if test="examineTimeOne != null">examine_time_one = #{examineTimeOne},</if>
            <if test="examineNameTwo != null">examine_name_two = #{examineNameTwo},</if>
            <if test="examineTimeTwo != null">examine_time_two = #{examineTimeTwo},</if>
            <if test="examineNameThr != null">examine_name_thr = #{examineNameThr},</if>
            <if test="examineTimeThr != null">examine_time_thr = #{examineTimeThr},</if>
            <if test="examineLevel != null">examine_level = #{examineLevel},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</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="deleteExamineScheduleById" parameterType="Long">
        delete from examine_schedule where id = #{id}
    </delete>

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