package com.hc.gpweb.controller.api;

import com.hc.gpbusiness.model.WebCourseTagCollection;
import com.hc.gpbusiness.service.WebCourseTagCollectionService;
import com.hc.gpcore.utils.result.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 新闻标签，新闻对应表(CourseTagCollection)表控制层
 *
 * @author java
 * @since 2020-07-29 16:23:09
 */

@RestController
@RequestMapping("/api/courseTagCollection")
public class CourseTagCollectionController {

    /**
     * 服务对象
     */
    private final WebCourseTagCollectionService courseTagCollectionService;

    public CourseTagCollectionController(WebCourseTagCollectionService courseTagCollectionService) {
        this.courseTagCollectionService = courseTagCollectionService;
    }

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

    @PostMapping("/insert")
    @ApiOperation(value = "新增 CourseTagCollection", response = Result.class)
    public Result addCourseTagCollection(@Valid @RequestBody WebCourseTagCollection courseTagCollection) {
        return Result.success(courseTagCollectionService.insert(courseTagCollection));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 CourseTagCollection", response = Result.class)
    public Result updateCourseTagCollection(@RequestBody WebCourseTagCollection courseTagCollection) {
        return Result.success(courseTagCollectionService.update(courseTagCollection));
    }

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

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


}