package cn.iocoder.yudao.module.system.service.attendance.statistics;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.controller.admin.attendance.vo.AttendanceStatisticsPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.attendance.vo.AttendanceStatisticsSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.statistics.AttendanceStatisticsDO;
import cn.iocoder.yudao.module.system.dal.mysql.attendance.statistics.AttendanceStatisticsMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 考勤统计 Service 实现类
 *
 * @author 艾楷
 */
@Service
@Validated
public class AttendanceStatisticsServiceImpl implements AttendanceStatisticsService {

    @Resource
    private AttendanceStatisticsMapper attendanceStatisticsMapper;

    @Override
    public Long createAttendanceStatistics(AttendanceStatisticsSaveReqVO createReqVO) {
        // 插入
        AttendanceStatisticsDO attendanceStatistics = BeanUtils.toBean(createReqVO, AttendanceStatisticsDO.class);
        attendanceStatisticsMapper.insert(attendanceStatistics);
        // 返回
        return attendanceStatistics.getId();
    }

    @Override
    public void updateAttendanceStatistics(AttendanceStatisticsSaveReqVO updateReqVO) {
        // 更新
        AttendanceStatisticsDO updateObj = BeanUtils.toBean(updateReqVO, AttendanceStatisticsDO.class);
        attendanceStatisticsMapper.updateById(updateObj);
    }

    @Override
    public void deleteAttendanceStatistics(Long id) {
        // 删除
        attendanceStatisticsMapper.deleteById(id);
    }


    @Override
    public AttendanceStatisticsDO getAttendanceStatistics(Long id) {
        return attendanceStatisticsMapper.selectById(id);
    }

    @Override
    public PageResult<AttendanceStatisticsDO> getAttendanceStatisticsPage(AttendanceStatisticsPageReqVO pageReqVO) {
        return attendanceStatisticsMapper.selectPage(pageReqVO);
    }

}