package com.reading.platform.controller.teacher;

import com.reading.platform.common.annotation.RequireRole;
import com.reading.platform.common.enums.UserRole;
import com.reading.platform.common.response.Result;
import com.reading.platform.entity.CourseLesson;
import com.reading.platform.service.CourseLessonService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "教师 - 课程课时", description = "课程课时接口（教师专用）")
@RestController
@RequestMapping("/api/v1/teacher/courses/{courseId}/lessons")
@RequiredArgsConstructor
@RequireRole(UserRole.TEACHER)
public class TeacherCourseLessonController {

    private final CourseLessonService courseLessonService;

    @Operation(summary = "获取课程的课时列表")
    @GetMapping
    public Result<List<CourseLesson>> getLessons(@PathVariable String courseId) {
        return Result.success(courseLessonService.getLessonsByCourse(courseId));
    }

    @Operation(summary = "根据ID获取课时")
    @GetMapping("/{id}")
    public Result<CourseLesson> getLesson(@PathVariable String courseId, @PathVariable String id) {
        return Result.success(courseLessonService.getLessonById(id));
    }
}
