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

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

import javax.validation.Valid;


/**
 * 图书章节标签表。新建完成的图书章节，可以根据讲师不同，给不同的章节打标签，比如基础阶段，进阶阶段。。。(ZccmCourseChapterTag)表控制层
 *
 * @author java
 * @since 2020-11-09 10:04:52
 */

@RestController
@RequestMapping("/new/api/courseChapterTag")
public class CourseChapterTagController {

    /**
     * 服务对象
     */
    private final ZccmCourseChapterTagService courseChapterTagService;

    public CourseChapterTagController(ZccmCourseChapterTagService courseChapterTagService) {
        this.courseChapterTagService = courseChapterTagService;
    }

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

    @PostMapping("/insert")
    @ApiOperation(value = "新增 ZccmCourseChapterTag", response = Result.class)
    public Result addZccmCourseChapterTag(@Valid @RequestBody ZccmCourseChapterTag courseChapterTag) {
        return Result.success(courseChapterTagService.insert(courseChapterTag));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 ZccmCourseChapterTag", response = Result.class)
    public Result updateZccmCourseChapterTag(@RequestBody ZccmCourseChapterTag courseChapterTag) {
        return Result.success(courseChapterTagService.update(courseChapterTag));
    }

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

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


}