package com.ym.mec.web.controller;

import com.ym.mec.biz.dal.entity.TeacherAttendance;
import com.ym.mec.biz.dal.page.TeacherCloseQueryInfo;
import com.ym.mec.biz.service.TeacherAttendanceService;
import com.ym.mec.common.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("teacherAttendance")
@Api(tags = "教师签到服务")
@RestController
public class TeacherAttendanceController extends BaseController {

    @Autowired
    private TeacherAttendanceService teacherAttendanceService;

    @ApiOperation(value = "查询教师签到（上课）记录")
    @GetMapping("/getTeacherPersonalAttendances")
    @PreAuthorize("@pcs.hasPermissions('teacherAttendance/getTeacherPersonalAttendances')")
    public Object getTeacherPersonalAttendances(TeacherCloseQueryInfo queryInfo){
        return succeed(teacherAttendanceService.getTeacherPersonalAttendances(queryInfo));
    }

    @ApiOperation(value = "查询某节课教师签到记录")
    @GetMapping("/getTeacherPersonalAttendance")
    @PreAuthorize("@pcs.hasPermissions('teacherAttendance/getTeacherPersonalAttendance')")
    public Object getTeacherPersonalAttendances(Integer courseScheduleId){
        return succeed(teacherAttendanceService.getTeacherPersonalAttendance(courseScheduleId));
    }

    @ApiOperation(value = "更新教师签到记录")
    @PostMapping("/updateTeacherAttendance")
    @PreAuthorize("@pcs.hasPermissions('teacherAttendance/updateTeacherAttendance')")
    public Object updateTeacherAttendance(TeacherAttendance teacherAttendance){
        teacherAttendanceService.updateTeacherAttendance(teacherAttendance);
        return succeed();
    }
}
