package com.ningdatech.pmapi.leave.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.pmapi.common.model.entity.KeyValDTO;
import com.ningdatech.pmapi.leave.entity.domain.ExpertLeaveDetail;
import com.ningdatech.pmapi.leave.mapper.ExpertLeaveDetailMapper;
import com.ningdatech.pmapi.leave.service.IExpertLeaveDetailService;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 专家请假详情表（维度：天） 服务实现类
 * </p>
 *
 * @author WendyYang
 * @since 2022-08-11
 */
@Service
public class ExpertLeaveDetailServiceImpl extends ServiceImpl<ExpertLeaveDetailMapper, ExpertLeaveDetail> implements IExpertLeaveDetailService {

    @Override
    public List<ExpertLeaveDetail> listByDateAndLeaveUserId(LocalDate startDate, LocalDate endDate, Long leaveUserId) {
        return baseMapper.selectLeaveIdByDateAndExpertId(leaveUserId, startDate, endDate.plusDays(1));
    }

    @Override
    public boolean existsLeaveByUserIdAndTime(Long userId, List<KeyValDTO<LocalDateTime, LocalDateTime>> times) {
        return baseMapper.existsLeaveByLeaveUserIdAndTime(userId, times) != null;
    }

}
