|  | @@ -2,15 +2,21 @@ package com.ym.controller;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  |  import com.ym.common.BaseResponse;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dto.TencentData;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.ETencentTRTCCallbackCommand;
 | 
	
		
			
				|  |  |  import com.ym.pojo.*;
 | 
	
		
			
				|  |  |  import com.ym.service.MessageService;
 | 
	
		
			
				|  |  |  import com.ym.service.RoomService;
 | 
	
		
			
				|  |  | +import io.swagger.annotations.ApiImplicitParam;
 | 
	
		
			
				|  |  | +import io.swagger.annotations.ApiImplicitParams;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiOperation;
 | 
	
		
			
				|  |  |  import lombok.extern.slf4j.Slf4j;
 | 
	
		
			
				|  |  | +import org.joda.time.DateTime;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.web.bind.annotation.*;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  | +import java.util.Objects;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @RestController
 | 
	
		
			
				|  |  |  @RequestMapping("/room")
 | 
	
	
		
			
				|  | @@ -23,7 +29,16 @@ public class RoomController{
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @RequestMapping(value = "/join", method = RequestMethod.POST)
 | 
	
		
			
				|  |  |      public BaseResponse joinRoom(@RequestBody ReqUserData data) throws Exception {
 | 
	
		
			
				|  |  | -        return roomService.joinRoom(data.getRoomId());
 | 
	
		
			
				|  |  | +        return roomService.joinRoom(data.getRoomId(), true);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @ApiOperation("查询网络教室信息")
 | 
	
		
			
				|  |  | +    @ApiImplicitParams({
 | 
	
		
			
				|  |  | +            @ApiImplicitParam(name = "roomId", value = "房间id", required = true, dataType = "String", paramType = "query")
 | 
	
		
			
				|  |  | +    })
 | 
	
		
			
				|  |  | +    @GetMapping(value = "/info")
 | 
	
		
			
				|  |  | +    public BaseResponse getRoomInfo(@RequestParam String roomId) throws Exception {
 | 
	
		
			
				|  |  | +        return roomService.joinRoom(roomId.substring(1), false);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @RequestMapping(value = "/signIn", method = RequestMethod.POST)
 | 
	
	
		
			
				|  | @@ -39,7 +54,7 @@ public class RoomController{
 | 
	
		
			
				|  |  |      @RequestMapping(value = "/leave", method = RequestMethod.POST)
 | 
	
		
			
				|  |  |      public Object leaveRoom(@RequestBody RoomStatusNotify roomStatusNotify) throws Exception {
 | 
	
		
			
				|  |  |          //成员退出
 | 
	
		
			
				|  |  | -        roomService.leaveRoomSuccess(roomStatusNotify.getRoomId(), roomStatusNotify.getUserId(),roomStatusNotify.getDeviceNum());
 | 
	
		
			
				|  |  | +        roomService.leaveRoomSuccess(roomStatusNotify.getRoomId(), roomStatusNotify.getUserId(), roomStatusNotify.getDeviceNum());
 | 
	
		
			
				|  |  |          return new BaseResponse<>();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -96,7 +111,7 @@ public class RoomController{
 | 
	
		
			
				|  |  |                      break;
 | 
	
		
			
				|  |  |                  case 12:
 | 
	
		
			
				|  |  |                      //成员退出
 | 
	
		
			
				|  |  | -                    roomService.leaveRoomSuccess(roomId, userId,null);
 | 
	
		
			
				|  |  | +                    roomService.leaveRoomSuccess(roomId, userId,null, notify.getTimestamp());
 | 
	
		
			
				|  |  |                      break;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }catch (Exception e){
 | 
	
	
		
			
				|  | @@ -104,6 +119,43 @@ public class RoomController{
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @PostMapping(value = "/statusSyncTencent")
 | 
	
		
			
				|  |  | +    public void statusSyncTencent(@RequestBody TencentData.TRTCEventInfo eventInfo) {
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            if (Objects.isNull(eventInfo.getEventInfo())) {
 | 
	
		
			
				|  |  | +                log.warn("statusSyncTencent eventInfo is null, time={}", DateTime.now().toString("yyy-MM-dd HH:mm:ss"));
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            log.info("statusSyncTencent: {}", eventInfo.jsonString());
 | 
	
		
			
				|  |  | +            String roomId = eventInfo.getEventInfo().getRoomId();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            // 网络教室回调整消息
 | 
	
		
			
				|  |  | +            if (roomId.startsWith("S") || roomId.startsWith("I")) {
 | 
	
		
			
				|  |  | +                // 进出用户信息
 | 
	
		
			
				|  |  | +                String userId = eventInfo.getEventInfo().getUserId();
 | 
	
		
			
				|  |  | +                switch (ETencentTRTCCallbackCommand.get(eventInfo.getEventType())){
 | 
	
		
			
				|  |  | +                    case EVENT_TYPE_ENTER_ROOM:
 | 
	
		
			
				|  |  | +                        //成员加入
 | 
	
		
			
				|  |  | +                        roomService.joinRoomSuccess(roomId, userId,null);
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    case EVENT_TYPE_EXIT_ROOM:
 | 
	
		
			
				|  |  | +                        //成员退出
 | 
	
		
			
				|  |  | +                        roomService.leaveRoomSuccess(roomId, userId,null, eventInfo.getCallbackTs());
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    default:
 | 
	
		
			
				|  |  | +                        // 默认事件,直接忽略
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            // 直播回调整消息, roomId.startsWith("LIVE")
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        }catch (Exception e){
 | 
	
		
			
				|  |  | +            log.error("statusSyncTencent event={}", eventInfo.jsonString(), e);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @RequestMapping(value = "/downgrade", method = RequestMethod.POST)
 | 
	
		
			
				|  |  |      public Object downRole(@RequestBody ReqChangeUserRoleData data)
 | 
	
		
			
				|  |  |              throws Exception {
 | 
	
	
		
			
				|  | @@ -209,10 +261,14 @@ public class RoomController{
 | 
	
		
			
				|  |  |          return new BaseResponse<>(result);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @ApiImplicitParams({
 | 
	
		
			
				|  |  | +            @ApiImplicitParam(name = "roomId", value = "房间id", required = true, dataType = "String"),
 | 
	
		
			
				|  |  | +            @ApiImplicitParam(name = "userId", value = "用户Id", dataType = "String"),
 | 
	
		
			
				|  |  | +    })
 | 
	
		
			
				|  |  |      @RequestMapping(value = "/members", method = RequestMethod.GET)
 | 
	
		
			
				|  |  | -    public Object getMembers(@RequestParam String roomId)
 | 
	
		
			
				|  |  | +    public Object getMembers(@RequestParam String roomId, @RequestParam String userId)
 | 
	
		
			
				|  |  |              throws Exception {
 | 
	
		
			
				|  |  | -        List<RoomResult.MemberResult> whiteboards = roomService.getMembers(roomId);
 | 
	
		
			
				|  |  | +        List<RoomResult.MemberResult> whiteboards = roomService.getMembers(roomId, userId);
 | 
	
		
			
				|  |  |          return new BaseResponse<>(whiteboards);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 |