package cn.iocoder.yudao.module.attendance.dal.mysql.workdaysetting;

import java.util.*;

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.attendance.dal.dataobject.schedulingmanage.AttendanceSchedulingManageDO;
import cn.iocoder.yudao.module.attendance.dal.dataobject.workdaysetting.AttendanceWorkdaySettingDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.attendance.controller.admin.workdaysetting.vo.*;

/**
 * 考勤工作日设置 Mapper
 *
 * @author zhaopq
 */
@Mapper
public interface AttendanceWorkdaySettingMapper extends BaseMapperX<AttendanceWorkdaySettingDO> {

    default PageResult<AttendanceWorkdaySettingDO> selectPage(AttendanceWorkdaySettingPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AttendanceWorkdaySettingDO>()
                .eqIfPresent(AttendanceWorkdaySettingDO::getWorkMonth, reqVO.getWorkMonth())
                .betweenIfPresent(AttendanceWorkdaySettingDO::getWorkDate, reqVO.getWorkDate())
                .eqIfPresent(AttendanceWorkdaySettingDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(AttendanceWorkdaySettingDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(AttendanceWorkdaySettingDO::getTenantId, reqVO.getTenantId())
                .orderByDesc(AttendanceWorkdaySettingDO::getId));
    }

    // 自定义的deleteByMonth方法
    default int deleteByMonth(String workMonth, Long tenantId) {
        return delete(new LambdaQueryWrapperX<AttendanceWorkdaySettingDO>()
                .eq(AttendanceWorkdaySettingDO::getWorkMonth, workMonth)
                .eqIfPresent(AttendanceWorkdaySettingDO::getTenantId, tenantId));
    }

    default List<AttendanceWorkdaySettingDO> getWorkdays(String workMonth, Long tenantId) {
        return selectList(new LambdaQueryWrapperX<AttendanceWorkdaySettingDO>()
                .eq(AttendanceWorkdaySettingDO::getWorkMonth, workMonth)
                .eqIfPresent(AttendanceWorkdaySettingDO::getTenantId, tenantId));
    }

}