package cn.iocoder.yudao.module.system.dal.mysql.attendance.scheduling;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.scheduling.AttendanceSchedulingDO;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.scheduling.vo.*;

import java.util.Map;

/**
 * 排班制考勤设置 Mapper
 *
 * @author 艾楷
 */
@Mapper
public interface AttendanceSchedulingMapper extends BaseMapperX<AttendanceSchedulingDO> {

    default PageResult<AttendanceSchedulingDO> selectPage(AttendanceSchedulingPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AttendanceSchedulingDO>()
                .eqIfPresent(AttendanceSchedulingDO::getIndexDay, reqVO.getIndexDay())
                .eqIfPresent(AttendanceSchedulingDO::getAttendanceGroupId, reqVO.getAttendanceGroupId())
                .eqIfPresent(AttendanceSchedulingDO::getAttendanceGroupShiftId, reqVO.getAttendanceGroupShiftId())
                .eqIfPresent(AttendanceSchedulingDO::getRestFlag, reqVO.getRestFlag())
                .betweenIfPresent(AttendanceSchedulingDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AttendanceSchedulingDO::getId));
    }
    @MapKey("id")
    Map<Long, Integer> countGroupId();
}