package cn.iocoder.yudao.module.system.controller.app.attendance;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.controller.app.attendance.dto.AttendancePunchDTO;
import cn.iocoder.yudao.module.system.controller.app.attendance.dto.AttendancePunchPageDTO;
import cn.iocoder.yudao.module.system.controller.app.attendance.dto.AttendanceStatisticsDTO;
import cn.iocoder.yudao.module.system.controller.app.attendance.vo.AttendancePunchPageVO;
import cn.iocoder.yudao.module.system.controller.app.attendance.vo.AttendancePunchVO;
import cn.iocoder.yudao.module.system.controller.app.attendance.vo.AttendanceStatisticsVO;
import cn.iocoder.yudao.module.system.service.attendance.AttendanceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;

@Tag(name = "考勤 App - 考勤管理")
@RestController
@RequestMapping("/system/attendance")
@Validated
public class AttendanceController {
    @Resource
    private AttendanceService attendanceService;

    @GetMapping("/getPunchPage")
    @Operation(summary = "获取考勤页面")
    public CommonResult<AttendancePunchPageVO> getPunchPage(@ModelAttribute AttendancePunchPageDTO dto) {
        AttendancePunchPageVO vo = attendanceService.getPunchPage(dto);
        return success(vo);
    }

    @PostMapping("/punch")
    @Operation(summary = "打卡")
    public CommonResult<AttendancePunchVO> punch(@RequestBody AttendancePunchDTO dto) {
        AttendancePunchVO vo = attendanceService.punch(dto);
        return success(vo);
    }

    @PostMapping("/statistics")
    @Operation(summary = "统计")
    public CommonResult<AttendanceStatisticsVO> statistics(@RequestBody AttendanceStatisticsDTO dto) {
        AttendanceStatisticsVO vo = attendanceService.statistics(dto);
        return success(vo);
    }
}
