package com.yida.data.attendance.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yida.data.attendance.dto.AttendanceRuleAdminUserPageDTO;
import com.yida.data.attendance.dto.AttendanceRuleUserPageDTO;
import com.yida.data.attendance.vo.AttdanceResultVO;
import com.yida.data.attendance.vo.AttendanceRuleAdminUserVO;
import com.yida.data.attendance.vo.AttendanceRuleUserVO;
import com.yida.data.attendance.vo.AttendanceRuleVO;
import com.yida.data.attendance.vo.ConflictRuleVO;
import com.yida.data.common.core.entity.attendance.attendance.AttendanceRule;
import java.time.LocalDate;
import java.util.List;
import org.apache.ibatis.annotations.Param;

/**
 * 教职工考勤规则 Mapper
 *
 * @date 2023-08-09 11:37:25
 */
public interface AttendanceRuleMapper extends BaseMapper<AttendanceRule> {

    AttendanceRuleVO getRule(Long id);

    IPage<AttendanceRuleVO> listRulePage(Page page,
        @Param("schoolId") Long schoolId,
        @Param("ruleName") String ruleName,
        @Param("type") Integer type,
        @Param("userType") Integer userType,
        @Param("status") Integer status);

    List<AttendanceRuleVO> listRule(@Param("schoolId") Long schoolId,
        @Param("ruleName") String ruleName,
        @Param("type") Integer type,
        @Param("userType") Integer userType,
        @Param("status") Integer status);

    IPage<AttendanceRuleUserVO> listRuleAttendanceUser(Page page, @Param("dto") AttendanceRuleUserPageDTO dto);

    IPage<AttendanceRuleAdminUserVO> listRuleAttendanceAdminUser(Page page, @Param("dto") AttendanceRuleAdminUserPageDTO dto);

    List<ConflictRuleVO> checkNormalRule(@Param("deptIds") List<Long> deptIds,
        @Param("startDate") LocalDate startDate,
        @Param("endDate") LocalDate endDate,
        @Param("userType") Integer userType,
        @Param("ruleId") Long ruleId,
        @Param("week") String week);

    List<AttendanceRuleVO> findUserMatchRuleByDevice(
        @Param("userType") Integer userType,
        @Param("deptIdList") List<Long> deptIdList,
        @Param("deviceSn") String deviceSn,
        @Param("currentDate") LocalDate currentDate,
        @Param("dayOfWeek") Integer dayOfWeek,
        @Param("schoolId") Long schoolId);

    List<AttendanceRuleVO> findUserMatchRuleByWifi(
        @Param("userType") Integer userType,
        @Param("deptIdList") List<Long> deptIdList,
        @Param("wifiName") String wifiName,
        @Param("wifiBssid") String wifiBssid,
        @Param("ip") String ip,
        @Param("currentDate") LocalDate currentDate,
        @Param("dayOfWeek") Integer dayOfWeek,
        @Param("schoolId") Long schoolId);


    List<AttendanceRuleVO> findUserMatchRuleByUserId(
        @Param("userType") Integer userType,
        @Param("userId") Long userId);


    List<AttendanceRuleVO> findByUserDeptListAndUserType(@Param("deptIdList") List<Long> deptIdList,
        @Param("userType") Integer userType,
        @Param("schoolId") Long schoolId);

    List<AttendanceRuleVO> findByUserIdAndUserType(@Param("userId") Long userId,
        @Param("userType") Integer userType);

    List<AttendanceRuleVO> findUserManageRuleList(@Param("userId") Long userId, @Param("userType") Integer userType);


    List<Long> getSchoolIdList();

//    List<AttendanceRuleVO> listByWifi(@Param("schoolId") Long schoolId);
}
