<?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.style24.admin.biz.dao.TsaDisplayDao">

	<!-- 카테고리관리 목록 -->
	<select id="getCategoryList" parameterType="Category" resultType="Category">
		/* TsaDisplay.getCategoryList */
		<if test='selLvl != null and selLvl != ""'>
		<choose>
		<when test='selLvl == "1"'>
		SELECT SITE_CD
		     , CATE_GB
		     , '' AS CATE1_NO
		     , '' AS CATE2_NO
		     , '' AS CATE3_NO
		     , '' AS CATE4_NO
		     , '' AS CATE5_NO
		     , '' AS CATE_NO
		     , '' AS CATE_NM
		     , '' AS CATE_TYPE     /*카테고리유형*/
		     , 'N' AS LEAF_YN      /*단말여부*/
		     , '' AS DISP_ORD      /*우선순위*/
		     , '' AS FORMAL_GB     /*정상이월구분*/
		     , '' AS CONTENTS_LOC  /*컨텐츠위치코드*/
		     , 'N' AS DISP_YN   /*전시여부*/
		     , 'Y' AS USE_YN   /*사용여부*/
		FROM TB_CATE1
		WHERE SITE_CD =  #{siteCd}
		AND USE_YN = 'Y'
		GROUP BY SITE_CD, CATE_GB
		</when>
		<otherwise>
		SELECT SITE_CD
		     , CATE_GB
		     , CATE1_NO
		     <if test='selLvl == "2"'>
		     , '' AS CATE2_NO
		     , '' AS CATE3_NO
		     , '' AS CATE4_NO
		     , '' AS CATE5_NO
		     , CATE1_NO AS CATE_NO     /*카테고리코드*/
		     , CATE1_NM AS CATE_NM     /*카테고리명*/
		     </if>
		     <if test='selLvl == "3"'>
		     , CATE2_NO
		     , '' AS CATE3_NO
		     , '' AS CATE4_NO
		     , '' AS CATE5_NO
		     , CATE2_NO AS CATE_NO     /*카테고리코드*/
		     , CATE2_NM AS CATE_NM     /*카테고리명*/
		     </if>
		     <if test='selLvl == "4"'>
		     , CATE2_NO
		     , CATE3_NO
		     , '' AS CATE4_NO
		     , '' AS CATE5_NO
		     , CATE3_NO AS CATE_NO     /*카테고리코드*/
		     , CATE3_NM AS CATE_NM     /*카테고리명*/
		     </if>
		     <if test='selLvl == "5"'>
		     , CATE2_NO
		     , CATE3_NO
		     , CATE4_NO
		     , '' AS CATE5_NO
		     , CATE4_NO AS CATE_NO     /*카테고리코드*/
		     , CATE4_NM AS CATE_NM     /*카테고리명*/
		     </if>
		     <if test='selLvl == "6"'>
		     , CATE2_NO
		     , CATE3_NO
		     , CATE4_NO
		     , CATE5_NO
		     , CATE5_NO AS CATE_NO     /*카테고리코드*/
		     , CATE5_NM AS CATE_NM     /*카테고리명*/
		     </if>
		     , CATE_TYPE    /*카테고리유형*/
		     , LEAF_YN      /*단말여부*/
		     , DISP_ORD     /*우선순위*/
		     , FORMAL_GB    /*정상이월구분*/
		     , CONTENTS_LOC /*컨텐츠위치코드*/
		     , DISP_YN      /*전시여부*/
		     , USE_YN       /*사용여부*/
		<if test='selLvl == "2"'>
		  FROM TB_CATE1
		 WHERE SITE_CD = #{siteCd}
		   AND CATE_GB = #{cateGb}
		</if>
		<if test='selLvl == "3"'>
		  FROM TB_CATE2
		 WHERE SITE_CD = #{siteCd}
		   AND CATE_GB = #{cateGb}
		   AND CATE1_NO = #{cate1No}
		</if>
		<if test='selLvl == "4"'>
		  FROM TB_CATE3
		 WHERE SITE_CD = #{siteCd}
		   AND CATE_GB = #{cateGb}
		   AND CATE1_NO = #{cate1No}
		   AND CATE2_NO = #{cate2No}
		</if>
		<if test='selLvl == "5"'>
		  FROM TB_CATE4
		 WHERE SITE_CD = #{siteCd}
		   AND CATE_GB = #{cateGb}
		   AND CATE1_NO = #{cate1No}
		   AND CATE2_NO = #{cate2No}
		   AND CATE3_NO = #{cate3No}
		</if>
		<if test='selLvl == "6"'>
		  FROM TB_CATE5
		 WHERE SITE_CD = #{siteCd}
		   AND CATE_GB = #{cateGb}
		   AND CATE1_NO = #{cate1No}
		   AND CATE2_NO = #{cate2No}
		   AND CATE3_NO = #{cate3No}
		   AND CATE4_NO = #{cate4No}
		</if>
		 ORDER BY SITE_CD, DISP_ORD
		</otherwise>
		</choose>
		</if>
	</select>
	
</mapper>