<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">

<mapper namespace="egovframework.com.sec.ram.service.impl.AuthorManageDAO">


    <resultMap id="author" type="egovframework.com.sec.ram.service.AuthorManageVO">
        <id column="authorCode" property="authorCode"/>
        <result property="authorCode"    column="AUTHOR_CODE"     />
        <result property="authorNm"      column="AUTHOR_NM"       />
        <result property="authorDc"      column="AUTHOR_DC"       />
        <result property="authorCreatDe" column="AUTHOR_CREAT_DE" />
    </resultMap>

    <select id="selectAuthorList" 
           parameterType="egovframework.com.sec.ram.service.AuthorManageVO" 
              resultMap="author">
    
            SELECT  * 
              FROM  (
            SELECT ROWNUM RNUM, ALL_LIST.* 
              FROM  (

            SELECT
                   AUTHOR_CODE, AUTHOR_NM, AUTHOR_DC, AUTHOR_CREAT_DE
              FROM AUTH_INFO
             WHERE 1=1
        	<if test="searchKeyword != null and searchKeyword !=''">
        		 AND   AUTHOR_NM LIKE '%'||#{searchKeyword}||'%'
        	</if>
            
            ORDER BY AUTHOR_CREAT_DE DESC

                    ) ALL_LIST
                    )
	<![CDATA[                    
             WHERE  RNUM  > #{firstIndex}
               AND  RNUM <= #{firstIndex} + #{recordCountPerPage}
      ]]>
    </select>

    <insert id="insertAuthor" parameterType="egovframework.com.sec.ram.service.AuthorManage">
            INSERT INTO AUTH_INFO 
                  ( AUTHOR_CODE
                  , AUTHOR_NM
                  , AUTHOR_DC
                  , AUTHOR_CREAT_DE )
           VALUES ( #{authorCode}
                  , #{authorNm}
                  , #{authorDc}
                  , SYSDATE)
    </insert>

    <update id="updateAuthor" parameterType="egovframework.com.sec.ram.service.AuthorManage">
            UPDATE AUTH_INFO 
               SET AUTHOR_NM=#{authorNm}
                 , AUTHOR_DC=#{authorDc}
             WHERE AUTHOR_CODE=#{authorCode}
    </update>
    
    <delete id="deleteAuthor">
            DELETE FROM AUTH_INFO 
             WHERE AUTHOR_CODE=#{authorCode}
    </delete>
    
    <select id="selectAuthor"  parameterType="egovframework.com.sec.ram.service.AuthorManageVO" 
                               resultMap="author">
            SELECT AUTHOR_CODE, AUTHOR_NM, AUTHOR_DC, AUTHOR_CREAT_DE
              FROM AUTH_INFO 
             WHERE AUTHOR_CODE=#{authorCode}
    </select>
    
    <select id="selectAuthorListTotCnt" 
            parameterType="egovframework.com.sec.ram.service.AuthorManageVO" 
               resultType="int">
            SELECT COUNT(*) totcnt
            FROM AUTH_INFO
            WHERE 1=1
            <if test="searchKeyword != null and searchKeyword !=''">
                AND AUTHOR_NM LIKE '%'||#{searchKeyword}||'%'
            </if>
    </select>
    
    <select id="selectAuthorAllList" parameterType="egovframework.com.sec.ram.service.AuthorManageVO" resultMap="author">
            SELECT
                   AUTHOR_CODE, AUTHOR_NM, AUTHOR_DC, AUTHOR_CREAT_DE
              FROM AUTH_INFO
    </select>


</mapper>
