<?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="WebPublicHoliday">
	
	<!-- 공휴일 total count 조회 -->
	<select id="selectListPublicHolidayDate" parameterType="hashmap" resultType="hashmap">
		SELECT MU_PUBLIC_HOLIDAY_ID   AS "muPublicHolidayId"
		  FROM MU_PUBLIC_HOLIDAY KPH
		 WHERE USE_YN = 'Y'
		   AND LOC_DATE = #{locDate}
	</select>
	
	<!-- 공휴일 등록  -->
	<insert id="insertPublicHoliday" parameterType="hashmap">
		<selectKey resultType="string" keyProperty="id" order="BEFORE">
			SELECT CONCAT(#{muPublicHolidayId},LPAD((SELECT NEXTVAL(MU_PUBLIC_HOLIDAY_SEQ)), 10, 0))
		</selectKey>
		INSERT INTO MU_PUBLIC_HOLIDAY(
					 MU_PUBLIC_HOLIDAY_ID
					,PUBLIC_HOLIDAY_NAME
					,LOC_DATE
					,DATE_KIND
					,WRITE_DATE
					,WRITE_TIME
					,CUD_FLAG
					,USE_YN
					,REG_ID
					,REG_DATE
					,MOD_ID
					,MOD_DATE
					,T_ID
					,T_DATE
		)VALUES(
					 #{id}
					,#{dateName}
					,#{locDate}
					,#{dateKind}
					,CURDATE()
					,CURTIME()
					,'C'
					,'Y'
					,#{regId}
					,NOW()
					,#{modId}
					,NOW()
					,#{tId}
					,#{tDate}
		)
	</insert>
	
	<!-- 공휴일 수정 -->
	<update id="updatePublicHoliday" parameterType="hashmap">
		UPDATE MU_PUBLIC_HOLIDAY
		   SET MOD_ID       = #{modId}
			  ,MOD_DATE     = NOW()
			  ,CUD_FLAG     = 'U'
			  ,LOC_DATE     = #{locDate}
			  ,REMARK       = #{remark}
		WHERE MU_PUBLIC_HOLIDAY_ID  = #{muPublicHolidayId}
	</update>
</mapper>