package com.xueyi.system.common.service.impl;

import com.xueyi.common.web.entity.service.impl.BaseServiceImpl;
import com.xueyi.system.common.domain.dto.DmHolidayDto;
import com.xueyi.system.common.domain.query.DmHolidayQuery;
import com.xueyi.system.common.manager.IDmHolidayManager;
import com.xueyi.system.common.service.IDmHolidayService;
import org.springframework.stereotype.Service;

import java.time.LocalDate;

@Service
public class IDmHolidayServiceImpl extends BaseServiceImpl<DmHolidayQuery, DmHolidayDto, IDmHolidayManager> implements IDmHolidayService {

    @Override
    public DmHolidayDto getTodayHoliday() {
        DmHolidayQuery query = new DmHolidayQuery();
        query.setDate(LocalDate.now());
        DmHolidayDto dto = baseManager.selectTodayHoliday(query);
        if (dto != null) {
            return dto;
        }
        dto = new DmHolidayDto();
        // 判断今天是工作日还是周末
        if (LocalDate.now().getDayOfWeek().getValue() == 6 || LocalDate.now().getDayOfWeek().getValue() == 7) {
            dto.setHoliday(1);
        } else {
            dto.setHoliday(0);
        }
        return dto;
    }
}
