<?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.zehong.system.mapper.THiddenTroubleAssessmentMapper">
    
    <resultMap type="THiddenTroubleAssessment" id="THiddenTroubleAssessmentResult">
        <result property="assessmentId"    column="assessment_id"    />
        <result property="workId"    column="work_id"    />
        <result property="checkFeedback"    column="check_feedback"    />
        <result property="checkUrl"    column="check_url"    />
        <result property="checkTime"    column="check_time"    />
        <result property="checkUser"    column="check_user"    />
        <result property="assessmentContent"    column="assessment_content"    />
        <result property="assessmentTime"    column="assessment_time"    />
        <result property="assessmentUser"    column="assessment_user"    />
        <result property="assessmentLevel"    column="assessment_level"    />
        <result property="isModify"    column="is_modify"    />
        <result property="modifyOpinion"    column="modify_opinion"    />
        <result property="modifyPeople"    column="modify_people"    />
        <result property="modifyPhone"    column="modify_phone"    />
        <result property="modifyTerm"    column="modify_term"    />
        <result property="modifyBegin"    column="modify_begin"    />
        <result property="modifyEnd"    column="modify_end"    />
        <result property="modifyComplete"    column="modify_complete"    />
    </resultMap>

    <sql id="selectTHiddenTroubleAssessmentVo">
        select assessment_id, work_id, check_feedback, check_url, check_time, check_user, assessment_content, assessment_time, assessment_user, assessment_level, is_modify, modify_opinion, modify_people, modify_phone, modify_term, modify_begin, modify_end, modify_complete from t_hidden_trouble_assessment
    </sql>

    <select id="selectTHiddenTroubleAssessmentList" parameterType="THiddenTroubleAssessment" resultMap="THiddenTroubleAssessmentResult">
        <include refid="selectTHiddenTroubleAssessmentVo"/>
        <where>  
            <if test="assessmentLevel != null "> and assessment_level = #{assessmentLevel}</if>
        </where>
    </select>
    
    <select id="selectTHiddenTroubleAssessmentById" parameterType="Long" resultMap="THiddenTroubleAssessmentResult">
        <include refid="selectTHiddenTroubleAssessmentVo"/>
        where assessment_id = #{assessmentId}
    </select>
    <select id="selectTHiddenTroubleAssessmentByWorkId" parameterType="Long" resultMap="THiddenTroubleAssessmentResult">
        <include refid="selectTHiddenTroubleAssessmentVo"/>
        where work_id = #{workId}
    </select>

    <insert id="insertTHiddenTroubleAssessment" parameterType="THiddenTroubleAssessment" useGeneratedKeys="true" keyProperty="assessmentId">
        insert into t_hidden_trouble_assessment
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="workId != null">work_id,</if>
            <if test="checkFeedback != null">check_feedback,</if>
            <if test="checkUrl != null">check_url,</if>
            <if test="checkTime != null">check_time,</if>
            <if test="checkUser != null">check_user,</if>
            <if test="assessmentContent != null">assessment_content,</if>
            <if test="assessmentTime != null">assessment_time,</if>
            <if test="assessmentUser != null">assessment_user,</if>
            <if test="assessmentLevel != null">assessment_level,</if>
            <if test="isModify != null">is_modify,</if>
            <if test="modifyOpinion != null">modify_opinion,</if>
            <if test="modifyPeople != null">modify_people,</if>
            <if test="modifyPhone != null">modify_phone,</if>
            <if test="modifyTerm != null">modify_term,</if>
            <if test="modifyBegin != null">modify_begin,</if>
            <if test="modifyEnd != null">modify_end,</if>
            <if test="modifyComplete != null">modify_complete,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="workId != null">#{workId},</if>
            <if test="checkFeedback != null">#{checkFeedback},</if>
            <if test="checkUrl != null">#{checkUrl},</if>
            <if test="checkTime != null">#{checkTime},</if>
            <if test="checkUser != null">#{checkUser},</if>
            <if test="assessmentContent != null">#{assessmentContent},</if>
            <if test="assessmentTime != null">#{assessmentTime},</if>
            <if test="assessmentUser != null">#{assessmentUser},</if>
            <if test="assessmentLevel != null">#{assessmentLevel},</if>
            <if test="isModify != null">#{isModify},</if>
            <if test="modifyOpinion != null">#{modifyOpinion},</if>
            <if test="modifyPeople != null">#{modifyPeople},</if>
            <if test="modifyPhone != null">#{modifyPhone},</if>
            <if test="modifyTerm != null">#{modifyTerm},</if>
            <if test="modifyBegin != null">#{modifyBegin},</if>
            <if test="modifyEnd != null">#{modifyEnd},</if>
            <if test="modifyComplete != null">#{modifyComplete},</if>
         </trim>
    </insert>

    <update id="updateTHiddenTroubleAssessment" parameterType="THiddenTroubleAssessment">
        update t_hidden_trouble_assessment
        <trim prefix="SET" suffixOverrides=",">
            <if test="workId != null">work_id = #{workId},</if>
            <if test="checkFeedback != null">check_feedback = #{checkFeedback},</if>
            <if test="checkUrl != null">check_url = #{checkUrl},</if>
            <if test="checkTime != null">check_time = #{checkTime},</if>
            <if test="checkUser != null">check_user = #{checkUser},</if>
            <if test="assessmentContent != null">assessment_content = #{assessmentContent},</if>
            <if test="assessmentTime != null">assessment_time = #{assessmentTime},</if>
            <if test="assessmentUser != null">assessment_user = #{assessmentUser},</if>
            <if test="assessmentLevel != null">assessment_level = #{assessmentLevel},</if>
            <if test="isModify != null">is_modify = #{isModify},</if>
            <if test="modifyOpinion != null">modify_opinion = #{modifyOpinion},</if>
            <if test="modifyPeople != null">modify_people = #{modifyPeople},</if>
            <if test="modifyPhone != null">modify_phone = #{modifyPhone},</if>
            <if test="modifyTerm != null">modify_term = #{modifyTerm},</if>
            <if test="modifyBegin != null">modify_begin = #{modifyBegin},</if>
            <if test="modifyEnd != null">modify_end = #{modifyEnd},</if>
            <if test="modifyComplete != null">modify_complete = #{modifyComplete},</if>
        </trim>
        where assessment_id = #{assessmentId}
    </update>

    <delete id="deleteTHiddenTroubleAssessmentById" parameterType="Long">
        delete from t_hidden_trouble_assessment where assessment_id = #{assessmentId}
    </delete>

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