<?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.xjrsoft.module.attendance.mapper.AttendanceRuleCategoryMapper">
    <select id="getExistCount" parameterType="com.xjrsoft.module.attendance.dto.AddAttendanceRuleCategoryDto" resultType="java.lang.Integer">
        SELECT count(*) FROM attendance_rule_category WHERE delete_mark = 0
        AND role_id = #{dto.roleId} AND attendance_range = #{dto.attendanceRange}
        AND (( #{dto.startDate} BETWEEN start_date AND end_date) OR ( #{dto.endDate} BETWEEN start_date AND end_date))
    </select>

    <select id="getExistCountNEId" parameterType="com.xjrsoft.module.attendance.dto.UpdateAttendanceRuleCategoryDto" resultType="java.lang.Integer">
        SELECT count(*) FROM attendance_rule_category WHERE delete_mark = 0
        AND role_id = #{dto.roleId} AND attendance_range = #{dto.attendanceRange}
        AND (( #{dto.startDate} BETWEEN start_date AND end_date) OR ( #{dto.endDate} BETWEEN start_date AND end_date))
        and id != #{dto.id}
    </select>


</mapper>