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

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

import javax.validation.Valid;


/**
 * 用户班级学习进度表
 * (ZccmUserStatus)表控制层
 *
 * @author java
 * @since 2020-12-06 11:26:46
 */

@RestController
@RequestMapping("/new/api/back/userStatus")
public class BackUserStatusController {

    /**
     * 服务对象
     */
    private final ZccmUserStatusService userStatusService;

    public BackUserStatusController(ZccmUserStatusService userStatusService) {
        this.userStatusService = userStatusService;
    }

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

    @PostMapping("/insert")
    @ApiOperation(value = "新增 ZccmUserStatus", response = Result.class)
    public Result addZccmUserStatus(@Valid @RequestBody ZccmUserStatus userStatus) {
        return Result.success(userStatusService.insert(userStatus));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 ZccmUserStatus", response = Result.class)
    public Result updateZccmUserStatus(@RequestBody ZccmUserStatus userStatus) {
        return Result.success(userStatusService.update(userStatus));
    }

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

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

    @GetMapping("/list/user")
    @ApiOperation(value = "获取 ZccmUser列表(分页)", response = Result.class)
    public Result listZccmUserByClassId(@RequestParam Integer classId,
                                    @RequestParam(defaultValue = "0") Integer page,
                                    @RequestParam(defaultValue = "0") Integer size) {
        return Result.success(userStatusService.queryByClassId(classId, page, size));
    }


}