123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- package com.ym.controller;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONObject;
- import com.alibaba.fastjson.serializer.SerializerFeature;
- import com.ym.common.ApiException;
- import com.ym.common.BaseResponse;
- import com.ym.common.ErrorEnum;
- import com.ym.pojo.*;
- import com.ym.service.MessageService;
- import com.ym.service.RoomService;
- import io.swagger.annotations.ApiOperation;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.data.redis.core.RedisTemplate;
- import org.springframework.web.bind.annotation.*;
- import java.util.List;
- @RestController
- @RequestMapping("/room")
- @Slf4j
- public class RoomController{
- @Autowired
- RoomService roomService;
- @Autowired
- MessageService messageService;
- @RequestMapping(value = "/join", method = RequestMethod.POST)
- public Object joinRoom(@RequestBody ReqUserData data) throws Exception {
- return new BaseResponse<>(roomService.joinRoom(data.getRoomId()));
- }
- @RequestMapping(value = "/signIn", method = RequestMethod.POST)
- public Object signIn(Long roomId){
- return new BaseResponse<>();
- }
- @RequestMapping(value = "/statusImMsg", method = RequestMethod.POST)
- public Object statusImMsg(ImMsg imMsg){
- return new BaseResponse<>();
- }
- @RequestMapping(value = "/leave", method = RequestMethod.POST)
- public Object leaveRoom(@RequestBody RoomStatusNotify roomStatusNotify) throws Exception {
- //成员退出
- roomService.leaveRoomSuccess(roomStatusNotify.getRoomId(), roomStatusNotify.getUserId(),roomStatusNotify.getDeviceNum());
- return new BaseResponse<>();
- }
- @RequestMapping(value = "/queryNoJoinStu", method = RequestMethod.GET)
- public Object queryNoJoinStu(String roomId){
- return new BaseResponse<>(roomService.queryNoJoinStu(roomId));
- }
- @RequestMapping(value = "/sendImPlayMidiMessage", method = RequestMethod.POST)
- public Object sendImPlayMidiMessage(@RequestBody PlayMidiMessageData playMidiMessageData) throws Exception {
- log.info("sendImPlayMidiMessage: {}",JSONObject.toJSON(playMidiMessageData));
- roomService.sendImPlayMidiMessage(playMidiMessageData);
- return new BaseResponse<>();
- }
- @RequestMapping(value = "pushDownloadExamSongMsg", method = RequestMethod.POST)
- public Object pushDownloadExamSongMsg(@RequestBody ExamSongData examSongData) throws Exception {
- roomService.pushDownloadExamSongMsg(examSongData.getRoomId(),examSongData.getExamSongId());
- return new BaseResponse<>();
- }
- @ApiOperation(value = "老师通知学员下载伴奏")
- @RequestMapping(value = "pushDownloadMusicScoreMsg", method = RequestMethod.POST)
- public Object pushDownloadMusicScoreMsg(@RequestBody MusicScoreData musicScoreData) throws Exception {
- roomService.pushDownloadMusicScoreMsg(musicScoreData);
- return new BaseResponse<>();
- }
- @RequestMapping(value = "joinRoomStatusNotify", method = RequestMethod.POST)
- public Object joinRoomStatusNotify(@RequestBody RoomStatusNotify roomStatusNotify) throws Exception {
- log.info("joinRoomStatusNotify: {}",JSONObject.toJSON(roomStatusNotify));
- String roomId = roomStatusNotify.getRoomId();
- String userId = roomStatusNotify.getUserId();
- String deviceNum = roomStatusNotify.getDeviceNum();
- if(roomStatusNotify.isRequestStatus()){
- roomService.joinRoomSuccess(roomId, userId,deviceNum);
- }else {
- roomService.joinRoomFailure(roomId, userId);
- }
- return new BaseResponse<>();
- }
- @RequestMapping(value = "/statusSync")
- public void statusSync(@RequestBody String body) throws Exception {
- ChannelStateNotify notify = JSONObject.parseObject(body, ChannelStateNotify.class);
- log.info("statusSyncParam: {}",JSONObject.toJSON(notify));
- String roomId = notify.getChannelId();
- String userId = notify.getUserId();
- switch (notify.getEvent()){
- case 11:
- //成员加入
- roomService.joinRoomSuccess(roomId, userId,null);
- break;
- case 12:
- //成员退出
- roomService.leaveRoomSuccess(roomId, userId,null);
- break;
- }
- }
- @RequestMapping(value = "/downgrade", method = RequestMethod.POST)
- public Object downRole(@RequestBody ReqChangeUserRoleData data)
- throws Exception {
- boolean result = roomService.downgrade(data.getRoomId(), data.getUsers());
- return new BaseResponse<>(result);
- }
- @RequestMapping(value = "/kick", method = RequestMethod.POST)
- public Object kickMember(@RequestBody ReqUserData data)
- throws Exception {
- boolean result = roomService.kickMember(data.getRoomId());
- return new BaseResponse<>(result);
- }
- //only teacher
- @RequestMapping(value = "/display", method = RequestMethod.POST)
- public Object display(@RequestBody ReqDisplayData data)
- throws Exception {
- boolean result = roomService.display(data.getRoomId(), data.getType(), data.getUri(),data.getUserId());
- return new BaseResponse<>(result);
- }
- @RequestMapping(value = "/whiteboard/create", method = RequestMethod.POST)
- public Object createWhiteBoard(@RequestBody ReqWhiteboardData data)
- throws Exception {
- String result = roomService.createWhiteBoard(data.getRoomId());
- return new BaseResponse<>(result);
- }
- @RequestMapping(value = "/whiteboard/delete", method = RequestMethod.POST)
- public Object destroyWhiteBoard(@RequestBody ReqWhiteboardData data)
- throws Exception {
- boolean result = roomService.deleteWhiteboard(data.getRoomId(), data.getWhiteboardId());
- return new BaseResponse<>(result);
- }
- @RequestMapping(value = "/whiteboard/list", method = RequestMethod.GET)
- public Object getWhiteBoard(@RequestParam String roomId)
- throws Exception {
- List<RoomResult.WhiteboardResult> whiteboards = roomService.getWhiteboard(roomId);
- return new BaseResponse<>(whiteboards);
- }
- @ApiOperation(value = "通知学员打开,麦克风、摄像头等权限请求")
- @RequestMapping(value = "/device/approve", method = RequestMethod.POST)
- public Object approveControlDevice(@RequestBody ReqDeviceControlData data)
- throws Exception {
- boolean result;
- result = roomService.approveControlDevice(data);
- return new BaseResponse<>(result);
- }
- @RequestMapping(value = "/device/reject", method = RequestMethod.POST)
- public Object rejectControlDevice(@RequestBody ReqDeviceControlData data)
- throws Exception {
- boolean result;
- result = roomService.rejectControlDevice(data.getRoomId(), data.getTicket());
- return new BaseResponse<>(result);
- }
- @ApiOperation(value = "学员麦克风、摄像头等开关控制")
- @RequestMapping(value = "/device/control", method = RequestMethod.POST)
- public Object controlDevice(@RequestBody ReqDeviceControlData data)
- throws Exception {
- return new BaseResponse<>(roomService.controlDevice(data));
- }
- @RequestMapping(value = "/device/batchControl", method = RequestMethod.POST)
- public Object batchControlDevice(@RequestBody ReqDeviceControlData data)throws Exception {
- log.info("batchControlDevice: {}",JSONObject.toJSON(data));
- boolean result = roomService.batchControlDevice(data);
- return new BaseResponse<>(result);
- }
- @ApiOperation(value = "学员伴奏下载状态回调")
- @RequestMapping(value = "adjustExamSong", method = RequestMethod.POST)
- public Object adjustExamSong(@RequestBody ExamSongData examSongData) throws Exception {
- log.info("adjustExamSong: {}",JSONObject.toJSON(examSongData));
- roomService.adjustExamSong(examSongData.getRoomId(),examSongData.getStatus(),examSongData.getExamSongId());
- return new BaseResponse<>();
- }
- @ApiOperation(value = "学员伴奏下载状态回调")
- @RequestMapping(value = "adjustMusicScore", method = RequestMethod.POST)
- public Object adjustMusicScore(@RequestBody MusicScoreData musicScoreData) throws Exception {
- roomService.adjustMusicScore(musicScoreData);
- return new BaseResponse<>();
- }
- @RequestMapping(value = "/device/sync", method = RequestMethod.POST)
- public Object syncDeviceState(@RequestBody ReqDeviceControlData data)
- throws Exception {
- return new BaseResponse<>(roomService.syncDeviceState(data));
- }
- @RequestMapping(value = "/whiteboard/turn-page", method = RequestMethod.POST)
- public Object turnPage(@RequestBody ReqWhiteboardData data)
- throws Exception {
- boolean result = roomService.turnWhiteBoardPage(data.getRoomId(), data.getWhiteboardId(), data.getPage());
- return new BaseResponse<>(result);
- }
- @RequestMapping(value = "/members", method = RequestMethod.GET)
- public Object getMembers(@RequestParam String roomId)
- throws Exception {
- List<RoomResult.MemberResult> whiteboards = roomService.getMembers(roomId);
- return new BaseResponse<>(whiteboards);
- }
- @RequestMapping(value = "/speech/apply", method = RequestMethod.POST)
- public Object apply(@RequestBody ReqSpeechData data)
- throws Exception {
- Boolean result = roomService.applySpeech(data.getRoomId());
- return new BaseResponse<>(result);
- }
- @RequestMapping(value = "/speech/approve", method = RequestMethod.POST)
- public Object approval(@RequestBody ReqSpeechData data)
- throws Exception {
- Boolean result = roomService.approveSpeech(data.getRoomId(), data.getTicket());
- return new BaseResponse<>(result);
- }
- @RequestMapping(value = "/speech/reject", method = RequestMethod.POST)
- public Object reject(@RequestBody ReqSpeechData data)
- throws Exception {
- Boolean result = roomService.rejectSpeech(data.getRoomId(), data.getTicket());
- return new BaseResponse<>(result);
- }
- @RequestMapping(value = "/transfer", method = RequestMethod.POST)
- public Object transfer(@RequestBody ReqUpgradeRoleData data)
- throws Exception {
- Boolean result = roomService.transfer(data.getRoomId(), data.getUserId());
- return new BaseResponse<>(result);
- }
- @RequestMapping(value = "/upgrade/invite", method = RequestMethod.POST)
- public Object inviteUpgradeRole(@RequestBody ReqUpgradeRoleData data)
- throws Exception {
- Boolean result = roomService.inviteUpgradeRole(data.getRoomId(), data.getUserId(), data.getRole());
- return new BaseResponse<>(result);
- }
- @RequestMapping(value = "/upgrade/approve", method = RequestMethod.POST)
- public Object approveUpgradeRole(@RequestBody ReqUpgradeRoleData data)
- throws Exception {
- Boolean result = roomService.approveUpgradeRole(data.getRoomId(), data.getTicket());
- return new BaseResponse<>(result);
- }
- @RequestMapping(value = "/upgrade/reject", method = RequestMethod.POST)
- public Object rejectUpgradeRole(@RequestBody ReqUpgradeRoleData data)
- throws Exception {
- Boolean result = roomService.rejectUpgradeRole(data.getRoomId(), data.getTicket());
- return new BaseResponse<>(result);
- }
- @RequestMapping(value = "/change-role", method = RequestMethod.POST)
- public Object changeRole(@RequestBody ReqChangeRole data)
- throws Exception {
- Boolean result = roomService.changeRole(data.getRoomId(), data.getUserId(), data.getRole());
- return new BaseResponse<>(result);
- }
- @RequestMapping(value = "/members/online-status", method = RequestMethod.POST)
- public Object memberOnlineStatus(@RequestBody List<ReqMemberOnlineStatus> statusList,
- @RequestParam(value = "timestamp", required = false) String timestamp,
- @RequestParam(value = "nonce", required = false) String nonce,
- @RequestParam(value = "signature", required = false) String signature)
- throws Exception {
- Boolean result = roomService.memberOnlineStatus(statusList, nonce, timestamp, signature);
- return new BaseResponse<>(result);
- }
- }
|