package com.yida.data.attendance.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yida.data.attendance.mapper.EduAttendanceRuleTimeMapper;
import com.yida.data.attendance.service.EduAttendanceRuleTimeService;
import com.yida.data.common.core.entity.attendance.EduAttendanceRuleTime;
import com.yida.data.attendance.vo.RuleTimeVO;
import com.yida.data.user.feign.RemoteUserDeptService;
import java.time.LocalDate;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * 考勤规则 考勤时间 Service实现
 *
 * @author zhanghaijun
 * @date 2021-06-25 09:51:00
 */
@Service
@RequiredArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class EduAttendanceRuleTimeServiceImpl extends ServiceImpl
    <EduAttendanceRuleTimeMapper, EduAttendanceRuleTime> implements EduAttendanceRuleTimeService {

    private final RemoteUserDeptService remoteUserDeptService;

    @Override
    public List<RuleTimeVO> listDeptRuleTime(Long deptId, LocalDate date, Integer type) {
        List<Long> deptIds = remoteUserDeptService.getUpId(new Long[]{deptId}).getData();
        return baseMapper.listDeptRuleTime(deptIds, date, date.getDayOfWeek().getValue(), type);
    }
}
