<?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.ObjPustMapper">

    <resultMap type="ObjPust" id="ObjPustResult">
        <result property="pustCode" column="PUST_CODE"/>
        <result property="pustName" column="PUST_NAME"/>
        <result property="fromDate" column="FROM_DATE"/>
        <result property="toDate" column="TO_DATE"/>
    </resultMap>

    <sql id="selectObjPustVo">
        select PUST_CODE, PUST_NAME, FROM_DATE, TO_DATE from OBJ_PUST
    </sql>

    <select id="selectObjPustList" parameterType="ObjPust" resultMap="ObjPustResult">
        <include refid="selectObjPustVo"/>
        <where>
            <if test="pustName != null and pustName != ''">
                and PUST_NAME like concat('%', #{pustName}, '%')
            </if>
        </where>
        order by PUST_CODE
    </select>

    <select id="selectObjPustById" parameterType="String" resultMap="ObjPustResult">
        <include refid="selectObjPustVo"/>
        where PUST_CODE = #{pustCode}
    </select>

    <delete id="deleteObjPustById" parameterType="String">
        delete from OBJ_PUST where PUST_CODE = #{pustCode}
    </delete>

    <insert id="insertObjPust" parameterType="ObjPust">
        insert into OBJ_PUST
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="pustCode != null">PUST_CODE,</if>
            <if test="pustName != null">PUST_NAME,</if>
            <if test="fromDate != null">FROM_DATE,</if>
            <if test="toDate != null">TO_DATE,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="pustCode != null">#{pustCode},</if>
            <if test="pustName != null">#{pustName},</if>
            <if test="fromDate != null">#{fromDate},</if>
            <if test="toDate != null">#{toDate},</if>
        </trim>
    </insert>

    <update id="updateObjPust" parameterType="ObjPust">
        update OBJ_PUST
        <trim prefix="SET" suffixOverrides=",">
            <if test="pustName != null">PUST_NAME = #{pustName},</if>
            <if test="fromDate != null">FROM_DATE = #{fromDate},</if>
            <if test="toDate != null">TO_DATE = #{toDate},</if>
        </trim>
        where PUST_CODE = #{pustCode}
    </update>

</mapper>
