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

    <resultMap type="com.zehong.system.domain.TDangersRectifications" id="TDangersRectificationsResult">
        <result property="id"    column="id"    />
        <result property="fHazardId"    column="f_hazard_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="riskLevel"    column="risk_level"    />
        <result property="rectificationMeasures"    column="rectification_measures"    />
        <result property="hazardDescription"    column="hazard_description"    />
        <result property="completionTime"    column="completion_time"    />
        <result property="fileUrl"    column="file_url"    />
    </resultMap>

    <sql id="selectTDangersRectificationsVo">
        select id, f_hazard_id, create_time, risk_level, rectification_measures, hazard_description, completion_time, file_url from t_dangers_rectifications
    </sql>

    <select id="selectTDangersRectificationsList" parameterType="com.zehong.system.domain.TDangersRectifications" resultMap="TDangersRectificationsResult">
        <include refid="selectTDangersRectificationsVo"/>
        <where>
            <if test="fHazardId != null "> and f_hazard_id = #{fHazardId}</if>
            <if test="riskLevel != null  and riskLevel != ''"> and risk_level = #{riskLevel}</if>
            <if test="rectificationMeasures != null  and rectificationMeasures != ''"> and rectification_measures = #{rectificationMeasures}</if>
            <if test="hazardDescription != null  and hazardDescription != ''"> and hazard_description = #{hazardDescription}</if>
            <if test="completionTime != null "> and completion_time = #{completionTime}</if>
            <if test="fileUrl != null  and fileUrl != ''"> and file_url = #{fileUrl}</if>
        </where>
    </select>

    <select id="selectTDangersRectificationsById" parameterType="Long" resultMap="TDangersRectificationsResult">
        <include refid="selectTDangersRectificationsVo"/>
        where id = #{id}
    </select>

    <insert id="insertTDangersRectifications" parameterType="com.zehong.system.domain.TDangersRectifications" useGeneratedKeys="true" keyProperty="id">
        insert into t_dangers_rectifications
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fHazardId != null">f_hazard_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="riskLevel != null">risk_level,</if>
            <if test="rectificationMeasures != null">rectification_measures,</if>
            <if test="hazardDescription != null">hazard_description,</if>
            <if test="completionTime != null">completion_time,</if>
            <if test="fileUrl != null">file_url,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fHazardId != null">#{fHazardId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="riskLevel != null">#{riskLevel},</if>
            <if test="rectificationMeasures != null">#{rectificationMeasures},</if>
            <if test="hazardDescription != null">#{hazardDescription},</if>
            <if test="completionTime != null">#{completionTime},</if>
            <if test="fileUrl != null">#{fileUrl},</if>
        </trim>
    </insert>

    <update id="updateTDangersRectifications" parameterType="com.zehong.system.domain.TDangersRectifications">
        update t_dangers_rectifications
        <trim prefix="SET" suffixOverrides=",">
            <if test="fHazardId != null">f_hazard_id = #{fHazardId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="riskLevel != null">risk_level = #{riskLevel},</if>
            <if test="rectificationMeasures != null">rectification_measures = #{rectificationMeasures},</if>
            <if test="hazardDescription != null">hazard_description = #{hazardDescription},</if>
            <if test="completionTime != null">completion_time = #{completionTime},</if>
            <if test="fileUrl != null">file_url = #{fileUrl},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTDangersRectificationsById" parameterType="Long">
        delete from t_dangers_rectifications where id = #{id}
    </delete>

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