<?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.dbnt.kcscbackend.admin.config.mapper.TcMenuMapper">

	<select id="selectMenuList" resultType="TcMenu">
		select a.menu_id,
					 a.menu_title,
					 a.role_grp_id,
					 a.menu_group,
					 a.menu_level,
					 a.menu_sort,
					 a.menu_url,
					 a.menu_type_cd,
					 a.use_yn,
					 a.frst_crt_id,
					 a.frst_crt_dt,
					 a.last_chg_id,
					 a.last_chg_dt,
					 b.item_nm as menu_type_value
		from tc_menu a
				inner join tc_code_item b on a.menu_type_cd = b.item_cd
		where a.use_yn = 'Y'
		order by menu_id asc
	</select>

	<select id="selectMenuAuthList" resultType="TcMenu">
		select a.menu_id ,
					 a.menu_title ,
					 a.menu_group ,
					 coalesce(b.role_cd, '') as menu_auth
		from tc_menu a
					 left outer join (
								select menu_id , string_agg(role_id, ',') as role_cd
								from tb_menu_role
								group by menu_id
						) b on a.menu_id  = b.menu_id
		where a.use_yn = 'Y'
		order by a.menu_id asc
	</select>
</mapper>