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

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yida.data.attendance.dto.AddAttendanceRuleTimeDTO;
import com.yida.data.attendance.mapper.AttendanceRuleTimeMapper;
import com.yida.data.attendance.service.AttendanceRuleTimeService;
import com.yida.data.common.core.entity.attendance.attendance.AttendanceRuleTime;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * 考勤-打卡时段 Service实现
 *
 * @date 2023-08-09 11:37:25
 */
@Service
@RequiredArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class AttendanceRuleTimeServiceImpl extends ServiceImpl
    <AttendanceRuleTimeMapper, AttendanceRuleTime> implements AttendanceRuleTimeService {


    @Override
    public AddAttendanceRuleTimeDTO get(Long id) {
        AttendanceRuleTime time = getById(id);
        if (ObjectUtil.isNull(time)) {
            return null;
        }
        AddAttendanceRuleTimeDTO timeDTO = new AddAttendanceRuleTimeDTO();
        BeanUtils.copyProperties(time, timeDTO);
        return timeDTO;
    }
}
