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

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

import javax.validation.Valid;


/**
 * 问题标签表(ZccmQuestionTag)表控制层
 *
 * @author java
 * @since 2020-12-07 11:36:44
 */

@RestController
@RequestMapping("/new/api/back/questionTag")
public class BackQuestionTagController {

    /**
     * 服务对象
     */
    private final ZccmQuestionTagService questionTagService;

    public BackQuestionTagController(ZccmQuestionTagService questionTagService) {
        this.questionTagService = questionTagService;
    }

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

    @PostMapping("/insert")
    @ApiOperation(value = "新增 ZccmQuestionTag", response = Result.class)
    public Result addBackQuestionTag(@Valid @RequestBody ZccmQuestionTag questionTag) {
        return Result.success(questionTagService.insert(questionTag));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 ZccmQuestionTag", response = Result.class)
    public Result updateBackQuestionTag(@RequestBody ZccmQuestionTag questionTag) {
        return Result.success(questionTagService.update(questionTag));
    }

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

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


}