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

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

import javax.validation.Valid;


/**
 * 章节测试表/随堂练习表(ZccmCourseChapterTest)表控制层
 *
 * @author java
 * @since 2020-11-09 10:04:54
 */

@RestController
@RequestMapping("/new/api/courseChapterTest")
public class CourseChapterTestController {

    /**
     * 服务对象
     */
    private final ZccmCourseChapterTestService courseChapterTestService;

    public CourseChapterTestController(ZccmCourseChapterTestService courseChapterTestService) {
        this.courseChapterTestService = courseChapterTestService;
    }

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

    @PostMapping("/insert")
    @ApiOperation(value = "新增 ZccmCourseChapterTest", response = Result.class)
    public Result addZccmCourseChapterTest(@Valid @RequestBody ZccmCourseChapterTest courseChapterTest) {
        return Result.success(courseChapterTestService.insert(courseChapterTest));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 ZccmCourseChapterTest", response = Result.class)
    public Result updateZccmCourseChapterTest(@RequestBody ZccmCourseChapterTest courseChapterTest) {
        return Result.success(courseChapterTestService.update(courseChapterTest));
    }

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

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


}