package com.zhongzheng.controller.course;

import java.util.List;
import java.util.Arrays;

import com.zhongzheng.modules.course.bo.CourseStreamingAddBo;
import com.zhongzheng.modules.course.bo.CourseStreamingEditBo;
import com.zhongzheng.modules.course.bo.CourseStreamingQueryBo;
import com.zhongzheng.modules.course.domain.CourseSectionBusiness;
import com.zhongzheng.modules.course.domain.CourseStreamingBusiness;
import com.zhongzheng.modules.course.service.ICourseStreamingBusinessService;
import com.zhongzheng.modules.course.service.ICourseStreamingService;
import com.zhongzheng.modules.course.vo.CourseStreamingVo;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhongzheng.common.annotation.Log;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.enums.BusinessType;
import com.zhongzheng.common.utils.poi.ExcelUtil;
import com.zhongzheng.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 课程流媒体Controller
 *
 * @author hjl
 * @date 2021-10-11
 */
@Api(value = "课程流媒体控制器", tags = {"课程流媒体管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/course/streaming")
public class CourseStreamingController extends BaseController {

    private final ICourseStreamingService iCourseStreamingService;

    private final ICourseStreamingBusinessService iCourseStreamingBusinessService;

    /**
     * 查询课程流媒体列表
     */
    @ApiOperation("查询课程流媒体列表")
    @PreAuthorize("@ss.hasPermi('system:streaming:list')")
    @GetMapping("/list")
    public TableDataInfo<CourseStreamingVo> list(CourseStreamingQueryBo bo) {
        startPage();
        List<CourseStreamingVo> list = iCourseStreamingService.selectList(bo);
        return getDataTable(list);
    }

    /**
     * 导出课程流媒体列表
     */
   /* @ApiOperation("导出课程流媒体列表")
    @PreAuthorize("@ss.hasPermi('system:streaming:export')")
    @Log(title = "课程流媒体", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<CourseStreamingVo> export(CourseStreamingQueryBo bo) {
        List<CourseStreamingVo> list = iCourseStreamingService.queryList(bo);
        ExcelUtil<CourseStreamingVo> util = new ExcelUtil<CourseStreamingVo>(CourseStreamingVo.class);
        return util.exportExcel(list, "课程流媒体");
    }*/

    /**
     * 获取课程流媒体详细信息
     */
    @ApiOperation("获取课程流媒体详细信息")
    @PreAuthorize("@ss.hasPermi('system:streaming:query')")
    @GetMapping("/{id}")
    public AjaxResult<CourseStreamingVo> getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iCourseStreamingService.queryById(id));
    }

    /**
     * 新增课程流媒体
     */
    @ApiOperation("新增课程流媒体")
    @PreAuthorize("@ss.hasPermi('system:streaming:add')")
    @Log(title = "课程流媒体", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody CourseStreamingAddBo bo) {
        return toAjax(iCourseStreamingService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改课程流媒体
     */
    @ApiOperation("修改课程流媒体")
    @PreAuthorize("@ss.hasPermi('system:streaming:edit')")
    @Log(title = "课程流媒体", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult<Void> edit(@RequestBody CourseStreamingEditBo bo) {
        return toAjax(iCourseStreamingService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除课程流媒体
     */
  /*  @ApiOperation("删除课程流媒体")
    @PreAuthorize("@ss.hasPermi('system:streaming:remove')")
    @Log(title = "课程流媒体" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@PathVariable Long[] ids) {
        return toAjax(iCourseStreamingService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }*/

    /**
     * 获取课程小节业务层次列表
     */
    @ApiOperation("获取课程小节业务层次列表")
    @PreAuthorize("@ss.hasPermi('system:section:query')")
    @GetMapping("/business/{id}")
    public AjaxResult<List<CourseStreamingBusiness>> getBusinessList(@PathVariable("id" ) Long id) {
        List<CourseStreamingBusiness> list = iCourseStreamingBusinessService.getListById(id);
        return AjaxResult.success(list);
    }
}
