<?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.goldenwater.slaj.hazard.mapper.MwrHazMapper">
    <resultMap type="com.goldenwater.slaj.hazard.domain.MwrHaz" id="MwrHazResult">
        <result property="guid" column="guid"/>
        <result property="hazName" column="haz_name"/>
        <result property="orgName" column="org_name"/>
        <result property="engName" column="eng_name"/>
        <result property="hiddGrad" column="hidd_grad"/>
        <result property="ifLiceNoti" column="if_lice_noti"/>
        <result property="prec" column="prec"/>
        <result property="evaeDate" column="evae_date"/>
        <result property="collTime" column="coll_time"/>
    </resultMap>
    <sql id="selectMwrHazVo">
        select guid, haz_name, org_name, eng_name, hidd_grad, if_lice_noti,
               prec, evae_date, coll_time
        from mwr_haz
    </sql>
    <select id="selectMwrHazByGuid" parameterType="String" resultMap="MwrHazResult">
        <include refid="selectMwrHazVo"/>
        where guid = #{guid}
    </select>
    <select id="selectMwrHazList" parameterType="com.goldenwater.slaj.hazard.domain.MwrHaz" resultMap="MwrHazResult">
        <include refid="selectMwrHazVo"/>
        <where>
            <if test="hazName != null and hazName != ''">AND haz_name like '%' || #{hazName} || '%'</if>
            <if test="orgName != null and orgName != ''">AND org_name like '%' || #{orgName} || '%'</if>
            <if test="guid != null and guid != ''">AND guid = #{guid}</if>
        </where>
    </select>
    <insert id="insertMwrHaz" parameterType="com.goldenwater.slaj.hazard.domain.MwrHaz">
        insert into mwr_haz (
            guid, haz_name, org_name, eng_name, hidd_grad, if_lice_noti,
            prec, evae_date, coll_time
        ) values (
            #{guid}, #{hazName}, #{orgName}, #{engName}, #{hiddGrad}, #{ifLiceNoti},
            #{prec}, #{evaeDate}, #{collTime}
        )
    </insert>
    <update id="updateMwrHaz" parameterType="com.goldenwater.slaj.hazard.domain.MwrHaz">
        update mwr_haz
        <set>
            <if test="hazName != null">haz_name = #{hazName},</if>
            <if test="orgName != null">org_name = #{orgName},</if>
            <if test="engName != null">eng_name = #{engName},</if>
            <if test="hiddGrad != null">hidd_grad = #{hiddGrad},</if>
            <if test="ifLiceNoti != null">if_lice_noti = #{ifLiceNoti},</if>
            <if test="prec != null">prec = #{prec},</if>
            <if test="evaeDate != null">evae_date = #{evaeDate},</if>
            <if test="collTime != null">coll_time = #{collTime},</if>
        </set>
        where guid = #{guid}
    </update>
    <delete id="deleteMwrHazByGuid" parameterType="String">
        delete from mwr_haz where guid = #{guid}
    </delete>
    <delete id="deleteMwrHazByGuids" parameterType="String">
        delete from mwr_haz where guid in
        <foreach item="guid" collection="array" open="(" separator="," close=")">
            #{guid}
        </foreach>
    </delete>
</mapper>
