<?xml version="1.0" encoding="UTF-8"?><!--Converted at: Wed May 11 15:49:38 KST 2016-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="nlib.col.service.impl.ReadDAO">

 	<select id="listDates" parameterType="String" resultType="EgovMap">
 	<![CDATA[ 
 	   /* 희망방문일 선택 가능 기준 
         - 시작일, 종료일 : 당일부터 2주이내 날짜 선택가능
         - 단, 문화원 운영시간이 지난 경우, 익일부터 2주이내 날짜 선택가능
        */
		SELECT 
		      DT  
		    , CASE UPPER(DAYNAME(DT)) 
		        WHEN 'MONDAY'    THEN '월' 
		        WHEN 'TUESDAY'   THEN '화'
		        WHEN 'WEDNESDAY' THEN '수'
		        WHEN 'THURSDAY'  THEN '목'
		        WHEN 'FRIDAY'    THEN '금'
		      END AS DT_NAME 
		FROM (
			SELECT ADDDATE(CURDATE(), (D + W + 
			         CASE WHEN IFNULL( (SELECT CLOSED_TIME FROM SM_DEPT WHERE ORG_CD = #{orgCd}), '18:00') > DATE_FORMAT(NOW(), '%H:%i') THEN 0 
			         ELSE 1 END 
			         )
			       ) AS DT
			FROM (SELECT 0 AS D UNION SELECT 1 AS D UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6) TDAYS,
			     (SELECT 0 AS W UNION SELECT 7) TWEEKS
		) T 
		WHERE UPPER(DAYNAME(DT)) NOT IN ('SUNDAY', 'SATURDAY')
		ORDER BY DT 
    ]]>
 	</select>
 	
    <select id="listReadMngOrg" parameterType="String" resultType="EgovMap">
        SELECT DISTINCT A.MNG_ORG_CD, B.DEPT_NM AS MNG_ORG_NM
        FROM (
            SELECT DISTINCT MNG_ORG_CD
            FROM  US_REQ
            WHERE REQ_USER_ID = #{mbInfoId} 
        ) A
        JOIN SM_DEPT B ON (A.MNG_ORG_CD = B.ORG_CD)
        ORDER BY B.DEPT_NM
    </select>
    
</mapper>