package rd.controller.schedule;

import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.stp.StpUtil;
import rd.data.db.CourseScheduleWithCourseIdName;
import rd.data.model.response.Response;
import rd.service.schedule.TeacherCourseScheduleService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/teacher/course-schedule")
public class TeacherScheduleController {
    private final TeacherCourseScheduleService teacherCourseScheduleService;

    public TeacherScheduleController(TeacherCourseScheduleService teacherCourseScheduleService) {

        this.teacherCourseScheduleService = teacherCourseScheduleService;
    }

    @SaCheckRole("TEACHER")
    @RequestMapping("/teacher-schedules")
    public Response<List<CourseScheduleWithCourseIdName>> list(@RequestParam("term") String term) {
        var uid = StpUtil.getLoginIdAsLong();
        var result = teacherCourseScheduleService.getTeacherSchedule(uid, term);

        return Response.success(result);
    }
}
