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

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

/**
 * 第三方用户课程配置表(ThirdCourse)表控制层
 *
 * @author java
 * @since 2020-06-17 17:29:30
 */

@RestController
@RequestMapping("/new/api/back/thirdCourse")
public class BackThirdCourseController {

    /**
     * 服务对象
     */
    private final ThirdCourseService thirdCourseService;

    public BackThirdCourseController(ThirdCourseService thirdCourseService) {
        this.thirdCourseService = thirdCourseService;
    }

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

    @PostMapping("/insert")
    @ApiOperation(value = "新增 ThirdCourse", response = Result.class)
    public Result addBackThirdCourse(@RequestBody ThirdCourse thirdCourse) {
        return Result.success(this.thirdCourseService.insert(thirdCourse));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 ThirdCourse", response = Result.class)
    public Result updateBackThirdCourse(@RequestBody ThirdCourse thirdCourse) {
        return Result.success(this.thirdCourseService.update(thirdCourse));
    }

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

    @GetMapping("/list")
    @ApiOperation(value = "获取 ThirdCourse列表(分页)", response = Result.class)
    public Result listBackThirdCourse(@RequestParam(defaultValue = "0") Integer page,
                                      @RequestParam(defaultValue = "0") Integer size) {
        return Result.success(this.thirdCourseService.queryPageAll(page, size));
    }

    @GetMapping("/findById/{thirdId}")
    @ApiOperation(value = "获取 ThirdCourse列表(分页)", response = Result.class)
    public Result listBackThirdCourseUpdate(@PathVariable("thirdId") Integer thirdId) {
        return Result.success(this.thirdCourseService.queryThirdCourseDtoById(thirdId));
    }

}