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

    <resultMap type="Wry" id="WryResult">
        <result property="id" column="ID"/>
        <result property="menuNum" column="MENU_NUM"/>
        <result property="area" column="AREA"/>
        <result property="year" column="YEAR"/>
        <result property="f1" column="F1"/>
        <result property="f2" column="F2"/>
        <result property="f3" column="F3"/>
        <result property="f4" column="F4"/>
        <result property="f5" column="F5"/>
        <result property="f6" column="F6"/>
        <result property="f7" column="F7"/>
        <result property="f8" column="F8"/>
        <result property="f9" column="F9"/>
        <result property="f10" column="F10"/>
        <result property="f11" column="F11"/>
        <result property="f12" column="F12"/>
        <result property="f13" column="F13"/>
        <result property="f14" column="F14"/>
        <result property="f15" column="F15"/>
        <result property="f16" column="F16"/>
        <result property="f17" column="F17"/>
        <result property="f18" column="F18"/>
        <result property="f19" column="F19"/>
        <result property="f20" column="F20"/>
        <result property="f21" column="F21"/>
        <result property="f22" column="F22"/>
        <result property="f23" column="F23"/>
        <result property="f24" column="F24"/>
        <result property="f25" column="F25"/>
        <result property="f26" column="F26"/>
        <result property="f27" column="F27"/>
        <result property="f28" column="F28"/>
        <result property="f29" column="F29"/>
        <result property="f30" column="F30"/>
    </resultMap>

    <sql id="selectWryVo">
        select ID, MENU_NUM, AREA, YEAR,
               F1, F2, F3, F4, F5, F6, F7, F8, F9, F10,
               F11, F12, F13, F14, F15, F16, F17, F18, F19, F20,
               F21, F22, F23, F24, F25, F26, F27, F28, F29, F30
        from WRY
    </sql>

    <select id="selectWryList" parameterType="Wry" resultMap="WryResult">
        <include refid="selectWryVo"/>
        <where>
            <if test="menuNum != null and menuNum != ''"> and MENU_NUM = #{menuNum}</if>
            <if test="area != null and area != ''"> and AREA = #{area}</if>
            <if test="year != null and year != ''"> and YEAR = #{year}</if>
        </where>
        order by YEAR desc, AREA
    </select>

    <select id="selectWryById" parameterType="String" resultMap="WryResult">
        <include refid="selectWryVo"/>
        where ID = #{id}
    </select>

    <delete id="deleteWryById" parameterType="String">
        delete from WRY where ID = #{id}
    </delete>

    <delete id="deleteWryByIds" parameterType="String">
        delete from WRY where ID in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <insert id="insertWry" parameterType="Wry">
        insert into WRY
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">ID,</if>
            <if test="menuNum != null">MENU_NUM,</if>
            <if test="area != null">AREA,</if>
            <if test="year != null">YEAR,</if>
            <if test="f1 != null">F1,</if>
            <if test="f2 != null">F2,</if>
            <if test="f3 != null">F3,</if>
            <if test="f4 != null">F4,</if>
            <if test="f5 != null">F5,</if>
            <if test="f6 != null">F6,</if>
            <if test="f7 != null">F7,</if>
            <if test="f8 != null">F8,</if>
            <if test="f9 != null">F9,</if>
            <if test="f10 != null">F10,</if>
            <if test="f11 != null">F11,</if>
            <if test="f12 != null">F12,</if>
            <if test="f13 != null">F13,</if>
            <if test="f14 != null">F14,</if>
            <if test="f15 != null">F15,</if>
            <if test="f16 != null">F16,</if>
            <if test="f17 != null">F17,</if>
            <if test="f18 != null">F18,</if>
            <if test="f19 != null">F19,</if>
            <if test="f20 != null">F20,</if>
            <if test="f21 != null">F21,</if>
            <if test="f22 != null">F22,</if>
            <if test="f23 != null">F23,</if>
            <if test="f24 != null">F24,</if>
            <if test="f25 != null">F25,</if>
            <if test="f26 != null">F26,</if>
            <if test="f27 != null">F27,</if>
            <if test="f28 != null">F28,</if>
            <if test="f29 != null">F29,</if>
            <if test="f30 != null">F30,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="menuNum != null">#{menuNum},</if>
            <if test="area != null">#{area},</if>
            <if test="year != null">#{year},</if>
            <if test="f1 != null">#{f1},</if>
            <if test="f2 != null">#{f2},</if>
            <if test="f3 != null">#{f3},</if>
            <if test="f4 != null">#{f4},</if>
            <if test="f5 != null">#{f5},</if>
            <if test="f6 != null">#{f6},</if>
            <if test="f7 != null">#{f7},</if>
            <if test="f8 != null">#{f8},</if>
            <if test="f9 != null">#{f9},</if>
            <if test="f10 != null">#{f10},</if>
            <if test="f11 != null">#{f11},</if>
            <if test="f12 != null">#{f12},</if>
            <if test="f13 != null">#{f13},</if>
            <if test="f14 != null">#{f14},</if>
            <if test="f15 != null">#{f15},</if>
            <if test="f16 != null">#{f16},</if>
            <if test="f17 != null">#{f17},</if>
            <if test="f18 != null">#{f18},</if>
            <if test="f19 != null">#{f19},</if>
            <if test="f20 != null">#{f20},</if>
            <if test="f21 != null">#{f21},</if>
            <if test="f22 != null">#{f22},</if>
            <if test="f23 != null">#{f23},</if>
            <if test="f24 != null">#{f24},</if>
            <if test="f25 != null">#{f25},</if>
            <if test="f26 != null">#{f26},</if>
            <if test="f27 != null">#{f27},</if>
            <if test="f28 != null">#{f28},</if>
            <if test="f29 != null">#{f29},</if>
            <if test="f30 != null">#{f30},</if>
        </trim>
    </insert>

    <update id="updateWry" parameterType="Wry">
        update WRY
        <trim prefix="SET" suffixOverrides=",">
            <if test="menuNum != null">MENU_NUM = #{menuNum},</if>
            <if test="area != null">AREA = #{area},</if>
            <if test="year != null">YEAR = #{year},</if>
            <if test="f1 != null">F1 = #{f1},</if>
            <if test="f2 != null">F2 = #{f2},</if>
            <if test="f3 != null">F3 = #{f3},</if>
            <if test="f4 != null">F4 = #{f4},</if>
            <if test="f5 != null">F5 = #{f5},</if>
            <if test="f6 != null">F6 = #{f6},</if>
            <if test="f7 != null">F7 = #{f7},</if>
            <if test="f8 != null">F8 = #{f8},</if>
            <if test="f9 != null">F9 = #{f9},</if>
            <if test="f10 != null">F10 = #{f10},</if>
            <if test="f11 != null">F11 = #{f11},</if>
            <if test="f12 != null">F12 = #{f12},</if>
            <if test="f13 != null">F13 = #{f13},</if>
            <if test="f14 != null">F14 = #{f14},</if>
            <if test="f15 != null">F15 = #{f15},</if>
            <if test="f16 != null">F16 = #{f16},</if>
            <if test="f17 != null">F17 = #{f17},</if>
            <if test="f18 != null">F18 = #{f18},</if>
            <if test="f19 != null">F19 = #{f19},</if>
            <if test="f20 != null">F20 = #{f20},</if>
            <if test="f21 != null">F21 = #{f21},</if>
            <if test="f22 != null">F22 = #{f22},</if>
            <if test="f23 != null">F23 = #{f23},</if>
            <if test="f24 != null">F24 = #{f24},</if>
            <if test="f25 != null">F25 = #{f25},</if>
            <if test="f26 != null">F26 = #{f26},</if>
            <if test="f27 != null">F27 = #{f27},</if>
            <if test="f28 != null">F28 = #{f28},</if>
            <if test="f29 != null">F29 = #{f29},</if>
            <if test="f30 != null">F30 = #{f30},</if>
        </trim>
        where ID = #{id}
    </update>

</mapper>
