<?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.hotent.uc.dao.ShiftRuleDao">
	<resultMap id="ShiftRule" type="com.hotent.uc.model.ShiftRule">
		<id property="id" column="ID_" jdbcType="VARCHAR"/>
		<result property="name" column="NAME_" jdbcType="VARCHAR"/>
		<result property="key" column="KEY_" jdbcType="VARCHAR"/>
		<result property="desc" column="DESC_" jdbcType="LONGVARCHAR"/>
		<result property="rule" column="RULE_" jdbcType="LONGVARCHAR"/>
		<result property="createTime" column="CREATE_TIME_" jdbcType="TIMESTAMP"/>
		<result property="updateTime" column="UPDATE_TIME_" jdbcType="TIMESTAMP"/>
		<result property="createBy" column="CREATE_BY_" jdbcType="VARCHAR"/>
		<result property="updateBy" column="UPDATE_BY_" jdbcType="VARCHAR"/>
		<result property="createOrgId" column="CREATE_ORG_ID_" jdbcType="VARCHAR"/>
		<result property="isDelete" column="IS_DELE_" jdbcType="NUMERIC"/>
		<result property="holidayId" column="HOLIDAY_ID_" jdbcType="VARCHAR"/>
	</resultMap>

	<select id="getRuleByUserId" resultMap="ShiftRule" parameterType="java.lang.String">
		select r.* from uc_shift_rule r
		left join uc_shift_user u on u.shift_id_ = r.id_
		where r.is_dele_ = '0' and u.is_dele_ = '0' and u.user_id_ = #{userId}
	</select>

	<select id="getByKey" resultType="com.hotent.uc.model.ShiftRule" parameterType="java.lang.String">
		select * from uc_shift_rule where KEY_ = #{key} AND IS_DELE_ = '0'
	</select>
</mapper>