<?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.slgc.mapper.AttStBaseMapper">

    <resultMap type="AttStBase" id="AttStBaseResult">
        <result property="stCode" column="ST_CODE"/>
        <result property="collDate" column="COLL_DATE"/>
        <result property="stName" column="ST_NAME"/>
        <result property="stType" column="ST_TYPE"/>
        <result property="stLong" column="ST_LONG"/>
        <result property="stLat" column="ST_LAT"/>
        <result property="stSite" column="ST_SITE"/>
        <result property="stYearMon" column="ST_YEAR_MON"/>
        <result property="begRepoYearMon" column="BEG_REPO_YEAR_MON"/>
        <result property="bank" column="BANK"/>
        <result property="stDir" column="ST_DIR"/>
        <result property="catArea" column="CAT_AREA"/>
        <result property="moniItem" column="MONI_ITEM"/>
        <result property="note" column="NOTE"/>
        <result property="updDate" column="UPD_DATE"/>
    </resultMap>

    <sql id="selectAttStBaseVo">
        select ST_CODE, COLL_DATE, ST_NAME, ST_TYPE, ST_LONG, ST_LAT, ST_SITE, ST_YEAR_MON,
               BEG_REPO_YEAR_MON, BANK, ST_DIR, CAT_AREA, MONI_ITEM, NOTE, UPD_DATE
        from ATT_ST_BASE
    </sql>

    <select id="selectAttStBaseList" parameterType="AttStBase" resultMap="AttStBaseResult">
        <include refid="selectAttStBaseVo"/>
        <where>
            <if test="stName != null and stName != ''">
                and ST_NAME like concat('%', #{stName}, '%')
            </if>
            <if test="stType != null and stType != ''">
                and ST_TYPE = #{stType}
            </if>
            <if test="bank != null and bank != ''">
                and BANK = #{bank}
            </if>
        </where>
        order by ST_CODE
    </select>

    <select id="selectAttStBaseById" parameterType="String" resultMap="AttStBaseResult">
        <include refid="selectAttStBaseVo"/>
        where ST_CODE = #{stCode}
    </select>

    <delete id="deleteAttStBaseById" parameterType="String">
        delete from ATT_ST_BASE where ST_CODE = #{stCode}
    </delete>

    <delete id="deleteAttStBaseByIds" parameterType="String">
        delete from ATT_ST_BASE where ST_CODE in
        <foreach item="stCode" collection="array" open="(" separator="," close=")">
            #{stCode}
        </foreach>
    </delete>

    <insert id="insertAttStBase" parameterType="AttStBase">
        insert into ATT_ST_BASE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="stCode != null">ST_CODE,</if>
            <if test="collDate != null">COLL_DATE,</if>
            <if test="stName != null">ST_NAME,</if>
            <if test="stType != null">ST_TYPE,</if>
            <if test="stLong != null">ST_LONG,</if>
            <if test="stLat != null">ST_LAT,</if>
            <if test="stSite != null">ST_SITE,</if>
            <if test="stYearMon != null">ST_YEAR_MON,</if>
            <if test="begRepoYearMon != null">BEG_REPO_YEAR_MON,</if>
            <if test="bank != null">BANK,</if>
            <if test="stDir != null">ST_DIR,</if>
            <if test="catArea != null">CAT_AREA,</if>
            <if test="moniItem != null">MONI_ITEM,</if>
            <if test="note != null">NOTE,</if>
            <if test="updDate != null">UPD_DATE,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="stCode != null">#{stCode},</if>
            <if test="collDate != null">#{collDate},</if>
            <if test="stName != null">#{stName},</if>
            <if test="stType != null">#{stType},</if>
            <if test="stLong != null">#{stLong},</if>
            <if test="stLat != null">#{stLat},</if>
            <if test="stSite != null">#{stSite},</if>
            <if test="stYearMon != null">#{stYearMon},</if>
            <if test="begRepoYearMon != null">#{begRepoYearMon},</if>
            <if test="bank != null">#{bank},</if>
            <if test="stDir != null">#{stDir},</if>
            <if test="catArea != null">#{catArea},</if>
            <if test="moniItem != null">#{moniItem},</if>
            <if test="note != null">#{note},</if>
            <if test="updDate != null">#{updDate},</if>
        </trim>
    </insert>

    <update id="updateAttStBase" parameterType="AttStBase">
        update ATT_ST_BASE
        <trim prefix="SET" suffixOverrides=",">
            <if test="collDate != null">COLL_DATE = #{collDate},</if>
            <if test="stName != null">ST_NAME = #{stName},</if>
            <if test="stType != null">ST_TYPE = #{stType},</if>
            <if test="stLong != null">ST_LONG = #{stLong},</if>
            <if test="stLat != null">ST_LAT = #{stLat},</if>
            <if test="stSite != null">ST_SITE = #{stSite},</if>
            <if test="stYearMon != null">ST_YEAR_MON = #{stYearMon},</if>
            <if test="begRepoYearMon != null">BEG_REPO_YEAR_MON = #{begRepoYearMon},</if>
            <if test="bank != null">BANK = #{bank},</if>
            <if test="stDir != null">ST_DIR = #{stDir},</if>
            <if test="catArea != null">CAT_AREA = #{catArea},</if>
            <if test="moniItem != null">MONI_ITEM = #{moniItem},</if>
            <if test="note != null">NOTE = #{note},</if>
            <if test="updDate != null">UPD_DATE = #{updDate},</if>
        </trim>
        where ST_CODE = #{stCode}
    </update>

</mapper>
