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

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

import javax.validation.Valid;


/**
 * 问题类型表(ZccmQuestionType)表控制层
 *
 * @author java
 * @since 2020-12-07 11:37:04
 */

@RestController
@RequestMapping("/new/api/back/questionType")
public class BackQuestionTypeController {

    /**
     * 服务对象
     */
    private final ZccmQuestionTypeService questionTypeService;

    public BackQuestionTypeController(ZccmQuestionTypeService questionTypeService) {
        this.questionTypeService = questionTypeService;
    }

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

    @PostMapping("/insert")
    @ApiOperation(value = "新增 ZccmQuestionType", response = Result.class)
    public Result addBackQuestionType(@Valid @RequestBody ZccmQuestionType questionType) {
        return Result.success(questionTypeService.insert(questionType));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 ZccmQuestionType", response = Result.class)
    public Result updateBackQuestionType(@RequestBody ZccmQuestionType questionType) {
        return Result.success(questionTypeService.update(questionType));
    }

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

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


}