<?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.persagy.calendar.mapper.OldWorkCalendarMapper">

	<resultMap id="WorkCalendarMap" type="com.persagy.calendar.pojo.dto.OldWorkCalendar">
		<result column="CALENDAR_ID" property="id" jdbcType="VARCHAR" />
		<result column="PROJECT_ID" property="projectId" jdbcType="VARCHAR" />
		<result column="CALENDAR_NAME" property="name" jdbcType="VARCHAR" />
		<result column="CALENDAR_DESC" property="desc" jdbcType="VARCHAR" />
		<result column="DICT_TYPE" property="tag" jdbcType="VARCHAR" />
		<result column="DICT_CODE" property="type" jdbcType="VARCHAR" />
		<result column="VALUE" property="value" jdbcType="VARCHAR" />
		<result column="DEL_FLAG" property="delFlag" jdbcType="VARCHAR" />
	</resultMap>
	
	<select id="queryOldCalendarList" resultMap="WorkCalendarMap">
		SELECT ID AS CALENDAR_ID, CALENDAR_NAME, CALENDAR_DESC FROM work_calendar
		WHERE PROJECT_ID = #{projectId} AND DEL_FLAG = #{delFlag}
	</select>
	
	<select id="queryOldCalendarRuleList" resultMap="WorkCalendarMap">
		SELECT CALENDAR_ID, DICT_TYPE, DICT_CODE, VALUE FROM work_calendar_rule
		WHERE CALENDAR_ID = #{id} AND PROJECT_ID = #{projectId} 
		<if test="tag != null and tag.trim().length() != 0">AND DICT_TYPE = #{tag}</if>
		AND DEL_FLAG = #{delFlag} AND RULE_FLAG = #{ruleFlag}
	</select>
</mapper>