package com.ruoyi.web.controller.school.course;

import com.ruoyi.core.api.APIResponse;
import com.ruoyi.school.course.domain.req.course.ReqSearchScCourse;
import com.ruoyi.school.course.domain.req.course.ReqSelect;
import com.ruoyi.school.course.domain.req.course.ReqAddScCourse;
import com.ruoyi.school.course.domain.req.course.ReqChangeScCourse;
import com.ruoyi.school.course.domain.ScCourse;
import com.ruoyi.school.course.service.BusinessScCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 课程信息 Controller
 * </p>
 *
 * @author zhangby
 * @since 2020-03-17 11:25:55
 */
@RestController
@RequestMapping("/api/sc/course")
public class ScCourseController {

    @Autowired
    private BusinessScCourseService scCourseService;

    /**
     * 列表
     *
     * @param reqSearchScCourse
     * @return
     */
    @GetMapping("/list/searchList")
    public APIResponse searchList(ReqSearchScCourse reqSearchScCourse) {
        return scCourseService.searchList(reqSearchScCourse);
    }

    /**
     * 查询课程列表
     * 含有会员报读状态
     *
     * @param reqSearchScCourse
     * @return
     */
    @GetMapping("/list/selectCourseListWithStudentCourse")
    public APIResponse selectCourseListWithStudentCourse(ReqSearchScCourse reqSearchScCourse) {
        return scCourseService.selectCourseListWithStudentCourse(reqSearchScCourse);
    }

    /**
     * 前端select
     *
     * @return
     */
    @GetMapping("/list/select")
    public APIResponse select(ReqSelect reqSelect) {
        return scCourseService.select(reqSelect);
    }

    /**
     * 详情
     *
     * @param courseId
     * @return
     */
    @GetMapping("/info/detailById/{courseId}")
    public APIResponse detailById(@PathVariable("courseId") Long courseId) {
        return scCourseService.detailById(courseId);
    }

    /**
     * 添加
     *
     * @param reqAddScCourse
     * @return
     */
    @PostMapping("/add/addScCourse")
    public APIResponse addScCourse(@RequestBody ReqAddScCourse reqAddScCourse) {
        return scCourseService.addScCourse(reqAddScCourse);
    }

    /**
     * 修改
     *
     * @param reqChangeScCourse
     * @return
     */
    @PutMapping("/update/updateScCourse")
    public APIResponse updateScCourse(@RequestBody ReqChangeScCourse reqChangeScCourse) {
        return scCourseService.updateScCourse(reqChangeScCourse);
    }

    /**
     * 删除
     *
     * @param courseIds
     * @return
     */
    @DeleteMapping("/delete/deleteById/{courseIds}")
    public APIResponse deleteById(@PathVariable("courseIds") List<Long> courseIds) {
        return scCourseService.deleteById(courseIds);
    }

    /**
     * 变更是否开售
     *
     * @param scCourse
     * @return
     */
    @PutMapping("/update/changeCourseSale")
    public APIResponse changeCourseSale(@RequestBody ScCourse scCourse) {
        return scCourseService.changeCourseSale(scCourse);
    }




}
