package com.zhongzheng.controller.course;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.zhongzheng.common.annotation.Log;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.core.page.TableDataInfo;
import com.zhongzheng.common.enums.BusinessType;
import com.zhongzheng.modules.course.bo.CourseAddBo;
import com.zhongzheng.modules.course.bo.CourseEditBo;
import com.zhongzheng.modules.course.bo.CourseQueryBo;
import com.zhongzheng.modules.course.service.ICourseService;
import com.zhongzheng.modules.course.vo.CourseVo;
import com.zhongzheng.modules.exam.bo.ExamNoteQueryBo;
import com.zhongzheng.modules.exam.vo.ExamNoteVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * 课程Controller
 *
 * @author hjl
 * @date 2021-05-19
 */
@Api(value = "课程控制器", tags = {"课程管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/app/common/course")
public class CourseController extends BaseController {

    private final ICourseService iCourseService;

    /**
     * 查询课程列表
     */
    @ApiOperation("查询课程列表")
    @GetMapping("/list")
    public TableDataInfo<CourseVo> list(CourseQueryBo bo) {
        List<Integer> statusList = new ArrayList<>();
        statusList.add(1);
        bo.setStatus(statusList);
        startPage();
        List<CourseVo> list = iCourseService.queryList(bo);
        return getDataTable(list);
    }


    /**
     * 获取课程详细信息
     */
    @ApiOperation("获取课程详细信息")
    @GetMapping("/{courseId}")
    public AjaxResult<CourseVo> getInfo(@PathVariable("courseId" ) Long courseId) {
        return AjaxResult.success(iCourseService.queryById(courseId));
    }

    @ApiOperation("课程推荐列表")
    @GetMapping("/recommendList")
    public AjaxResult<List<CourseVo>> recommendList(CourseQueryBo bo) {
        List<CourseVo> list = iCourseService.queryRecommendList(bo);
        return AjaxResult.success(list);
    }

}
