package com.ym.controller;

import com.ym.mec.common.controller.BaseController;
import com.ym.service.HereWhiteService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/hereWhite")
public class HereWhiteController  extends BaseController {

    @Autowired
    private HereWhiteService hereWhiteService;

    /**
     * 创建白板，默认全部采用零时白板
     * @param name 白板名称
     * @param userNum 白板人数上限，0不限制
     * @param courseScheduleId 课程编号
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "create", method = RequestMethod.POST)
    public Object userAdd(String name,Integer userNum,Integer courseScheduleId) throws Exception {
        if(StringUtils.isEmpty(name) || userNum == null || courseScheduleId == null){
            return failed("参数校验失败");
        }
        return succeed(hereWhiteService.create(name, userNum,courseScheduleId));
    }

    /**
     * 获取特定白板详情
     * @param courseScheduleId 课程编号
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "get", method = RequestMethod.GET)
    public Object join(Integer courseScheduleId){
        return succeed(hereWhiteService.getByClassId(courseScheduleId));
    }

}
