<?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.hidd.mapper.AttOrgBaseMapper">
    <resultMap type="com.goldenwater.slaj.hidd.domain.AttOrgBase" id="AttOrgBaseResult">
        <result property="guid" column="guid"/>
        <result property="pguid" column="pguid"/>
        <result property="orgCode" column="org_code"/>
        <result property="orgName" column="org_name"/>
        <result property="orgLevel" column="org_level"/>
        <result property="orgGrad" column="org_grad"/>
        <result property="orgType" column="org_type"/>
        <result property="ordernum" column="ordernum"/>
        <result property="adCode" column="ad_code"/>
        <result property="status" column="status"/>
        <result property="modifier" column="modifier"/>
        <result property="fromDate" column="from_date"/>
        <result property="toDate" column="to_date"/>
        <result property="note" column="note"/>
        <result property="jurd" column="jurd"/>
        <result property="areaType" column="area_type"/>
        <result property="nodeCode" column="node_code"/>
    </resultMap>
    <sql id="selectAttOrgBaseVo">
        select guid, pguid, org_code, org_name, org_level, org_grad, org_type, ordernum,
               ad_code, status, modifier, from_date, to_date, note, jurd, area_type, node_code
        from att_org_base
    </sql>
    <select id="selectAttOrgBaseByGuid" parameterType="String" resultMap="AttOrgBaseResult">
        <include refid="selectAttOrgBaseVo"/>
        where guid = #{guid}
    </select>
    <select id="selectAttOrgBaseList" parameterType="com.goldenwater.slaj.hidd.domain.AttOrgBase" resultMap="AttOrgBaseResult">
        select b.guid, b.pguid, b.org_code, b.org_name, b.org_level, b.org_grad, b.org_type, b.ordernum,
               b.ad_code, b.status, b.modifier, b.from_date, b.to_date, b.note, b.jurd, b.area_type, b.node_code
        from att_org_base b
        <where>
            <if test="orgName != null and orgName != ''">AND b.org_name like '%' || #{orgName} || '%'</if>
            <if test="orgCode != null and orgCode != ''">AND b.org_code = #{orgCode}</if>
            <if test="pguid != null and pguid != ''">AND b.pguid = #{pguid}</if>
            <if test="wiunProp != null and wiunProp != ''">AND EXISTS (SELECT 1 FROM att_org_ext ext WHERE ext.org_guid = b.guid AND ext.wiun_prop = #{wiunProp})</if>
        </where>
    </select>
    <insert id="insertAttOrgBase" parameterType="com.goldenwater.slaj.hidd.domain.AttOrgBase">
        insert into att_org_base (guid, pguid, org_code, org_name, org_level, org_grad, org_type, ordernum, ad_code, status, modifier, from_date, to_date, note, jurd, area_type, node_code)
        values (#{guid}, #{pguid}, #{orgCode}, #{orgName}, #{orgLevel}, #{orgGrad}, #{orgType}, #{ordernum}, #{adCode}, #{status}, #{modifier}, #{fromDate}, #{toDate}, #{note}, #{jurd}, #{areaType}, #{nodeCode}, )
    </insert>
    <update id="updateAttOrgBase" parameterType="com.goldenwater.slaj.hidd.domain.AttOrgBase">
        update att_org_base
        <set>
            <if test="pguid != null">pguid = #{pguid},</if>
            <if test="orgCode != null">org_code = #{orgCode},</if>
            <if test="orgName != null">org_name = #{orgName},</if>
            <if test="orgLevel != null">org_level = #{orgLevel},</if>
            <if test="orgGrad != null">org_grad = #{orgGrad},</if>
            <if test="orgType != null">org_type = #{orgType},</if>
            <if test="ordernum != null">ordernum = #{ordernum},</if>
            <if test="adCode != null">ad_code = #{adCode},</if>
            <if test="status != null">status = #{status},</if>
            <if test="modifier != null">modifier = #{modifier},</if>
            <if test="fromDate != null">from_date = #{fromDate},</if>
            <if test="toDate != null">to_date = #{toDate},</if>
            <if test="note != null">note = #{note},</if>
            <if test="jurd != null">jurd = #{jurd},</if>
            <if test="areaType != null">area_type = #{areaType},</if>
            <if test="nodeCode != null">node_code = #{nodeCode},</if>
        </set>
        where guid = #{guid}
    </update>
    <delete id="deleteAttOrgBaseByGuid" parameterType="String">
        delete from att_org_base where guid = #{guid}
    </delete>
    <delete id="deleteAttOrgBaseByGuids" parameterType="String">
        delete from att_org_base where guid in
        <foreach item="guid" collection="array" open="(" separator="," close=")">
            #{guid}
        </foreach>
    </delete>
</mapper>
