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

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

import javax.validation.Valid;


/**
 * 章节附件表(ZccmCourseChapterAnnex)表控制层
 *
 * @author java
 * @since 2020-11-09 10:04:50
 */

@RestController
@RequestMapping("/new/api/courseChapterAnnex")
public class CourseChapterAnnexController {

    /**
     * 服务对象
     */
    private final ZccmCourseChapterAnnexService courseChapterAnnexService;

    public CourseChapterAnnexController(ZccmCourseChapterAnnexService courseChapterAnnexService) {
        this.courseChapterAnnexService = courseChapterAnnexService;
    }

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

    @PostMapping("/insert")
    @ApiOperation(value = "新增 ZccmCourseChapterAnnex", response = Result.class)
    public Result addZccmCourseChapterAnnex(@Valid @RequestBody ZccmCourseChapterAnnex courseChapterAnnex) {
        return Result.success(courseChapterAnnexService.insert(courseChapterAnnex));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 ZccmCourseChapterAnnex", response = Result.class)
    public Result updateZccmCourseChapterAnnex(@RequestBody ZccmCourseChapterAnnex courseChapterAnnex) {
        return Result.success(courseChapterAnnexService.update(courseChapterAnnex));
    }

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

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


}