<?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="Menu">

	<resultMap id="menuResult" type="menuVO">
		<result property="id" column="ID" />
		<result property="name" column="NAME" />
		<result property="engName" column="ENG_NAME" />
		<result property="parent" column="PARENT" />
		<result property="depth" column="DEPTH" />
		<result property="url" column="URL" />
		<result property="visible" column="VISIBLE" />
		<result property="urlGroup" column="URL_GROUP" />
		<result property="subVisible" column="SUB_VISIBLE" />
		<result property="roleLevel" column="ROLE_LEVEL" />
		<result property="urlQuery" column="URL_QUERY" />
		<result property="boardId" column="BOARD_ID" />
		<result property="windowTarget" column="WINDOW_TARGET" />
	</resultMap>

	<select id="Menu.selectMemuList" parameterType="menuVO" resultMap="menuResult">
	/* Menu.selectMemuList */
		SELECT
			*
		FROM
			T_MENU
		WHERE
			DEPTH = #{depth}
		AND 
		 	MENU_POSITION = #{menuPosition}
		AND VISIBLE = 'Y'
		AND ROLE_LEVEL<![CDATA[ > ]]> #{roleLevel}
		ORDER BY ORD 
	</select>

	<select id="Menu.getMenuInfo" parameterType="map" resultType="egovMap">
	/* Menu.getMenuInfo */
			SELECT
			  *
			FROM
			  T_MENU
			WHERE
				URL_GROUP = #{group} AND
				URL = #{url}
			<if test="boardId != null and boardId != ''"><![CDATA[
				AND BOARD_ID = #{boardId}
			]]></if>
			<if test="query != null and query != ''"><![CDATA[
				AND URL_QUERY = #{query}
			]]></if>
			ORDER BY DEPTH DESC
			LIMIT 1	
	</select>
	
	
	<select id="Menu.getMenuInfoById" parameterType="String" resultType="egovMap">
	/* Menu.getMenuInfoById */
		SELECT
		  *
		FROM
		  T_MENU
		WHERE
			ID = #{id}
	</select>
	
	<select id="Menu.getMenuInfoByParentId" parameterType="map" resultType="egovMap">
	/* Menu.getMenuInfoByParentId */
		SELECT
		  *
		FROM
		  T_MENU
		WHERE
			PARENT = #{id}
		AND ROLE_LEVEL<![CDATA[ > ]]> #{roleLevel}
		ORDER BY ORD
		LIMIT 1
	</select>
	
	<select id="Menu.getSubMenu" parameterType="map" resultMap="menuResult">
	/* Menu.getSubMenu */
		SELECT
			*
		FROM
			T_MENU
		WHERE
		 	MENU_POSITION = 'SUB'
		AND PARENT = #{parent}
		AND VISIBLE = 'Y'
		AND ROLE_LEVEL<![CDATA[ > ]]> #{roleLevel}
		ORDER BY ORD 
	</select>
	
	
	<select id="Menu.getTopMenu" parameterType="map" resultMap="menuResult">
	/* Menu.getTopMenu */
		SELECT
			*
		FROM
			T_MENU
		WHERE
		SUB_VISIBLE = 'Y'
		AND ROLE_LEVEL<![CDATA[ > ]]> #{roleLevel}
		ORDER BY ORD 
	</select>
	
	
</mapper>
