RoomResult.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package com.ym.pojo;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.microsvc.toolkit.middleware.rtc.message.RTCRoomConfig;
  5. import com.ym.mec.biz.dal.entity.CourseScheduleStudentMusicScore;
  6. import io.swagger.annotations.ApiModelProperty;
  7. import lombok.Data;
  8. import lombok.Getter;
  9. import lombok.Setter;
  10. import org.apache.commons.lang3.StringUtils;
  11. import java.util.ArrayList;
  12. import java.util.Date;
  13. import java.util.List;
  14. import java.util.Map;
  15. import java.util.stream.Collectors;
  16. /**
  17. * Created by weiqinxiao on 2019/2/28.
  18. */
  19. public class RoomResult {
  20. private @Getter @Setter String roomId;
  21. //课程结束后是否自动关闭课程
  22. private @Getter @Setter Boolean autoCloseFlag = true;
  23. //课程结束后多少分钟关闭网络教室
  24. private @Getter @Setter String autoCloseNetworkRoomTime;
  25. private @Getter @Setter Date startTime;
  26. private @Getter @Setter int surplusTime;
  27. //伴奏音量
  28. private @Getter @Setter int soundVolume = 100;
  29. private @Getter @Setter String imToken;
  30. private @Getter @Setter String authorization;
  31. private @Getter List<MemberResult> members = new ArrayList<>();
  32. private @Getter @Setter String display;
  33. private @Getter @Setter List<WhiteboardResult> whiteboards = new ArrayList<>();
  34. private @Getter @Setter MemberResult userInfo;
  35. private @Getter @Setter String randomNumeric = "0";
  36. @ApiModelProperty("RTC接入参数")
  37. private @Getter @Setter RTCRoomConfig rtcRoomConfig;
  38. @ApiModelProperty("直播间用户签名")
  39. private @Getter @Setter String userSig;
  40. @ApiModelProperty("群组id")
  41. private @Getter @Setter String groupId;
  42. @ApiModelProperty("服务提供商")
  43. private @Getter @Setter String serviceProvider;
  44. public RoomResult rtcRoomConfig(RTCRoomConfig rtcRoomConfig) {
  45. this.rtcRoomConfig = rtcRoomConfig;
  46. return this;
  47. }
  48. public RoomResult userSig(String userSig) {
  49. this.userSig = userSig;
  50. return this;
  51. }
  52. @Data
  53. public static class MemberResult {
  54. String userId;
  55. String userName;
  56. String headUrl;
  57. int role;
  58. Date joinTime;
  59. boolean camera;
  60. boolean microphone;
  61. boolean handUpOn;
  62. ExamSongDownloadData examSongDownloadJson;
  63. List<CourseScheduleStudentMusicScore> scheduleStudentMusicScores;
  64. CustomMessage playMidiJson;
  65. }
  66. @Data
  67. public static class WhiteboardResult {
  68. String whiteboardId;
  69. String name;
  70. int curPg;
  71. }
  72. public void setMembers(List<RoomMember> roomMemberList, Map<Integer,String> midiMap,Map<Integer,String> examSongMap,List<CourseScheduleStudentMusicScore> scheduleStudentMusicScores) {
  73. for (RoomMember member : roomMemberList) {
  74. MemberResult result = new MemberResult();
  75. result.setUserId(member.getUid());
  76. result.setJoinTime(member.getJoinDt());
  77. result.setRole(member.getRole());
  78. result.setMicrophone(member.isMic());
  79. result.setCamera(member.isCamera());
  80. result.setUserName(member.getName());
  81. result.setHandUpOn(member.isHand());
  82. result.setHeadUrl(member.getHeadUrl());
  83. result.setPlayMidiJson(JSONObject.parseObject(midiMap.get(Integer.parseInt(member.getUid())),CustomMessage.class));
  84. if(scheduleStudentMusicScores != null && scheduleStudentMusicScores.size() > 0){
  85. result.setScheduleStudentMusicScores(scheduleStudentMusicScores.stream().filter(e->e.getUserId().equals(Integer.parseInt(result.getUserId()))).collect(Collectors.toList()));
  86. }
  87. ExamSongDownloadData examSongDownloadData;
  88. String json = examSongMap.get(Integer.parseInt(member.getUid()));
  89. if(StringUtils.isEmpty(json)){
  90. examSongDownloadData = new ExamSongDownloadData();
  91. }else {
  92. examSongDownloadData = JSON.parseObject(json,ExamSongDownloadData.class);
  93. }
  94. result.setExamSongDownloadJson(examSongDownloadData);
  95. members.add(result);
  96. }
  97. }
  98. public void setWhiteboards(List<Whiteboard> whiteboardList) {
  99. for (Whiteboard wb : whiteboardList) {
  100. WhiteboardResult r = new WhiteboardResult();
  101. r.setName(wb.getName());
  102. r.setWhiteboardId(wb.getWbid());
  103. r.setCurPg(wb.getCurPg());
  104. whiteboards.add(r);
  105. }
  106. }
  107. }