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

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

import javax.validation.Valid;


/**
 * 班次表(ZccmClassConfig)表控制层
 *
 * @author java
 * @since 2020-11-19 16:12:35
 */

@RestController
@RequestMapping("/new/api/back/classConfig")
public class BackClassConfigController {

    /**
     * 服务对象
     */
    private final ZccmClassConfigService classConfigService;

    public BackClassConfigController(ZccmClassConfigService classConfigService) {
        this.classConfigService = classConfigService;
    }

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

    @PostMapping("/insert")
    @ApiOperation(value = "新增 ZccmClassConfig", response = Result.class)
    public Result addBackClassConfig(@Valid @RequestBody ZccmClassConfig classConfig) {
        return Result.success(classConfigService.insert(classConfig));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 ZccmClassConfig", response = Result.class)
    public Result updateBackClassConfig(@RequestBody ZccmClassConfig classConfig) {
        return Result.success(classConfigService.update(classConfig));
    }

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

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

    @GetMapping("/valid/list")
    @ApiOperation(value = "获取 ZccmClassConfig列表(分页)", response = Result.class)
    public Result listBackClassConfigByValid(@ApiParam(value = "状态") @RequestParam Integer valid,
                                             @RequestParam(defaultValue = "0") Integer page,
                                             @RequestParam(defaultValue = "0") Integer size) {
        return Result.success(classConfigService.queryByValid(valid, page, size));
    }

    @GetMapping("/area/list")
    @ApiOperation(value = "获取 ZccmClassConfig列表(分页)", response = Result.class)
    public Result listBackClassConfigByAreaId(@ApiParam(value = "地区id") @RequestParam Integer areaId,
                                              @RequestParam(defaultValue = "0") Integer page,
                                              @RequestParam(defaultValue = "0") Integer size) {
        return Result.success(classConfigService.queryByAreaId(areaId, page, size));
    }


}