package com.lesingle.edu.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.lesingle.edu.entity.CourseLesson;
import com.lesingle.edu.entity.LessonStep;

import java.util.List;

/**
 * 课程环节服务接口
 */
public interface CourseLessonService extends IService<CourseLesson> {

    /**
     * 查询课程的所有环节
     */
    List<CourseLesson> findByCourseId(Long courseId);

    /**
     * 查询课程环节详情
     */
    CourseLesson findById(Long id);

    /**
     * 按 lessonType 查询包含该类型环节的课程 ID 列表
     * 兼容多种存储格式：SOCIAL/SOCIETY/DOMAIN_SOCIAL、INTRODUCTION/INTRO 等
     */
    List<Long> findCourseIdsByLessonType(String lessonType);

    /**
     * 按类型查询课程环节
     */
    CourseLesson findByType(Long courseId, String lessonType);

    /**
     * 创建课程环节
     */
    CourseLesson create(Long courseId, String lessonType, String name, String description,
                       Integer duration, String videoPath, String videoName,
                       String pptPath, String pptName, String pdfPath, String pdfName,
                       String objectives, String preparation, String extension,
                       String reflection, String assessmentData, Boolean useTemplate);

    /**
     * 更新课程环节
     */
    CourseLesson update(Long id, String name, String description, Integer duration,
                       String videoPath, String videoName, String pptPath, String pptName,
                       String pdfPath, String pdfName, String objectives, String preparation,
                       String extension, String reflection, String assessmentData, Boolean useTemplate);

    /**
     * 删除课程环节
     */
    void delete(Long id);

    /**
     * 重新排序课程环节
     */
    void reorder(Long courseId, List<Long> lessonIds);

    /**
     * 查询课程环节的教学环节
     */
    List<LessonStep> findSteps(Long lessonId);

    /**
     * 创建教学环节
     */
    LessonStep createStep(Long lessonId, String name, String content, Integer duration,
                         String objective, List<Long> resourceIds);

    /**
     * 更新教学环节
     */
    LessonStep updateStep(Long stepId, String name, String content, Integer duration,
                         String objective, List<Long> resourceIds);

    /**
     * 删除教学环节
     */
    void deleteStep(Long stepId);

    /**
     * 重新排序教学环节
     */
    void reorderSteps(Long lessonId, List<Long> stepIds);

    /**
     * 查询教师的课程环节（带权限检查）
     */
    List<CourseLesson> findCourseLessonsForTeacher(Long courseId, Long tenantId);
}
