<?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.TDictMajorBuildingMapper">
    <resultMap type="com.goldenwater.slaj.hazard.domain.TDictMajorBuilding" id="TDictMajorBuildingResult">
        <result property="guid" column="guid"/>
        <result property="type" column="type"/>
        <result property="project" column="project"/>
        <result property="major" column="major"/>
        <result property="majorName" column="major_name"/>
        <result property="l" column="l"/>
        <result property="e" column="e"/>
        <result property="c" column="c"/>
        <result property="d" column="d"/>
        <result property="riskLevel" column="risk_level"/>
        <result property="version" column="version"/>
        <result property="accident" column="accident"/>
        <result property="riskMethod" column="risk_method"/>
    </resultMap>
    <sql id="selectTDictMajorBuildingVo">
        select guid, type, project, major, major_name, l, e, c, d, risk_level, version, accident, risk_method
        from t_dict_major_building
    </sql>
    <select id="selectTDictMajorBuildingByGuid" parameterType="String" resultMap="TDictMajorBuildingResult">
        <include refid="selectTDictMajorBuildingVo"/>
        where guid = #{guid}
    </select>
    <select id="selectTDictMajorBuildingList" parameterType="com.goldenwater.slaj.hazard.domain.TDictMajorBuilding" resultMap="TDictMajorBuildingResult">
        <include refid="selectTDictMajorBuildingVo"/>
        <where>
            <if test="type != null and type != ''">AND type like '%' || #{type} || '%'</if>
            <if test="project != null and project != ''">AND project like '%' || #{project} || '%'</if>
            <if test="major != null and major != ''">AND major like '%' || #{major} || '%'</if>
            <if test="majorName != null and majorName != ''">AND major_name = #{majorName}</if>
            <if test="l != null and l != ''">AND l = #{l}</if>
            <if test="e != null and e != ''">AND e = #{e}</if>
            <if test="c != null and c != ''">AND c = #{c}</if>
            <if test="d != null and d != ''">AND d = #{d}</if>
            <if test="riskLevel != null and riskLevel != ''">AND risk_level = #{riskLevel}</if>
            <if test="version != null and version != ''">AND version = #{version}</if>
        </where>
    </select>
    <insert id="insertTDictMajorBuilding" parameterType="com.goldenwater.slaj.hazard.domain.TDictMajorBuilding">
        insert into t_dict_major_building (
            guid,
            type,
            project,
            major,
            major_name,
            l,
            e,
            c,
            d,
            risk_level,
            version,
            accident,
            risk_method
        ) values (
            #{guid},
            #{type},
            #{project},
            #{major},
            #{majorName},
            #{l},
            #{e},
            #{c},
            #{d},
            #{riskLevel},
            #{version},
            #{accident},
            #{riskMethod}
        )
    </insert>
    <update id="updateTDictMajorBuilding" parameterType="com.goldenwater.slaj.hazard.domain.TDictMajorBuilding">
        update t_dict_major_building
        <set>
            <if test="type != null">type = #{type},</if>
            <if test="project != null">project = #{project},</if>
            <if test="major != null">major = #{major},</if>
            <if test="majorName != null">major_name = #{majorName},</if>
            <if test="l != null">l = #{l},</if>
            <if test="e != null">e = #{e},</if>
            <if test="c != null">c = #{c},</if>
            <if test="d != null">d = #{d},</if>
            <if test="riskLevel != null">risk_level = #{riskLevel},</if>
            <if test="version != null">version = #{version},</if>
            <if test="accident != null">accident = #{accident},</if>
            <if test="riskMethod != null">risk_method = #{riskMethod},</if>
        </set>
        where guid = #{guid}
    </update>
    <delete id="deleteTDictMajorBuildingByGuid" parameterType="String">
        delete from t_dict_major_building where guid = #{guid}
    </delete>
    <delete id="deleteTDictMajorBuildingByGuids" parameterType="String">
        delete from t_dict_major_building where guid in
        <foreach item="guid" collection="array" open="(" separator="," close=")">
            #{guid}
        </foreach>
    </delete>
</mapper>
