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

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

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

@RestController
@RequestMapping("/new/api/back/third")
public class BackThirdController {

    /**
     * 服务对象
     */
    private final ThirdService thirdService;

    public BackThirdController(ThirdService thirdService) {
        this.thirdService = thirdService;
    }

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

    @PostMapping("/insert")
    @ApiOperation(value = "新增 Third", response = Result.class)
    public Result addBackThird(@RequestBody Third third) {
        return Result.success(this.thirdService.insert(third));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 Third", response = Result.class)
    public Result updateBackThird(@RequestBody Third third) {
        return Result.success(this.thirdService.update(third));
    }

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

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


}