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

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

import javax.validation.Valid;


/**
 * 用户考试记录表(UserTestHistory)表控制层
 *
 * @author java
 * @since 2020-12-07 11:28:22
 */

@RestController
@RequestMapping("/new/api/back/userTestHistory")
public class BackUserTestHistoryController {

    /**
     * 服务对象
     */
    private final UserTestHistoryService userTestHistoryService;

    public BackUserTestHistoryController(UserTestHistoryService userTestHistoryService) {
        this.userTestHistoryService = userTestHistoryService;
    }

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

    @PostMapping("/insert")
    @ApiOperation(value = "新增 UserTestHistory", response = Result.class)
    public Result addBackUserTestHistory(@Valid @RequestBody UserTestHistory userTestHistory) {
        return Result.success(userTestHistoryService.insert(userTestHistory));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 UserTestHistory", response = Result.class)
    public Result updateBackUserTestHistory(@RequestBody UserTestHistory userTestHistory) {
        return Result.success(userTestHistoryService.update(userTestHistory));
    }

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

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


}