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

    <resultMap type="RtStuMultiLevelReview" id="RtStuMultiLevelReviewResult">
        <result property="id"    column="id"    />
        <result property="stuName"    column="stu_name"    />
        <result property="stuNo"    column="stuNo"    />
        <result property="reason"    column="reason"    />
        <result property="reviewer"    column="reviewer"    />
        <result property="reviewerIdentity"    column="reviewer_identity"    />
        <result property="reviewTime"    column="review_time"    />
        <result property="reviewerId"    column="reviewer_id"    />
        <result property="notes"    column="notes"    />
        <result property="type"    column="type"    />
        <result property="reviewerStatus"    column="reviewer_status"    />
    </resultMap>

    <sql id="selectRtStuMultiLevelReviewVo">
        select id, stu_name, stuNo, reason, reviewer, reviewer_identity, review_time, reviewer_id, notes, type, reviewer_status from rt_stu_multi_level_review
    </sql>

    <select id="selectRtStuMultiLevelReviewList" parameterType="RtStuMultiLevelReview" resultMap="RtStuMultiLevelReviewResult">
        <include refid="selectRtStuMultiLevelReviewVo"/>
        <where>
            <if test="stuName != null "> and stu_name like concat('%', #{stuName}, '%')</if>
            <if test="stuNo != null  and stuNo != ''"> and stuNo = #{stuNo}</if>
            <if test="reason != null  and reason != ''"> and reason = #{reason}</if>
            <if test="reviewer != null  and reviewer != ''"> and reviewer = #{reviewer}</if>
            <if test="reviewerIdentity != null  and reviewerIdentity != ''"> and reviewer_identity = #{reviewerIdentity}</if>
            <if test="reviewTime != null "> and review_time = #{reviewTime}</if>
            <if test="reviewerId != null "> and reviewer_id = #{reviewerId}</if>
            <if test="notes != null  and notes != ''"> and notes = #{notes}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="reviewerStatus != null "> and reviewer_status = #{reviewerStatus}</if>
        </where>
    </select>

    <select id="selectRtStuMultiLevelReviewById" parameterType="Long" resultMap="RtStuMultiLevelReviewResult">
        <include refid="selectRtStuMultiLevelReviewVo"/>
        where id = #{id}
    </select>

    <select id="selectRtStuMultiLevelReviewByReviewerIdentity" parameterType="String" resultMap="RtStuMultiLevelReviewResult">
        <include refid="selectRtStuMultiLevelReviewVo"/>
        where reviewer_identity = #{reviewerIdentity} and stuNo = #{stuNo}
    </select>

    <insert id="insertRtStuMultiLevelReview" parameterType="RtStuMultiLevelReview" useGeneratedKeys="true" keyProperty="id">
        insert into rt_stu_multi_level_review
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="stuName != null">stu_name,</if>
            <if test="stuNo != null and stuNo != ''">stuNo,</if>
            <if test="reason != null and reason != ''">reason,</if>
            <if test="reviewer != null">reviewer,</if>
            <if test="reviewerIdentity != null">reviewer_identity,</if>
            <if test="reviewTime != null">review_time,</if>
            <if test="reviewerId != null">reviewer_id,</if>
            <if test="notes != null">notes,</if>
            <if test="type != null">type,</if>
            <if test="reviewerStatus != null">reviewer_status,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="stuName != null">#{stuName},</if>
            <if test="stuNo != null and stuNo != ''">#{stuNo},</if>
            <if test="reason != null and reason != ''">#{reason},</if>
            <if test="reviewer != null">#{reviewer},</if>
            <if test="reviewerIdentity != null">#{reviewerIdentity},</if>
            <if test="reviewTime != null">#{reviewTime},</if>
            <if test="reviewerId != null">#{reviewerId},</if>
            <if test="notes != null">#{notes},</if>
            <if test="type != null">#{type},</if>
            <if test="reviewerStatus != null">#{reviewerStatus},</if>
        </trim>
    </insert>

    <update id="updateRtStuMultiLevelReview" parameterType="RtStuMultiLevelReview">
        update rt_stu_multi_level_review
        <trim prefix="SET" suffixOverrides=",">
            <if test="stuName != null">stu_name = #{stuName},</if>
            <if test="stuNo != null and stuNo != ''">stuNo = #{stuNo},</if>
            <if test="reason != null and reason != ''">reason = #{reason},</if>
            <if test="reviewer != null">reviewer = #{reviewer},</if>
            <if test="reviewerIdentity != null">reviewer_identity = #{reviewerIdentity},</if>
            <if test="reviewTime != null">review_time = #{reviewTime},</if>
            <if test="reviewerId != null">reviewer_id = #{reviewerId},</if>
            <if test="notes != null">notes = #{notes},</if>
            <if test="type != null">type = #{type},</if>
            <if test="reviewerStatus != null">reviewer_status = #{reviewerStatus},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRtStuMultiLevelReviewById" parameterType="Long">
        delete from rt_stu_multi_level_review where id = #{id}
    </delete>

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