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

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

import javax.validation.Valid;


/**
 * (CourseType)表控制层
 *
 * @author java
 * @since 2020-12-17 14:12:55
 */

@RestController
@RequestMapping("/new/api/back/courseType")
public class BackCourseTypeController {

    /**
     * 服务对象
     */
    private final CourseTypeService courseTypeService;

    public BackCourseTypeController(CourseTypeService courseTypeService) {
        this.courseTypeService = courseTypeService;
    }

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

    @PostMapping("/insert")
    @ApiOperation(value = "新增 CourseType", response = Result.class)
    public Result addBackCourseType(@Valid @RequestBody CourseType courseType) {
        return Result.success(courseTypeService.insert(courseType));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 CourseType", response = Result.class)
    public Result updateBackCourseType(@RequestBody CourseType courseType) {
        return Result.success(courseTypeService.update(courseType));
    }

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

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




}