<?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.postCheck.mapper.PostAssessmentRulesMapper">

    <resultMap type="PostAssessmentRules" id="PostAssessmentRulesResult">
        <result property="id"    column="id"    />
        <result property="type"    column="type"    />
        <result property="dutyType"    column="duty_type"    />
        <result property="fullScore"    column="full_score"    />
        <result property="rule"    column="rule"    />
        <result property="problemLevelOne"    column="problem_level_one"    />
        <result property="problemLevelTwo"    column="problem_level_two"    />
        <result property="status"    column="status"    />
        <result property="statusByUserId"    column="status_by_user_id"    />
        <result property="statusByUserName"    column="status_by_user_name"    />
        <result property="remark"    column="remark"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="createUserId"    column="create_user_id"    />
        <result property="statusReason"    column="status_reason"    />
        <result property="statusApproveTime"    column="status_approve_time"    />
    </resultMap>

    <sql id="selectPostAssessmentRulesVo">
        select
            id, type, duty_type, full_score, rule, problem_level_one, problem_level_two, status, status_by_user_id, status_by_user_name,
            remark, del_flag, create_time, create_by, update_time, update_by,
            create_user_id, status_reason, status_approve_time
        from post_assessment_rules t1
    </sql>

    <select id="selectPostAssessmentRulesList" parameterType="PostAssessmentRules" resultMap="PostAssessmentRulesResult">
        <include refid="selectPostAssessmentRulesVo"/>
        <where>
            <if test="type != null "> and type = #{type}</if>
            <if test="dutyType != null "> and duty_type = #{dutyType}</if>
            <if test="fullScore != null "> and full_score = #{fullScore}</if>
            <if test="rule != null  and rule != ''"> and rule = #{rule}</if>
            <if test="problemLevelOne != null "> and problem_level_one = #{problemLevelOne}</if>
            <if test="problemLevelTwo != null "> and problem_level_two = #{problemLevelTwo}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="statusByUserId != null "> and status_by_user_id = #{statusByUserId}</if>
            <if test="statusByUserName != null  and statusByUserName != ''"> and status_by_user_name like concat('%', #{statusByUserName}, '%')</if>
            <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
            <if test="statusReason != null  and statusReason != ''"> and status_reason = like concat('%', #{statusReason}, '%')</if>
        </where>
    </select>

    <select id="selectPostAssessmentRulesById" parameterType="Long" resultMap="PostAssessmentRulesResult">
        <include refid="selectPostAssessmentRulesVo"/>
        where id = #{id}
    </select>

    <insert id="insertPostAssessmentRules" parameterType="PostAssessmentRules">
        insert into post_assessment_rules
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="type != null">type,</if>
            <if test="dutyType != null">duty_type,</if>
            <if test="fullScore != null">full_score,</if>
            <if test="rule != null">rule,</if>
            <if test="problemLevelOne != null">problem_level_one,</if>
            <if test="problemLevelTwo != null">problem_level_two,</if>
            <if test="status != null">status,</if>
            <if test="statusByUserId != null">status_by_user_id,</if>
            <if test="statusByUserName != null">status_by_user_name,</if>
            <if test="remark != null">remark,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
            <if test="createUserId != null">create_user_id,</if>
            <if test="statusReason != null">status_reason,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="type != null">#{type},</if>
            <if test="dutyType != null">#{dutyType},</if>
            <if test="fullScore != null">#{fullScore},</if>
            <if test="rule != null">#{rule},</if>
            <if test="problemLevelOne != null">#{problemLevelOne},</if>
            <if test="problemLevelTwo != null">#{problemLevelTwo},</if>
            <if test="status != null">#{status},</if>
            <if test="statusByUserId != null">#{statusByUserId},</if>
            <if test="statusByUserName != null">#{statusByUserName},</if>
            <if test="remark != null">#{remark},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="createUserId != null">#{createUserId},</if>
            <if test="statusReason != null">#{statusReason},</if>
         </trim>
    </insert>

    <update id="updatePostAssessmentRules" parameterType="PostAssessmentRules">
        update post_assessment_rules
        <trim prefix="SET" suffixOverrides=",">
            <!--<if test="type != null">type = #{type},</if>-->
            <if test="dutyType != null">duty_type = #{dutyType},</if>
            <if test="fullScore != null">full_score = #{fullScore},</if>
            <if test="rule != null">rule = #{rule},</if>
            <if test="problemLevelOne != null">problem_level_one = #{problemLevelOne},</if>
            <if test="problemLevelTwo != null">problem_level_two = #{problemLevelTwo},</if>
            <if test="status != null">status = #{status},</if>
            <if test="statusByUserId != null">status_by_user_id = #{statusByUserId},</if>
            <if test="statusByUserName != null">status_by_user_name = #{statusByUserName},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <!--
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            -->
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <!--<if test="createUserId != null">create_user_id = #{createUserId},</if>-->
            <if test="statusReason != null and statusReason != ''">status_reason = #{statusReason},</if>
            <if test="statusApproveTime != null">status_approve_time = #{statusApproveTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePostAssessmentRulesById" parameterType="Long">
        delete from post_assessment_rules where id = #{id}
    </delete>

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