<?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.yida.data.attendance.mapper.AttendanceRuleAdminMapper">

  <select id="findList" parameterType="com.yida.data.common.core.entity.attendance.attendance.AttendanceRuleAdmin"
    resultType="com.yida.data.common.core.entity.attendance.attendance.AttendanceRuleAdmin">

    SELECT DISTINCT
    admin.rule_id,
    admin.user_type,
    admin.dept_id,
    admin.staff_id
    FROM
    attendance_rule_admin admin
    LEFT JOIN attendance_rule ru ON admin.rule_id = ru.id
    WHERE
    ru.del_flag = 0
    AND ru.`status` = 1
    <if test="schoolId!=null">
      AND admin.school_id = #{schoolId}
    </if>
    <if test="ruleId!=null">
      AND admin.rule_id = #{ruleId}
    </if>
    <if test="userType!=null">
      AND admin.user_type = #{userType}
    </if>
    <if test="staffId!=null">
      AND admin.staff_id = #{staffId}
    </if>
  </select>
</mapper>
