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

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


/**
 * 班次课程表(ClassCourse)表控制层
 *
 * @author java
 * @since 2020-11-24 11:30:12
 */

@RestController
@RequestMapping("/new/api/app/classCourse")
public class AppClassCourseController {

    /**
     * 服务对象
     */
    private final ZccmClassCourseService classCourseService;

    public AppClassCourseController(ZccmClassCourseService classCourseService) {
        this.classCourseService = classCourseService;
    }

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

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

    @GetMapping("/course")
    @ApiOperation(value = "获取班级 必修/选修课程", response = Result.class)
    public Result listAppClassCourseByParam(@ApiParam(value = "班次id") @RequestParam Integer classId,
                                            @ApiParam(value = "课程类别") @RequestParam(required = false) Integer courseType,
                                            @RequestParam(defaultValue = "0") Integer page,
                                            @RequestParam(defaultValue = "0") Integer size) {
        return Result.success(classCourseService.queryByClassId(classId, courseType, page, size));
    }
}