package com.ruoyi.zhushi.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.zhushi.entity.AppDTO;
import com.ruoyi.zhushi.entity.DkCheckInRecord;
import com.ruoyi.zhushi.service.DkAppService;
import com.ruoyi.zhushi.service.DkAttendanceGroupService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 打卡控制台
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/dk/app")
@Slf4j
public class DkAppController extends BaseController {


    @Autowired
    private DkAttendanceGroupService dkAttendanceGroupService;

    @Autowired
    private DkAppService dkAppService;


    @GetMapping("/queryAttendanceGroupByUserId")
    public R<AppDTO> queryAttendanceGroupBYUserId(long userId) {
        return R.ok(dkAttendanceGroupService.queryAttendanceGroupBYUserId(userId));
    }

    // 上班打卡
    @GetMapping("/checkIn")
    public R<String> checkIn(AppDTO appDTO) {
        return R.ok(dkAppService.checkIn(appDTO));
    }

    // 下班打卡
    @GetMapping("/checkOut")
    public R<String> checkOut(AppDTO appDTO) {
        return R.ok(dkAppService.checkOut(appDTO));
    }

    // 获取当日当前员工考勤状态
    @GetMapping("/getCurrentDayRecord")
    public R<List<DkCheckInRecord>> getAttendanceStatus(AppDTO appDTO) {
        return R.ok(dkAppService.getCurrentDayRecord(appDTO));
    }
}
