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.CourseSectionAddBo;
import com.zhongzheng.modules.course.bo.CourseSectionEditBo;
import com.zhongzheng.modules.course.bo.CourseSectionQueryBo;
import com.zhongzheng.modules.course.service.ICourseSectionService;
import com.zhongzheng.modules.course.vo.CourseSectionVo;
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.Arrays;
import java.util.List;

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

    private final ICourseSectionService iCourseSectionService;

    /**
     * 查询课程小节列表
     */
    @ApiOperation("查询课程小节列表")
    @GetMapping("/list")
    public TableDataInfo<CourseSectionVo> list(CourseSectionQueryBo bo) {
        startPage();
        List<CourseSectionVo> list = iCourseSectionService.selectList(bo);
        return getDataTable(list);
    }

    /**
     * 获取课程小节详细信息
     */
    @ApiOperation("获取课程小节详细信息")
    @GetMapping("/{sectionId}")
    public AjaxResult<CourseSectionVo> getInfo(@PathVariable("sectionId" ) Long sectionId) {
        return AjaxResult.success(iCourseSectionService.queryById(sectionId));
    }

}
