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

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.*;


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

@RestController
@RequestMapping("/new/api/app/classConfig")
public class AppClassConfigController {

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

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

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

    @GetMapping("/valid/list")
    @ApiOperation(value = "获取 ClassConfig列表(分页)", response = Result.class)
    public Result listAppClassConfigByValid(@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 = "获取 ClassConfig列表(分页) 地区id", response = Result.class)
    public Result listAppClassConfigByAreaId(@ApiParam(value = "地区id") @RequestParam Integer areaId,
                                             @RequestParam(defaultValue = "0") Integer page,
                                             @RequestParam(defaultValue = "0") Integer size) {
        return Result.success(classConfigService.queryByAreaId(areaId, page, size));
    }

    @GetMapping("/time/list")
    @ApiOperation(value = "获取 ClassConfig列表(分页) 学习时间", response = Result.class)
    public Result listAppByStudyStartTime(@ApiParam(value = "学习开始时间") @RequestParam Long studyStartTime,
                                          @RequestParam(defaultValue = "0") Integer page,
                                          @RequestParam(defaultValue = "0") Integer size) {
        return Result.success(classConfigService.queryByTime(studyStartTime, page, size));
    }

    @GetMapping("/list/name")
    @ApiOperation(value = "依据名称 获取 ClassConfig列表", response = Result.class)
    public Result listFrontClassConfigByName(@ApiParam(value = "培训班名称") @RequestParam String name) {
        return Result.success(classConfigService.queryByClassName(name));
    }


}