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

    <resultMap type="ObjWaga" id="ObjWagaResult">
        <result property="wagaCode" column="WAGA_CODE"/>
        <result property="wagaName" column="WAGA_NAME"/>
        <result property="fromDate" column="FROM_DATE"/>
        <result property="toDate" column="TO_DATE"/>
    </resultMap>

    <sql id="selectObjWagaVo">
        select WAGA_CODE, WAGA_NAME, FROM_DATE, TO_DATE from OBJ_WAGA
    </sql>

    <select id="selectObjWagaList" parameterType="ObjWaga" resultMap="ObjWagaResult">
        <include refid="selectObjWagaVo"/>
        <where>
            <if test="wagaName != null and wagaName != ''">
                and WAGA_NAME like concat('%', #{wagaName}, '%')
            </if>
        </where>
        order by WAGA_CODE
    </select>

    <select id="selectObjWagaById" parameterType="String" resultMap="ObjWagaResult">
        <include refid="selectObjWagaVo"/>
        where WAGA_CODE = #{wagaCode}
    </select>

    <delete id="deleteObjWagaById" parameterType="String">
        delete from OBJ_WAGA where WAGA_CODE = #{wagaCode}
    </delete>

    <insert id="insertObjWaga" parameterType="ObjWaga">
        insert into OBJ_WAGA
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="wagaCode != null">WAGA_CODE,</if>
            <if test="wagaName != null">WAGA_NAME,</if>
            <if test="fromDate != null">FROM_DATE,</if>
            <if test="toDate != null">TO_DATE,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="wagaCode != null">#{wagaCode},</if>
            <if test="wagaName != null">#{wagaName},</if>
            <if test="fromDate != null">#{fromDate},</if>
            <if test="toDate != null">#{toDate},</if>
        </trim>
    </insert>

    <update id="updateObjWaga" parameterType="ObjWaga">
        update OBJ_WAGA
        <trim prefix="SET" suffixOverrides=",">
            <if test="wagaName != null">WAGA_NAME = #{wagaName},</if>
            <if test="fromDate != null">FROM_DATE = #{fromDate},</if>
            <if test="toDate != null">TO_DATE = #{toDate},</if>
        </trim>
        where WAGA_CODE = #{wagaCode}
    </update>

</mapper>
