package com.education.api.controller.student;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.education.business.service.education.CourseInfoService;
import com.education.business.service.education.CourseSectionService;
import com.education.common.base.BaseController;
import com.education.common.utils.Result;
import com.education.model.dto.CourseInfoDto;
import com.education.model.entity.CourseSection;
import com.education.model.request.PageParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 课程管理接口
 * @author zengjintao
 * @version 1.0
 * @create_at 2020/11/23 18:42
 */
@RestController("student-courseInfo")
@RequestMapping("/student/courseInfo")
public class CourseInfoController extends BaseController {

    @Resource
    private CourseInfoService courseInfoService;

    @Resource
    private CourseSectionService courseSectionService;

    /**
     * 课程列表
     * @param pageParam
     * @param courseInfo
     * @return
     */
    @GetMapping
    public Result selectPageList(PageParam pageParam, CourseInfoDto courseInfo) {

        return Result.success(courseInfoService.selectPageList(pageParam, courseInfo));
    }


    @GetMapping("/{courseId}/section")
    //@RequiresPermissions("system:section:list")
    public Result section(@PathVariable Integer courseId) {
        List<CourseSection> list = courseSectionService.list(new LambdaQueryWrapper<CourseSection>().eq(CourseSection::getCourseId, courseId));
        return Result.success(list);
    }
}
