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.CourseChapterAddBo;
import com.zhongzheng.modules.course.bo.CourseChapterEditBo;
import com.zhongzheng.modules.course.bo.CourseChapterQueryBo;
import com.zhongzheng.modules.course.service.ICourseChapterService;
import com.zhongzheng.modules.course.vo.CourseChapterVo;
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.List;

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

    private final ICourseChapterService iCourseChapterService;

    /**
     * 查询课程大章列表
     */
    @ApiOperation("查询课程大章列表")
    @GetMapping("/list")
    public TableDataInfo<CourseChapterVo> list(CourseChapterQueryBo bo) {
        startPage();
        List<CourseChapterVo> list = iCourseChapterService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出课程大章列表
     */
    /*@ApiOperation("导出课程大章列表")
    @PreAuthorize("@ss.hasPermi('course:chapter:export')")
    @Log(title = "课程大章", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<CourseChapterVo> export(CourseChapterQueryBo bo) {
        List<CourseChapterVo> list = iCourseChapterService.queryList(bo);
        ExcelUtil<CourseChapterVo> util = new ExcelUtil<CourseChapterVo>(CourseChapterVo.class);
        return util.exportExcel(list, "课程大章");
    }*/

    /**
     * 获取课程大章详细信息
     */
    @ApiOperation("获取课程大章详细信息")
    @GetMapping("/{chapterId}")
    public AjaxResult<CourseChapterVo> getInfo(@PathVariable("chapterId" ) Long chapterId) {
        return AjaxResult.success(iCourseChapterService.queryById(chapterId));
    }


}
