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

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

import javax.validation.Valid;


/**
 * 问题答案表(ZccmQuestionAnswer)表控制层
 *
 * @author java
 * @since 2020-12-07 11:36:23
 */

@RestController
@RequestMapping("/new/api/back/questionAnswer")
public class BackQuestionAnswerController {

    /**
     * 服务对象
     */
    private final ZccmQuestionAnswerService questionAnswerService;

    public BackQuestionAnswerController(ZccmQuestionAnswerService questionAnswerService) {
        this.questionAnswerService = questionAnswerService;
    }

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

    @PostMapping("/insert")
    @ApiOperation(value = "新增 ZccmQuestionAnswer", response = Result.class)
    public Result addBackQuestionAnswer(@Valid @RequestBody ZccmQuestionAnswer questionAnswer) {
        return Result.success(questionAnswerService.insert(questionAnswer));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 ZccmQuestionAnswer", response = Result.class)
    public Result updateBackQuestionAnswer(@RequestBody ZccmQuestionAnswer questionAnswer) {
        return Result.success(questionAnswerService.update(questionAnswer));
    }

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

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


}