<?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.TSupMajorHazardMapper">
    
    <resultMap type="TSupMajorHazard" id="TSupMajorHazardResult">
        <result property="fHazardId"    column="f_hazard_id"    />
        <result property="beyondEnterpriseId"    column="beyond_enterprise_id"    />
        <result property="fName"    column="f_name"    />
        <result property="fResPer"    column="f_res_per"    />
        <result property="fPhone"    column="f_phone"    />
        <result property="fEvaInfor"    column="f_eva_infor"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="fLevel"    column="f_level"    />
        <result property="fCreateTime"    column="f_create_time"    />
        <result property="fUpdateTime"    column="f_update_time"    />
        <result property="fIsDel"    column="f_is_del"    />
        <result property="fRemarks"    column="f_remarks"    />
    </resultMap>

    <resultMap type="TSupMajorHazard" id="ExportTSupMajorHazardResult">
        <result property="fHazardId"    column="f_hazard_id"    />
        <result property="beyondEnterpriseId"    column="beyond_enterprise_id"    />
        <result property="fName"    column="f_name"    />
        <result property="fResPer"    column="f_res_per"    />
        <result property="fPhone"    column="f_phone"    />
        <result property="fEvaInfor"    column="f_eva_infor"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="fLevel"    column="dict_label"    />
        <result property="fCreateTime"    column="f_create_time"    />
        <result property="fUpdateTime"    column="f_update_time"    />
        <result property="fIsDel"    column="f_is_del"    />
        <result property="fRemarks"    column="f_remarks"    />
    </resultMap>
    <sql id="selectTSupMajorHazardVo">
        select f_hazard_id, f_name, f_res_per, f_phone, f_eva_infor, longitude, latitude, f_level, f_create_time, f_update_time, f_is_del, f_remarks,beyond_enterprise_id from t_sup_major_hazard
    </sql>

    <sql id="exportSelectTSupMajorHazardVo">
        SELECT
            f_hazard_id,
            f_name,
            f_res_per,
            f_phone,
            f_eva_infor,
            longitude,
            latitude,
            f_level,
            f_create_time,
            f_update_time,
            f_is_del,
            f_remarks,
            beyond_enterprise_id ,
            dict_label
        FROM
            t_sup_major_hazard hazard inner join sys_dict_data dictData on hazard.f_level = dictData.dict_value and dictData.dict_type = 'major_poll_source_level'
    </sql>
    <select id="selectTSupMajorHazardList" parameterType="TSupMajorHazard" resultMap="TSupMajorHazardResult">
        <include refid="selectTSupMajorHazardVo"/>
        <where>  
            <if test="fName != null  and fName != ''"> and f_name like concat('%', #{fName}, '%')</if>
            <if test="fResPer != null  and fResPer != ''"> and f_res_per = #{fResPer}</if>
        </where>
    </select>

    <select id="exportselectTSupMajorHazardList" parameterType="TSupMajorHazard" resultMap="ExportTSupMajorHazardResult">
        <include refid="exportSelectTSupMajorHazardVo"/>
        <where>
            <if test="fName != null  and fName != ''"> and f_name like concat('%', #{fName}, '%')</if>
            <if test="fResPer != null  and fResPer != ''"> and f_res_per = #{fResPer}</if>
        </where>
    </select>
    <select id="selectTSupMajorHazardById" parameterType="Long" resultMap="TSupMajorHazardResult">
        <include refid="selectTSupMajorHazardVo"/>
        where f_hazard_id = #{fHazardId}
    </select>
        
    <insert id="insertTSupMajorHazard" parameterType="TSupMajorHazard" useGeneratedKeys="true" keyProperty="fHazardId">
        insert into t_sup_major_hazard
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fName != null">f_name,</if>
            <if test="fResPer != null">f_res_per,</if>
            <if test="fPhone != null">f_phone,</if>
            <if test="fEvaInfor != null">f_eva_infor,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
            <if test="fLevel != null">f_level,</if>
            <if test="beyondEnterpriseId != null">beyond_enterprise_id,</if>
            <if test="fCreateTime != null">f_create_time,</if>
            <if test="fUpdateTime != null">f_update_time,</if>
            <if test="fIsDel != null">f_is_del,</if>
            <if test="fRemarks != null">f_remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fName != null">#{fName},</if>
            <if test="fResPer != null">#{fResPer},</if>
            <if test="fPhone != null">#{fPhone},</if>
            <if test="fEvaInfor != null">#{fEvaInfor},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="fLevel != null">#{fLevel},</if>
            <if test="beyondEnterpriseId != null">#{beyondEnterpriseId},</if>
            <if test="fCreateTime != null">#{fCreateTime},</if>
            <if test="fUpdateTime != null">#{fUpdateTime},</if>
            <if test="fIsDel != null">#{fIsDel},</if>
            <if test="fRemarks != null">#{fRemarks},</if>
         </trim>
    </insert>

    <update id="updateTSupMajorHazard" parameterType="TSupMajorHazard">
        update t_sup_major_hazard
        <trim prefix="SET" suffixOverrides=",">
            <if test="fName != null">f_name = #{fName},</if>
            <if test="fResPer != null">f_res_per = #{fResPer},</if>
            <if test="fPhone != null">f_phone = #{fPhone},</if>
            <if test="fEvaInfor != null">f_eva_infor = #{fEvaInfor},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="fLevel != null">f_level = #{fLevel},</if>
            <if test="beyondEnterpriseId != null">beyond_enterprise_id = #{beyondEnterpriseId},</if>
            <if test="fCreateTime != null">f_create_time = #{fCreateTime},</if>
            <if test="fUpdateTime != null">f_update_time = #{fUpdateTime},</if>
            <if test="fIsDel != null">f_is_del = #{fIsDel},</if>
            <if test="fRemarks != null">f_remarks = #{fRemarks},</if>
        </trim>
        where f_hazard_id = #{fHazardId}
    </update>

    <delete id="deleteTSupMajorHazardById" parameterType="Long">
        delete from t_sup_major_hazard where f_hazard_id = #{fHazardId}
    </delete>

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