|
@@ -0,0 +1,166 @@
|
|
|
+package com.yonge.cooleshow.classroom.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.yonge.cooleshow.biz.dal.dto.*;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.UserRoleEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.ImNetworkRoomService;
|
|
|
+import com.yonge.cooleshow.common.controller.BaseController;
|
|
|
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
+import com.yonge.toolset.base.exception.BizException;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Optional;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 网络教室房间(ImNetworkRoom)表控制层
|
|
|
+ *
|
|
|
+ * @author zx
|
|
|
+ * @since 2022-03-30 16:36:36
|
|
|
+ */
|
|
|
+@Api(tags = "网络教室房间")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/imNetworkRoom")
|
|
|
+public class ImNetworkRoomController extends BaseController {
|
|
|
+
|
|
|
+ private final static Logger log = LoggerFactory.getLogger(ImNetworkRoomController.class);
|
|
|
+ /**
|
|
|
+ * 服务对象
|
|
|
+ */
|
|
|
+ @Resource
|
|
|
+ private ImNetworkRoomService imNetworkRoomService;
|
|
|
+
|
|
|
+ @ApiOperation("加入网络教室")
|
|
|
+ @PostMapping(value = "/join", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
+ @ApiImplicitParam(name = "roomId", dataType = "Long", value = "课程编号")
|
|
|
+ public HttpResponseResult<ImNetworkRoomResult> joinRoom(Long roomId) throws Exception {
|
|
|
+ roomId = Optional.ofNullable(roomId)
|
|
|
+ .orElseThrow(()->new BizException("房间号不可为空"));
|
|
|
+ return imNetworkRoomService.joinRoom(roomId, UserRoleEnum.TEACHER);
|
|
|
+ }
|
|
|
+
|
|
|
+// @ApiOperation("加入网络教室状态回调")
|
|
|
+// @PostMapping(value = "joinRoomSuccess", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
+// public HttpResponseResult joinRoomSuccess(Long courseScheduleId) throws Exception {
|
|
|
+// imNetworkRoomService.joinRoomSuccess(courseScheduleId.toString(),UserRoleEnum.TEACHER);
|
|
|
+// return succeed();
|
|
|
+// }
|
|
|
+
|
|
|
+ @ApiOperation("加入网络教室状态回调")
|
|
|
+ @PostMapping(value = "joinRoomFailure", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
+ public HttpResponseResult joinRoomFailure(Long roomId){
|
|
|
+ imNetworkRoomService.joinRoomFailure(roomId.toString());
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/statusSync")
|
|
|
+ public void statusSync(@RequestBody String body) throws Exception {
|
|
|
+ ImChannelStateNotify notify = JSONObject.parseObject(body, ImChannelStateNotify.class);
|
|
|
+ log.info("statusSyncParam: {}",JSONObject.toJSON(notify));
|
|
|
+ switch (notify.getEvent()) {
|
|
|
+ case 11:
|
|
|
+ //成员加入
|
|
|
+ imNetworkRoomService.joinRoomSuccess(notify.getChannelId(),Long.parseLong(notify.getUserId()));
|
|
|
+ break;
|
|
|
+ case 12:
|
|
|
+ //成员退出
|
|
|
+ imNetworkRoomService.leaveRoomSuccess(notify.getChannelId(),Long.parseLong(notify.getUserId()));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("退出网络教室")
|
|
|
+ @ApiImplicitParam(name = "roomId", dataType = "Long", value = "课程编号")
|
|
|
+ @PostMapping(value = "/leave", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
+ public HttpResponseResult leaveRoom(Long roomId) throws Exception {
|
|
|
+ imNetworkRoomService.leaveRoom(roomId.toString(),UserRoleEnum.TEACHER);
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("控制学员节拍器")
|
|
|
+ @PostMapping(value = "/sendImPlayMidiMessage", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
+ public HttpResponseResult sendImPlayMidiMessage(@RequestBody ImNetworkCustomMessage customMessage) throws Exception {
|
|
|
+ imNetworkRoomService.sendImPlayMidiMessage(customMessage);
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("移动端用来渲染页面")
|
|
|
+ @PostMapping(value = "/display", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
+ public HttpResponseResult display(@RequestBody ImNetworkDisplayDataDto displayData) throws Exception {
|
|
|
+ imNetworkRoomService.display(displayData);
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "批量控制学员设备开关")
|
|
|
+ @PostMapping(value = "/device/batchControl", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
+ public Object batchControlDevice(@RequestBody ImNetworkDeviceControlDto deviceControl)throws Exception {
|
|
|
+ imNetworkRoomService.batchControlDevice(deviceControl);
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "控制学员设备开关")
|
|
|
+ @PostMapping(value = "/device/control", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
+ public HttpResponseResult controlDevice(@RequestBody ImNetworkDeviceControlDto deviceControl)
|
|
|
+ throws Exception {
|
|
|
+ imNetworkRoomService.controlDevice(deviceControl);
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "学员同意打开,麦克风、摄像头")
|
|
|
+ @PostMapping(value = "/device/approve", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
+ public HttpResponseResult approveControlDevice(@RequestBody ImNetworkDeviceControlDto deviceControl) throws Exception {
|
|
|
+ imNetworkRoomService.approveControlDevice(deviceControl);
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "学员拒绝打开,麦克风、摄像头")
|
|
|
+ @PostMapping(value = "/device/reject", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
+ public HttpResponseResult rejectControlDevice(@RequestBody ImNetworkDeviceControlDto deviceControl)
|
|
|
+ throws Exception {
|
|
|
+ imNetworkRoomService.rejectControlDevice(deviceControl);
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "学员设备状态同步")
|
|
|
+ @PostMapping(value = "/device/sync", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
+ public Object deviceStatusSync(@RequestBody ImNetworkDeviceControlDto deviceControl)
|
|
|
+ throws Exception {
|
|
|
+ imNetworkRoomService.deviceStatusSync(deviceControl);
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "roomId", dataType = "String", value = "房间号",required = true),
|
|
|
+ @ApiImplicitParam(name = "accompanimentId", dataType = "Long", value = "伴奏编号",required = true)
|
|
|
+ })
|
|
|
+ @ApiOperation(value = "老师在网络教室选择完伴奏后、通知学员下载伴奏")
|
|
|
+ @PostMapping(value = "pushDownloadMusicSheetMsg", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
+ public HttpResponseResult pushDownloadMusicSheetMsg(String roomId,Long accompanimentId) throws Exception {
|
|
|
+ imNetworkRoomService.pushDownloadMusicSheetMsg(roomId,accompanimentId);
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "roomId", dataType = "String", value = "房间号",required = true),
|
|
|
+ @ApiImplicitParam(name = "accompanimentId", dataType = "Long", value = "伴奏编号",required = false),
|
|
|
+ @ApiImplicitParam(name = "status", dataType = "Integer", value = "伴奏下载状态(1下载成功0下载中2下载失败)",required = true)
|
|
|
+ })
|
|
|
+ @ApiOperation(value = "学员伴奏下载状态回调")
|
|
|
+ @PostMapping(value = "musicSheetDownNotify", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
+ public HttpResponseResult adjustMusicScore(String roomId,Long accompanimentId,Integer status) throws Exception {
|
|
|
+ imNetworkRoomService.musicSheetDownNotify(roomId,accompanimentId,status);
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|