package com.hc.web.controller.browser.back;

import com.hc.business.model.ZccmCourseChapterVideo;
import com.hc.business.service.ZccmCourseChapterVideoService;
import com.hc.core.utils.result.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 课程视频(ZccmCourseChapterVideo)表控制层
 *
 * @author java
 * @since 2020-11-09 10:04:56
 */

@RestController
@RequestMapping("/new/api/courseChapterVideo")
public class CourseChapterVideoController {

    /**
     * 服务对象
     */
    private final ZccmCourseChapterVideoService courseChapterVideoService;

    public CourseChapterVideoController(ZccmCourseChapterVideoService courseChapterVideoService) {
        this.courseChapterVideoService = courseChapterVideoService;
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "依据主键获取 ZccmCourseChapterVideo", response = Result.class)
    public Result selectDetail(@PathVariable("id") Integer id) {
        return Result.success(this.courseChapterVideoService.queryById(id));
    }

    @PostMapping("/insert")
    @ApiOperation(value = "新增 ZccmCourseChapterVideo", response = Result.class)
    public Result addZccmCourseChapterVideo(@Valid @RequestBody ZccmCourseChapterVideo courseChapterVideo) {
        return Result.success(courseChapterVideoService.insert(courseChapterVideo));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 ZccmCourseChapterVideo", response = Result.class)
    public Result updateZccmCourseChapterVideo(@RequestBody ZccmCourseChapterVideo courseChapterVideo) {
        return Result.success(courseChapterVideoService.update(courseChapterVideo));
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "依据主键删除 ZccmCourseChapterVideo", response = Result.class)
    public Result deleteZccmCourseChapterVideo(@PathVariable("id") Integer id) {
        return Result.success(courseChapterVideoService.deleteById(id));
    }

    @GetMapping("/list")
    @ApiOperation(value = "获取 ZccmCourseChapterVideo列表(分页)", response = Result.class)
    public Result listZccmCourseChapterVideo(@RequestParam(defaultValue = "0") Integer page,
                                         @RequestParam(defaultValue = "0") Integer size) {
        return Result.success(courseChapterVideoService.queryAllByLimit(page, size));
    }


}