package com.yida.data.attendance.controller.in;

import com.yida.data.attendance.dto.AttendanceFaceMatchDTO;
import com.yida.data.attendance.dto.AttendanceUserCheckInDTO;
import com.yida.data.attendance.dto.H5AttendanceRuleWifiDTO;
import com.yida.data.attendance.service.AttendanceCheckInService;
import com.yida.data.attendance.service.AttendanceRuleService;
import com.yida.data.attendance.vo.AttendanceFaceMatchVO;
import com.yida.data.attendance.vo.AttendanceUserCheckInVO;
import com.yida.data.attendance.vo.AttendanceWifiVO;
import com.yida.data.common.core.annotation.ControllerLog;
import com.yida.data.common.core.common.ModuleName;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.system.enums.OperationLogTypeEnum;
import com.yida.data.log.annotation.OperationLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 教职工考勤规则 Controller
 *
 * @date 2023-08-09 11:37:25
 */
@Slf4j
@RestController
@RequestMapping("in/H5/attendanceRule")
@RequiredArgsConstructor
@Api(tags = "移动端-考勤-打卡-非鉴权", value = "移动端-考勤-打卡-非鉴权")
public class InH5AttendanceRuleController {

    private final AttendanceRuleService attendanceRuleService;
    private final AttendanceCheckInService attendanceCheckInService;

    @ApiOperation("查询用户当前时间的打卡规则")
    @PostMapping("/findRuleByUserAndDate")
    public ResultBean<AttendanceWifiVO> findRuleByUserAndDate(@Validated @RequestBody H5AttendanceRuleWifiDTO dto) {
        return ResultBean.buildSuccess(attendanceCheckInService.findByUserIdAndDateTime(dto));
    }

    @ApiOperation("签到打卡")
    @PostMapping("/userCheckIn")
    @OperationLog(module = ModuleName.ATTENDANCE, methods = "签到打卡", type = OperationLogTypeEnum.INSERT)
    public ResultBean<AttendanceUserCheckInVO> userCheckIn(@RequestBody AttendanceUserCheckInDTO dto) {
        return ResultBean.buildSuccess(attendanceCheckInService.userCheckIn(dto));
    }

    @ApiOperation("签到人脸比对")
    @PostMapping("/rosterFaceMatch")
    @OperationLog(module = ModuleName.ATTENDANCE, methods = "签到人脸比对", type = OperationLogTypeEnum.SELECT)
    public ResultBean<AttendanceFaceMatchVO> rosterFaceMatch(@RequestBody AttendanceFaceMatchDTO dto) {
        return ResultBean.buildSuccess(attendanceRuleService.AttendanceFaceMatch(dto));
    }

}
