瀏覽代碼

Merge branch 'saas' of http://git.dayaedu.com/yonge/mec into saas_export

zouxuan 3 年之前
父節點
當前提交
503671a987
共有 29 個文件被更改,包括 686 次插入469 次删除
  1. 3 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ImLiveRoomVideoDao.java
  2. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ImLiveBroadcastRoomDto.java
  3. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ImLiveBroadcastRoom.java
  4. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/MessageTypeEnum.java
  5. 3 4
      mec-biz/src/main/java/com/ym/mec/biz/dal/vo/ImLiveBroadcastRoomDetailVo.java
  6. 22 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/vo/ImLiveRoomVideoVo.java
  7. 12 4
      mec-biz/src/main/java/com/ym/mec/biz/service/ImLiveBroadcastRoomService.java
  8. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/service/ImLiveRoomVideoService.java
  9. 41 120
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java
  10. 2 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveBroadcastRoomMemberServiceImpl.java
  11. 157 39
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveBroadcastRoomServiceImpl.java
  12. 4 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveRoomBlackServiceImpl.java
  13. 3 11
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveRoomVideoServiceImpl.java
  14. 5 3
      mec-biz/src/main/resources/config/mybatis/ImLiveBroadcastRoomMapper.xml
  15. 1 0
      mec-biz/src/main/resources/config/mybatis/ImLiveRoomReservationMapper.xml
  16. 9 0
      mec-biz/src/main/resources/config/mybatis/ImLiveRoomVideoMapper.xml
  17. 19 1
      mec-client-api/src/main/java/com/ym/mec/im/ImFeignService.java
  18. 11 1
      mec-client-api/src/main/java/com/ym/mec/im/fallback/ImFeignServiceFallback.java
  19. 2 1
      mec-im/src/main/java/com/ym/config/ResourceServerConfig.java
  20. 15 3
      mec-im/src/main/java/com/ym/controller/LiveRoomController.java
  21. 36 0
      mec-im/src/main/java/com/ym/mec/im/IMHelper.java
  22. 49 2
      mec-im/src/main/java/com/ym/service/Impl/LiveRoomServiceImpl.java
  23. 16 1
      mec-im/src/main/java/com/ym/service/LiveRoomService.java
  24. 0 30
      mec-student/src/main/java/com/ym/mec/student/controller/ImLiveBroadcastRoomController.java
  25. 2 1
      mec-student/src/main/java/com/ym/mec/student/controller/ImLiveRoomVideoController.java
  26. 19 12
      mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherImLiveBroadcastRoomController.java
  27. 33 0
      mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherImLiveRoomVideoController.java
  28. 192 228
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/provider/JiguangPushPlugin.java
  29. 4 4
      mec-web/src/main/java/com/ym/mec/web/controller/ImLiveBroadcastRoomController.java

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ImLiveRoomVideoDao.java

@@ -2,6 +2,7 @@ package com.ym.mec.biz.dal.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ym.mec.biz.dal.entity.ImLiveRoomVideo;
+import com.ym.mec.biz.dal.vo.ImLiveRoomVideoVo;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -17,5 +18,7 @@ public interface ImLiveRoomVideoDao extends BaseMapper<ImLiveRoomVideo> {
     int insertBatch(@Param("entities") List<ImLiveRoomVideo> entities);
 
     ImLiveRoomVideo getLastRecord(@Param("roomId") String roomId, @Param("recordId") String recordId);
+
+    List<ImLiveRoomVideoVo> queryVideoList(@Param("roomUid") String roomUid);
 }
 

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ImLiveBroadcastRoomDto.java

@@ -52,6 +52,9 @@ public class ImLiveBroadcastRoomDto implements Serializable {
     @ApiModelProperty(value = "直播间可见类型-全部可见 ALL / 部分可见 PRIVATE")
     private String popularizeType;
 
+    @ApiModelProperty(value = "播出端-  pc网页端 移动端mobile")
+    private String os = "pc";
+
     @ApiModel(value = "房间配置")
     public static class RoomConfig implements Serializable {
 
@@ -183,5 +186,12 @@ public class ImLiveBroadcastRoomDto implements Serializable {
         this.popularizeType = popularizeType;
     }
 
+    public String getOs() {
+        return os;
+    }
+
+    public void setOs(String os) {
+        this.os = os;
+    }
 }
 

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ImLiveBroadcastRoom.java

@@ -78,6 +78,10 @@ public class ImLiveBroadcastRoom implements Serializable {
     @ApiModelProperty(value = "直播间可见类型-全部可见 ALL / 部分可见 PRIVATE")
     private String popularizeType;
 
+    @TableField("os_")
+    @ApiModelProperty(value = "播出端-  pc网页端 移动端mobile")
+    private String os = "pc";
+
     @TableField("created_by_")
     @ApiModelProperty(value = "创建人")
     private Integer createdBy;
@@ -218,6 +222,14 @@ public class ImLiveBroadcastRoom implements Serializable {
         this.popularize = popularize;
     }
 
+    public String getOs() {
+        return os;
+    }
+
+    public void setOs(String os) {
+        this.os = os;
+    }
+
     public Integer getCreatedBy() {
         return createdBy;
     }

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/MessageTypeEnum.java

@@ -228,6 +228,8 @@ public enum MessageTypeEnum implements BaseEnum<String, MessageTypeEnum> {
 
     //直播推送
     JIGUANG_LIVE_RESERVATION("IM_LIVE_RESERVATION","直播开播预约提醒-极光推送"),
+    JIGUANG_LIVE_CREATED("IM_LIVE_CREATED","创建直播间-极光推送"),
+    JIGUANG_LIVE_STARTED("IM_LIVE_STARTED","直播已经开始-极光推送"),
 
     //小小训练营-训练营开始训练推送
     JIGUANG_TEMP_LITTLE_ARTIST_START_TRAIN("JIGUANG_TEMP_LITTLE_ARTIST_START_TRAIN","训练营开始训练推送-极光推送"),

+ 3 - 4
mec-biz/src/main/java/com/ym/mec/biz/dal/vo/ImLiveBroadcastRoomDetailVo.java

@@ -1,6 +1,5 @@
 package com.ym.mec.biz.dal.vo;
 
-import com.ym.mec.biz.dal.entity.ImLiveRoomVideo;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
@@ -43,7 +42,7 @@ public class ImLiveBroadcastRoomDetailVo implements Serializable {
     @ApiModelProperty(value = "直播状态 0未开始 1开始 2已结束")
     private Integer liveState;
 
-    private List<ImLiveRoomVideo> videoList;
+    private List<ImLiveRoomVideoVo> videoList;
 
     public Date getLiveStartTime() {
         return liveStartTime;
@@ -125,11 +124,11 @@ public class ImLiveBroadcastRoomDetailVo implements Serializable {
         this.totalLiveTime = totalLiveTime;
     }
 
-    public List<ImLiveRoomVideo> getVideoList() {
+    public List<ImLiveRoomVideoVo> getVideoList() {
         return videoList;
     }
 
-    public void setVideoList(List<ImLiveRoomVideo> videoList) {
+    public void setVideoList(List<ImLiveRoomVideoVo> videoList) {
         this.videoList = videoList;
     }
 }

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/vo/ImLiveRoomVideoVo.java

@@ -0,0 +1,22 @@
+package com.ym.mec.biz.dal.vo;
+
+import com.ym.mec.biz.dal.entity.ImLiveRoomVideo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+@ApiModel(value = "im_live_room_video-直播视频记录参数返回")
+public class ImLiveRoomVideoVo extends ImLiveRoomVideo implements Serializable {
+
+    @ApiModelProperty(value = "播出端-  pc网页端 移动端mobile")
+    private String os;
+
+    public String getOs() {
+        return os;
+    }
+
+    public void setOs(String os) {
+        this.os = os;
+    }
+}

+ 12 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/ImLiveBroadcastRoomService.java

@@ -27,7 +27,7 @@ public interface ImLiveBroadcastRoomService extends IService<ImLiveBroadcastRoom
 
     PageInfo<ImLiveBroadcastRoomVo> queryPage(Map<String, Object> param);
 
-    ImLiveBroadcastRoomVo queryRoomAndCheck(String roomUid, Integer userId,Integer osType);
+    ImLiveBroadcastRoomVo queryRoomAndCheck(String roomUid, Integer userId, Integer osType);
 
     ImLiveBroadcastRoomVo queryRoomInfo(String roomUid);
 
@@ -37,6 +37,14 @@ public interface ImLiveBroadcastRoomService extends IService<ImLiveBroadcastRoom
 
     void whetherChat(Integer id, Integer whetherChat);
 
+    /**
+     * 关闭房间-融云
+     * 获取所有直播间缓存数据并写入数据库后并清理缓存
+     *
+     * @param roomUid 直播间Uid
+     */
+    void roomDestroy(String roomUid);
+
     void roomDestroy(Integer id);
 
     void delete(Integer id);
@@ -60,17 +68,17 @@ public interface ImLiveBroadcastRoomService extends IService<ImLiveBroadcastRoom
 
     void opsRoom(List<ImUserState> userState);
 
-    ImLiveBroadcastRoomVo speakerJoinRoom(String roomUid);
+    ImLiveBroadcastRoomVo speakerJoinRoom(String roomUid, String os);
 
     void joinRoom(String roomUid, Integer userId);
 
-    void startLive(String roomUid, Integer userId);
+    void startLive(String roomUid, Integer userId,String videoResolution);
 
     void closeLive(String roomUid, Integer userId);
 
     void createLiveRoom();
 
-    Map<String, Object> test(String roomUid);
+    Map<String, Object> test(String roomUid,String userFlag);
 
     /**
      * @param roomUid 直播间uid

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/ImLiveRoomVideoService.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ym.mec.biz.dal.dao.ImLiveRoomVideoDao;
 import com.ym.mec.biz.dal.entity.ImLiveRoomVideo;
+import com.ym.mec.biz.dal.vo.ImLiveRoomVideoVo;
 
 import java.util.List;
 
@@ -16,6 +17,6 @@ public interface ImLiveRoomVideoService extends IService<ImLiveRoomVideo> {
 
     ImLiveRoomVideoDao getDao();
 
-    List<ImLiveRoomVideo> queryList(String roomUid);
+    List<ImLiveRoomVideoVo> queryList(String roomUid);
 }
 

+ 41 - 120
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -1,126 +1,18 @@
 package com.ym.mec.biz.service.impl;
 
-import static com.ym.mec.biz.dal.enums.GroupType.MUSIC;
-import static com.ym.mec.biz.dal.enums.GroupType.PRACTICE;
-import static com.ym.mec.biz.dal.enums.GroupType.VIP;
-import static com.ym.mec.biz.dal.enums.PracticeGroupType.FREE;
-import static com.ym.mec.biz.dal.enums.PracticeGroupType.TRIAL;
-import static com.ym.mec.biz.dal.enums.SysUserRoleEnum.ORGAN_MANAGER;
-
-import java.lang.reflect.InvocationTargetException;
-import java.math.BigDecimal;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import com.ym.mec.biz.dal.dto.*;
-import com.ym.mec.biz.dal.entity.*;
-import com.ym.mec.biz.dal.page.*;
-import org.apache.commons.collections.ListUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Lazy;
-import org.springframework.http.HttpStatus;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
-import org.springframework.util.CollectionUtils;
-
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.ActivityUserMapperDao;
-import com.ym.mec.biz.dal.dao.ClassGroupDao;
-import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
-import com.ym.mec.biz.dal.dao.ClassGroupTeacherMapperDao;
-import com.ym.mec.biz.dal.dao.ClassGroupTeacherSalaryDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleComplaintsDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleEvaluateDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleModifyLogDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleReviewDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleTeacherSalaryDao;
-import com.ym.mec.biz.dal.dao.CoursesGroupDao;
-import com.ym.mec.biz.dal.dao.CoursesGroupModifyLogDao;
-import com.ym.mec.biz.dal.dao.GroupDao;
-import com.ym.mec.biz.dal.dao.MusicGroupDao;
-import com.ym.mec.biz.dal.dao.PracticeGroupDao;
-import com.ym.mec.biz.dal.dao.PracticeGroupSellPriceDao;
-import com.ym.mec.biz.dal.dao.SchoolDao;
-import com.ym.mec.biz.dal.dao.StudentAttendanceDao;
-import com.ym.mec.biz.dal.dao.SubjectDao;
-import com.ym.mec.biz.dal.dao.SysConfigDao;
-import com.ym.mec.biz.dal.dao.TeacherAttendanceDao;
-import com.ym.mec.biz.dal.dao.TeacherDao;
-import com.ym.mec.biz.dal.dao.TeacherDefaultMusicGroupSalaryDao;
-import com.ym.mec.biz.dal.dao.TeacherDefaultPracticeGroupSalaryDao;
-import com.ym.mec.biz.dal.dao.TeacherDefaultVipGroupSalaryDao;
-import com.ym.mec.biz.dal.dao.VipGroupActivityDao;
-import com.ym.mec.biz.dal.dao.VipGroupCategoryDao;
-import com.ym.mec.biz.dal.dao.VipGroupDao;
+import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.dto.*;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
-import com.ym.mec.biz.dal.enums.AuditStatusEnum;
-import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
-import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
-import com.ym.mec.biz.dal.enums.CourseStatusEnum;
-import com.ym.mec.biz.dal.enums.GroupStatusEnum;
-import com.ym.mec.biz.dal.enums.GroupType;
-import com.ym.mec.biz.dal.enums.MessageTypeEnum;
-import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
-import com.ym.mec.biz.dal.enums.ParamEnum;
-import com.ym.mec.biz.dal.enums.PracticeGroupType;
-import com.ym.mec.biz.dal.enums.SalarySettlementTypeEnum;
-import com.ym.mec.biz.dal.enums.StudentAttendanceStatusEnum;
-import com.ym.mec.biz.dal.enums.SysUserRoleEnum;
-import com.ym.mec.biz.dal.enums.TeachModeEnum;
-import com.ym.mec.biz.dal.enums.TeachTypeEnum;
-import com.ym.mec.biz.dal.enums.VipGroupStatusEnum;
-import com.ym.mec.biz.dal.enums.YesOrNoEnum;
+import com.ym.mec.biz.dal.enums.*;
+import com.ym.mec.biz.dal.page.*;
 import com.ym.mec.biz.event.source.CourseEventSource;
 import com.ym.mec.biz.event.source.SendSeoMessageSource;
-import com.ym.mec.biz.service.ClassGroupService;
-import com.ym.mec.biz.service.ClassGroupTeacherMapperService;
-import com.ym.mec.biz.service.CourseHomeworkService;
-import com.ym.mec.biz.service.CourseScheduleService;
-import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
-import com.ym.mec.biz.service.CourseScheduleTeacherSalaryService;
-import com.ym.mec.biz.service.ImGroupMemberService;
-import com.ym.mec.biz.service.ImUserFriendService;
-import com.ym.mec.biz.service.MusicGroupService;
-import com.ym.mec.biz.service.MusicGroupTrainPlanService;
-import com.ym.mec.biz.service.PracticeGroupService;
-import com.ym.mec.biz.service.StudentServeService;
-import com.ym.mec.biz.service.SysConfigService;
-import com.ym.mec.biz.service.SysMessageService;
-import com.ym.mec.biz.service.SysTenantConfigService;
-import com.ym.mec.biz.service.TenantAssetsInfoService;
-import com.ym.mec.biz.service.TenantConfigService;
-import com.ym.mec.biz.service.VipGroupService;
+import com.ym.mec.biz.service.*;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -136,6 +28,35 @@ import com.ym.mec.util.collection.ListUtil;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.json.JsonUtil;
+import org.apache.commons.collections.ListUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
+import org.springframework.util.CollectionUtils;
+
+import java.lang.reflect.InvocationTargetException;
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static com.ym.mec.biz.dal.enums.GroupType.*;
+import static com.ym.mec.biz.dal.enums.PracticeGroupType.FREE;
+import static com.ym.mec.biz.dal.enums.PracticeGroupType.TRIAL;
+import static com.ym.mec.biz.dal.enums.SysUserRoleEnum.ORGAN_MANAGER;
 
 @Service
 public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSchedule> implements CourseScheduleService {
@@ -4651,6 +4572,11 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                 eduName = new HashMap<>(courseScheduleIds.size());
                 if (musicCourseIds != null && musicCourseIds.size() > 0) {
                     eduName.putAll(MapUtil.convertMybatisMap(musicGroupDao.queryEduNameMapByCourseId(musicCourseIds)));
+					//获取合作单位,只有groupType是 MUSIC 的才有合作单位
+					List<MusicGroupBasicDto> maps = musicGroupDao.findMusicByCourseIds(musicCourseIds);
+					for (MusicGroupBasicDto map : maps) {
+						cooperationMap.put(map.getId(), map);
+					}
                 }
                 List<Long> vipCourseIds = results.stream().filter(e -> e.getGroupType() == VIP).map(CourseScheduleEndDto::getId).collect(Collectors.toList());
                 if (vipCourseIds != null && vipCourseIds.size() > 0) {
@@ -4660,12 +4586,6 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                 if (practiceCourseIds != null && practiceCourseIds.size() > 0) {
                     eduName.putAll(MapUtil.convertMybatisMap(practiceGroupDao.queryEduNameMapByCourseId(practiceCourseIds)));
                 }
-
-                //获取合作单位,只有groupType是 MUSIC 的才有合作单位
-                List<MusicGroupBasicDto> maps = musicGroupDao.findMusicByCourseIds(musicCourseIds);
-                for (MusicGroupBasicDto map : maps) {
-                    cooperationMap.put(map.getId(), map);
-                }
             }
 
             for (CourseScheduleEndDto result : results) {
@@ -5377,6 +5297,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		if(schedule == null){
 			throw new BizException("课程不存在");
 		}
+		LOGGER.warn("teacherCourseRates courseScheduleId:{},userId{}",courseScheduleId,user.getId());
 		//如果是乐团课
 		List<CourseScheduleRateDto> courseScheduleRateDtos;
 		CourseSchedule courseSchedule;

+ 2 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveBroadcastRoomMemberServiceImpl.java

@@ -32,9 +32,8 @@ public class ImLiveBroadcastRoomMemberServiceImpl extends ServiceImpl<ImLiveBroa
 
     @Autowired
     private ImLiveBroadcastRoomDataService imLiveBroadcastRoomDataService;
-@Autowired
-private ImLiveRoomVideoService imLiveRoomVideoService;
-
+    @Autowired
+    private ImLiveRoomVideoService imLiveRoomVideoService;
 
     @Override
     public ImLiveBroadcastRoomMemberDao getDao() {

+ 157 - 39
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveBroadcastRoomServiceImpl.java

@@ -2,7 +2,6 @@ package com.ym.mec.biz.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -32,6 +31,7 @@ import com.ym.mec.common.page.PageUtil;
 import com.ym.mec.common.page.WrapperUtil;
 import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.im.ImFeignService;
+import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.excel.POIUtil;
@@ -133,31 +133,56 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
                 .map(this::getSysUser)
                 .orElseGet(this::getSysUser);
         osType = Optional.ofNullable(osType).orElse(1);
-        return queryRoomAndCheck(roomUid, sysUser, osType);
+        if (osType == 1) {
+            //学生端
+            return studentQueryRoomAndCheck(roomUid, sysUser);
+        } else if (osType == 2) {
+            //老师端
+            return teacherQueryRoomAndCheck(roomUid, sysUser);
+        }
+        return queryRoomAndCheck(roomUid, sysUser);
     }
 
-    public ImLiveBroadcastRoomVo queryRoomAndCheck(String roomUid, SysUser sysUser, Integer osType) {
-        Optional<ImLiveBroadcastRoomVo> optional;
+    public ImLiveBroadcastRoomVo studentQueryRoomAndCheck(String roomUid, SysUser sysUser) {
         //如果是学生端,则需要检查是否有权限进入
-        if (osType == 1) {
-            Map<String, Object> param = new HashMap<>();
-            param.put("roomUid", roomUid);
-            optional = Optional.of(param).map(this::getImLiveBroadcastRoomVo);
-            optional.orElseThrow(() -> new BizException("您无法观看该直播"));
-        } else {
-            optional = Optional.ofNullable(roomUid).map(this::queryRoomInfo);
-            optional.orElseThrow(() -> new BizException("直播间不存在"));
+        Map<String, Object> param = new HashMap<>();
+        param.put("roomUid", roomUid);
+        ImLiveBroadcastRoomVo vo = Optional.of(param).map(this::getImLiveBroadcastRoomVo)
+                .orElseThrow(() -> new BizException("您无法观看该直播"));
+        if (vo.getSpeakerId().equals(sysUser.getId())) {
+            throw new BizException("您是该直播间的主讲人,请从直播端进入");
+        }
+        if (vo.getLiveState() == 0) {
+            throw new BizException("直播尚未开始");
+        }
+        return queryRoomAndCheck(vo, sysUser);
+    }
+
+    public ImLiveBroadcastRoomVo teacherQueryRoomAndCheck(String roomUid, SysUser sysUser) {
+        ImLiveBroadcastRoomVo vo = Optional.ofNullable(roomUid).map(this::queryRoomInfo)
+                .orElseThrow(() -> new BizException("直播间不存在"));
+        if (vo.getOs().equals("pc")) {
+            throw new BizException("该直播间仅可在电脑端直播");
         }
+        return queryRoomAndCheck(vo, sysUser);
+    }
+
+    public ImLiveBroadcastRoomVo queryRoomAndCheck(String roomUid, SysUser sysUser) {
+        ImLiveBroadcastRoomVo vo = Optional.ofNullable(roomUid).map(this::queryRoomInfo)
+                .orElseThrow(() -> new BizException("直播间不存在"));
+        return queryRoomAndCheck(vo, sysUser);
+    }
+
+    public ImLiveBroadcastRoomVo queryRoomAndCheck(ImLiveBroadcastRoomVo room, SysUser sysUser) {
         //直播间信息校验
-        optional.filter(r -> r.getTenantId().equals(sysUser.getTenantId()))
-                .orElseThrow(() -> new BizException("您不是该直播机构人员,不可观看!"));
-        optional.filter(r -> r.getRoomState() != 1).orElseThrow(() -> new BizException("直播间不存在"));
-        ImLiveBroadcastRoomVo room = optional.get();
+        if (!room.getTenantId().equals(sysUser.getTenantId())) {
+            throw new BizException("您不是该直播机构人员,不可观看!");
+        }
+        if (room.getRoomState() == 1) {
+            throw new BizException("直播间不存在");
+        }
         if (room.getLiveState() == 0) {
             Date liveStartTime = DateUtil.addMinutes(room.getLiveStartTime(), -PRE_LIVE_TIME_MINUTE);
-            if (osType == 1) {
-                throw new BizException("直播尚未开始");
-            }
             throw new BizException(DateUtil.format(liveStartTime, "yyyy年MM月dd日 HH点mm分") + " 可进入直播间准备");
         }
         if (room.getLiveState() == 2) {
@@ -172,7 +197,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         room.setBlacklistFlag(0);
         //黑名单查询-查询当前用户是否在黑名单中
         int count = imLiveRoomBlackService.count(Wrappers.<ImLiveRoomBlack>lambdaQuery()
-                .eq(ImLiveRoomBlack::getRoomUid, roomUid)
+                .eq(ImLiveRoomBlack::getRoomUid, room.getRoomUid())
                 .eq(ImLiveRoomBlack::getUserId, sysUser.getId()));
         if (count > 0) {
             room.setBlacklistFlag(1);
@@ -266,6 +291,8 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         obj.setCreatedBy(getSysUser().getId());
         obj.setCreatedTime(now);
         this.save(obj);
+        //推送老师端-直播已经创建
+        sendRoomLiveState(sysUser, obj, MessageTypeEnum.JIGUANG_LIVE_CREATED);
     }
 
     /**
@@ -387,6 +414,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         PageInfo<ImLiveBroadcastRoomVo> pageInfo = imLiveRoomReservationService.queryPageStudent(param);
         List<ImLiveBroadcastRoomVo> list = pageInfo.getRows();
         if (CollectionUtils.isNotEmpty(list)) {
+            getRoomData(list.get(0));
             return list.get(0);
         }
         return null;
@@ -478,11 +506,28 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
      * 关闭房间-融云
      * 获取所有直播间缓存数据并写入数据库后并清理缓存
      *
+     * @param roomUid 直播间Uid
+     */
+    @Override
+    public void roomDestroy(String roomUid) {
+        ImLiveBroadcastRoom room = this.getOne(Wrappers.<ImLiveBroadcastRoom>lambdaQuery()
+                .eq(ImLiveBroadcastRoom::getRoomUid, roomUid));
+        opsRoomDestroy(room);
+    }
+
+    /**
+     * 关闭房间-融云
+     * 获取所有直播间缓存数据并写入数据库后并清理缓存
+     *
      * @param id 直播房间表id
      */
     @Override
     public void roomDestroy(Integer id) {
         ImLiveBroadcastRoom room = this.getById(id);
+        opsRoomDestroy(room);
+    }
+
+    private void opsRoomDestroy(ImLiveBroadcastRoom room) {
         if (Objects.isNull(room)) {
             return;
         }
@@ -781,6 +826,10 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
                 }
             }
         }
+        //如果退出时间大于进入时间就无需再次退出-直接返回
+        if (compareDate.apply(speakerInfo.getExitRoomTime(), speakerInfo.getJoinRoomTime())) {
+            return true;
+        }
         //主讲人退出房间关闭录像
         closeLive(speakerInfo);
         speakerInfo.setExitRoomTime(now);
@@ -794,9 +843,14 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
      *
      * @param roomUid
      */
-    public ImLiveBroadcastRoomVo speakerJoinRoom(String roomUid) {
+    public ImLiveBroadcastRoomVo speakerJoinRoom(String roomUid, String os) {
         SysUser sysUser = getSysUser();
-        ImLiveBroadcastRoomVo roomVo = queryRoomAndCheck(roomUid, sysUser, 0);
+        ImLiveBroadcastRoomVo roomVo;
+        if (os.equals("mobile")) {
+            roomVo = teacherQueryRoomAndCheck(roomUid, sysUser);
+        } else {
+            roomVo = queryRoomAndCheck(roomUid, sysUser);
+        }
         Integer userId = sysUser.getId();
         if (!userId.equals(roomVo.getSpeakerId())) {
             throw new BizException("您不是该直播间的主讲人");
@@ -871,7 +925,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
      *
      * @param roomUid 房间uid
      */
-    public void startLive(String roomUid, Integer userId) {
+    public void startLive(String roomUid, Integer userId, String videoResolution) {
         //查询房间信息
         RBucket<RoomSpeakerInfo> speakerCache = getRoomSpeakerInfoCache(roomUid, userId.toString());
         if (!speakerCache.isExists()) {
@@ -886,7 +940,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         if (intEquals(roomSpeakerInfo.getWhetherVideo(), 0)) {
             //开始录制视频
             try {
-                imFeignService.startRecord(roomUid);
+                imFeignService.startRecord(roomUid, videoResolution);
             } catch (Exception e) {
                 log.error("startRecord error: {}", e.getMessage());
             }
@@ -1038,6 +1092,8 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
             imFeignService.createLiveRoom(room.getRoomUid(), room.getRoomTitle());
             //推送预约直播间消息
             imLiveRoomReservationService.push(room);
+            //推送直播开始消息
+            sendRoomLiveState(sysUser, room, MessageTypeEnum.JIGUANG_LIVE_STARTED);
         } catch (Exception e) {
             log.error(">>>>>>>>>> createLiveRoom error roomUid:{} msg:{}", room.getRoomUid(), e.getMessage());
         }
@@ -1054,9 +1110,8 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         speakerInfo.setTenantId(sysUser.getTenantId());
         speakerInfo.setTotalLiveTime(0);
 
-        //查询房间信息是否允许录像
-        ImLiveBroadcastRoom one = this.getOne(new QueryWrapper<ImLiveBroadcastRoom>().eq("room_uid_", room.getRoomUid()));
-        boolean video = getRoomConfig(one.getRoomConfig())
+        //获取是否允许录像
+        boolean video = getRoomConfig(room.getRoomConfig())
                 .filter(c -> Objects.nonNull(c.getWhether_video()))
                 .map(c -> c.getWhether_video() == 0)
                 .orElse(false);
@@ -1067,6 +1122,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
             //不可以录制视频
             speakerInfo.setWhetherVideo(1);
         }
+        speakerInfo.setOs(room.getOs());
         //写入主讲人信息
         getRoomSpeakerInfoCache(room.getRoomUid(), room.getSpeakerId().toString()).set(speakerInfo);
 
@@ -1085,6 +1141,50 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
                 .map(c -> JSON.parseObject(c, ImLiveBroadcastRoomDto.RoomConfig.class));
     }
 
+    /**
+     * 推送老师端-直播已经创建/开始的消息
+     *
+     * @param user 用户信息
+     * @param room 房间信息
+     * @param en   直播列表地址
+     *             <P> /#/liveRoomList?t=0 未开始
+     *             <P>/#/liveRoomList 直播中
+     */
+    private void sendRoomLiveState(SysUser user, ImLiveBroadcastRoom room, MessageTypeEnum en) {
+        String teacherBaseUrl = sysConfigDao.findConfigValue(SysConfigService.TEACHER_BASE_URL);
+        if (StringUtils.isBlank(teacherBaseUrl)) {
+            log.error("sendRoomState error: teacherBaseUrl is null");
+            return;
+        }
+        teacherBaseUrl = "13?" + teacherBaseUrl;
+        Map<Integer, String> pushMap = new HashMap<>();
+        pushMap.put(user.getId(), user.getId().toString());
+        String memo;
+        Object[] objs;
+        try {
+            String liveDateStr = DateUtil.format(room.getLiveStartTime(), "yyyy年MM月dd日 HH点mm分");
+            //创建直播间
+            if (en.equals(MessageTypeEnum.JIGUANG_LIVE_CREATED)) {
+                //创建直播间-发送消息-跳到未开始页面
+                memo = teacherBaseUrl + "/#/liveRoomList?t=0";
+                SysUser createUser = getSysUser(room.getCreatedBy());
+                objs = new Object[]{createUser.getUsername(), liveDateStr, room.getLiveRemark()};
+            } else if (en.equals(MessageTypeEnum.JIGUANG_LIVE_STARTED)) {
+                //直播开始-发送消息-跳到直播中页面
+                memo = teacherBaseUrl + "/#/liveRoomList";
+                objs = new Object[]{liveDateStr, room.getRoomTitle()};
+            } else {
+                log.error("sendRoomState error: MessageTypeEnum error " + en);
+                return;
+            }
+            //发送消息
+            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, en, pushMap,
+                    null, 0, memo, "TEACHER", objs);
+        } catch (Exception e) {
+            log.error("sendRoomState error ", e.getCause());
+        }
+    }
+
     private void getRoomData(ImLiveBroadcastRoomVo roomVo) {
         //点赞数
         Object like = redissonClient.getBucket(LIVE_ROOM_LIKE.replace(ROOM_UID, roomVo.getRoomUid())).get();
@@ -1123,21 +1223,14 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
                 .orElseThrow(() -> new BizException("用户不存在."));
     }
 
-    @Autowired
-    private ImLiveRoomPurviewService imLiveRoomPurviewService;
-
     /**
      * 测试
      */
     public Map<String, Object> test(String roomUid) {
-//        Map<String, Object> map = new HashMap<>();
-//        TenantContextHolder.setTenantId(1);
-//        map.put("roomUid", roomUid);
-//        map.put("groupIds", "22053019304300001,1141,1");
-//        map.put("subjectIds", "2,5,4");
-//        PageInfo<SysUserDto> sysUserDtoPageInfo = imLiveRoomPurviewService.selectRoomPurviewStudent(map);
-//        System.out.println(sysUserDtoPageInfo);
+        return test(roomUid, null);
+    }
 
+    public Map<String, Object> test(String roomUid, String userFlag) {
         //test
         Map<String, Object> result = new HashMap<>();
         //校验房间心跳是否过期没续租
@@ -1176,12 +1269,14 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         if (CollectionUtils.isNotEmpty(totalUserInfo)) {
             if (CollectionUtils.isNotEmpty(inRoomUserInfo)) {
                 look = inRoomUserInfo.size();
-//                result.put("正在观看的人员信息", inRoomUserInfo);
+                Optional.ofNullable(userFlag)
+                        .ifPresent(a -> result.put("正在观看的人员信息", inRoomUserInfo));
             } else {
                 result.put("正在观看的人员信息", "没有正在观看的人员数据");
             }
             totalLook = totalUserInfo.size();
-//            result.put("总人员数据", totalUserInfo);
+            Optional.ofNullable(userFlag)
+                    .ifPresent(a -> result.put("总人员数据", totalUserInfo));
         } else {
             result.put("总人员数据", "没有人员数据");
         }
@@ -1458,6 +1553,19 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
     }
 
     /**
+     * 对比时间,2个时间一个为空返回false,否则对比时间大小
+     * <p>- date1 时间1
+     * <p>- date2 时间2
+     */
+    private final BiFunction<Date, Date, Boolean> compareDate = (date1, date2) -> {
+        if (Objects.nonNull(date1) && Objects.nonNull(date2)) {
+            return date1.getTime() > date2.getTime();
+        } else {
+            return false;
+        }
+    };
+
+    /**
      * 主讲人信息
      */
     public static class RoomSpeakerInfo implements Serializable {
@@ -1489,6 +1597,8 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         private Integer whetherVideo;
         //机构
         private Integer tenantId;
+        //播出端-  pc网页端 移动端mobile
+        private String os = "pc";
 
         public Integer getSpeakerId() {
             return speakerId;
@@ -1591,6 +1701,14 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         public void setEndLiveTime(Date endLiveTime) {
             this.endLiveTime = endLiveTime;
         }
+
+        public String getOs() {
+            return os;
+        }
+
+        public void setOs(String os) {
+            this.os = os;
+        }
     }
 
 }

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveRoomBlackServiceImpl.java

@@ -90,6 +90,8 @@ public class ImLiveRoomBlackServiceImpl extends ServiceImpl<ImLiveRoomBlackDao,
             this.save(imLiveRoomBlack);
             //发送消息到直播房间
             this.sendBlackMsg(roomUid, userId, userId, ImRoomMessage.BLOCK_BLACK_USER);
+            //调用融云方法加入禁言
+            imFeignService.addUserUnableSpeak(roomUid, userIdStr);
         });
     }
 
@@ -112,6 +114,8 @@ public class ImLiveRoomBlackServiceImpl extends ServiceImpl<ImLiveRoomBlackDao,
                     .eq(ImLiveRoomBlack::getUserId, userId));
             //发送消息到直播房间
             this.sendBlackMsg(roomUid, userId, userId, ImRoomMessage.UNBLOCK_BLACK_USER);
+            //调用融云方法加入禁言
+            imFeignService.removeUserUnableSpeak(roomUid, userIdStr);
         });
     }
 

+ 3 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveRoomVideoServiceImpl.java

@@ -1,20 +1,16 @@
 package com.ym.mec.biz.service.impl;
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ym.mec.biz.dal.dao.ImLiveRoomVideoDao;
 import com.ym.mec.biz.dal.entity.ImLiveRoomVideo;
+import com.ym.mec.biz.dal.vo.ImLiveRoomVideoVo;
 import com.ym.mec.biz.service.ImLiveRoomVideoService;
-import com.ym.mec.common.page.PageInfo;
-import com.ym.mec.common.page.PageUtil;
 import com.ym.mec.common.page.WrapperUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
-import java.util.Map;
 
 /**
  * 直播视频记录(ImLiveRoomVideo)表服务实现类
@@ -32,13 +28,9 @@ public class ImLiveRoomVideoServiceImpl extends ServiceImpl<ImLiveRoomVideoDao,
         return this.baseMapper;
     }
 
-    public List<ImLiveRoomVideo> queryList(String roomUid) {
-        return baseMapper.selectList(new WrapperUtil<ImLiveRoomVideo>()
-                .hasEq("room_uid_",roomUid)
-                .hasEq("type",2).queryWrapper()
-        );
+    public List<ImLiveRoomVideoVo> queryList(String roomUid) {
+        return baseMapper.queryVideoList(roomUid);
     }
 
-
 }
 

+ 5 - 3
mec-biz/src/main/resources/config/mybatis/ImLiveBroadcastRoomMapper.xml

@@ -16,6 +16,7 @@
         <result column="room_state_" jdbcType="INTEGER" property="roomState"/>
         <result column="popularize_" jdbcType="INTEGER" property="popularize"/>
         <result column="popularize_type_" jdbcType="VARCHAR" property="popularizeType"/>
+        <result column="os_" jdbcType="VARCHAR" property="os"/>
         <result column="created_by_" jdbcType="INTEGER" property="createdBy"/>
         <result column="created_time_" jdbcType="TIMESTAMP" property="createdTime"/>
         <result column="updated_by_" jdbcType="INTEGER" property="updatedBy"/>
@@ -26,13 +27,13 @@
             parameterType="com.ym.mec.biz.dal.entity.ImLiveBroadcastRoom">
         insert into im_live_broadcast_room(tenant_id_, speaker_id_, room_uid_, room_title_, live_start_time_,
         live_end_time_, live_remark_, pre_template_, room_config_, live_state_, room_state_,
-        popularize_, popularize_type_, created_by_, created_time_, updated_by_, updated_time_)
+        popularize_, popularize_type_, os_, created_by_, created_time_, updated_by_, updated_time_)
         values
         <foreach collection="entities" item="entity" separator=",">
             (#{entity.tenantId}, #{entity.speakerId}, #{entity.roomUid}, #{entity.roomTitle}, #{entity.liveStartTime},
             #{entity.liveEndTime}, #{entity.liveRemark}, #{entity.preTemplate}, #{entity.roomConfig},
-            #{entity.liveState}, #{entity.roomState}, #{entity.popularize},
-            #{entity.popularizeType}, #{entity.createdBy}, #{entity.createdTime}, #{entity.updatedBy},#{entity.updatedTime})
+            #{entity.liveState}, #{entity.roomState}, #{entity.popularize}, #{entity.popularizeType},#{entity.os},
+            #{entity.createdBy}, #{entity.createdTime}, #{entity.updatedBy},#{entity.updatedTime})
         </foreach>
     </insert>
 
@@ -41,6 +42,7 @@
         a.tenant_id_ AS tenantId,
         t.name_ AS tenantName,
         t.logo_ AS tenantLogo,
+        a.os_ AS os,
         a.room_uid_ AS roomUid,
         a.room_title_ AS roomTitle,
         a.live_remark_ AS liveRemark,

+ 1 - 0
mec-biz/src/main/resources/config/mybatis/ImLiveRoomReservationMapper.xml

@@ -28,6 +28,7 @@
         a.tenant_id_ AS tenantId,
         t.name_ AS tenantName,
         t.logo_ AS tenantLogo,
+        a.os_ AS os,
         a.room_uid_ AS roomUid,
         a.room_title_ AS roomTitle,
         a.live_remark_ AS liveRemark,

+ 9 - 0
mec-biz/src/main/resources/config/mybatis/ImLiveRoomVideoMapper.xml

@@ -27,8 +27,17 @@
             #{entity.endTime}, #{entity.type}, #{entity.createdTime})
         </foreach>
     </insert>
+
     <select id="getLastRecord" resultMap="BaseResultMap">
         SELECT * FROM im_live_room_video WHERE room_uid_ = #{roomId} AND record_id_ = #{recordId} ORDER BY id_ DESC LIMIT 1
     </select>
 
+    <select id="queryVideoList" parameterType="object" resultType="com.ym.mec.biz.dal.vo.ImLiveRoomVideoVo">
+        select a.*,b.os_ as os
+        from im_live_room_video a
+                 left join im_live_broadcast_room b on a.room_uid_ = b.room_uid_
+        where a.room_uid_ = #{roomUid}
+          and a.type = 2
+    </select>
+
 </mapper>

+ 19 - 1
mec-client-api/src/main/java/com/ym/mec/im/ImFeignService.java

@@ -160,7 +160,7 @@ public interface ImFeignService {
      * @date 2022/2/25 13:52
      */
     @PostMapping(value = "/liveRoom/startRecord")
-    void startRecord(@RequestParam("roomId") String roomId);
+    void startRecord(@RequestParam("roomId") String roomId, @RequestParam("videoResolution") String videoResolution);
 
     /**
      * @param roomId
@@ -198,4 +198,22 @@ public interface ImFeignService {
     @PostMapping(value = "/liveRoom/checkOnline")
     boolean checkOnline(@RequestParam("userId") String userId);
 
+    /**
+     * 添加禁言成员-默认禁言120分钟
+     *
+     * @param roomUid 房间uid
+     * @param userId  用户id
+     */
+    @PostMapping(value ="/liveRoom/addUserUnableSpeak")
+    boolean addUserUnableSpeak(@RequestParam("roomUid") String roomUid, @RequestParam("userId") String userId);
+
+    /**
+     * 移除禁言成员
+     *
+     * @param roomUid 房间uid
+     * @param userId  用户id
+     */
+    @PostMapping(value ="/liveRoom/removeUserUnableSpeak")
+    boolean removeUserUnableSpeak(@RequestParam("roomUid") String roomUid, @RequestParam("userId") String userId);
+
 }

+ 11 - 1
mec-client-api/src/main/java/com/ym/mec/im/fallback/ImFeignServiceFallback.java

@@ -91,7 +91,7 @@ public class ImFeignServiceFallback implements ImFeignService {
     }
 
     @Override
-    public void startRecord(String roomId) {
+    public void startRecord(String roomId, String videoResolution) {
 
     }
 
@@ -115,4 +115,14 @@ public class ImFeignServiceFallback implements ImFeignService {
         return false;
     }
 
+    @Override
+    public boolean addUserUnableSpeak(String roomUid, String userId) {
+        return false;
+    }
+
+    @Override
+    public boolean removeUserUnableSpeak(String roomUid, String userId) {
+        return false;
+    }
+
 }

+ 2 - 1
mec-im/src/main/java/com/ym/config/ResourceServerConfig.java

@@ -15,7 +15,8 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
                         "/room/statusImMsg", "/group/batchDismiss", "/private/send", "/group/send",
                         "/group/dismiss", "/room/statusImMsg", "/history/get", "/user/statusImUser", "/liveRoom/recordSync",
                         "/liveRoom/publishRoomMsg", "/liveRoom/destroy", "/liveRoom/create", "/liveRoom/startRecord",
-                        "/liveRoom/stopRecord", "/liveRoom/userExistInRoom","/liveRoom/checkOnline")
+                        "/liveRoom/stopRecord", "/liveRoom/userExistInRoom","/liveRoom/checkOnline",
+                        "/liveRoom/addUserUnableSpeak","/liveRoom/removeUserUnableSpeak","/liveRoom/syncChatRoomStatus")
                 .permitAll().anyRequest().authenticated().and().csrf().disable();
     }
 }

+ 15 - 3
mec-im/src/main/java/com/ym/controller/LiveRoomController.java

@@ -53,8 +53,8 @@ public class LiveRoomController {
 
     @ApiOperation("录制直播")
     @RequestMapping(value = "/startRecord")
-    public void startRecord(String roomId) throws Exception {
-        liveRoomService.startRecord(roomId);
+    public void startRecord(String roomId, String videoResolution) throws Exception {
+        liveRoomService.startRecord(roomId, videoResolution);
     }
 
     @ApiOperation("结束录制直播")
@@ -75,6 +75,18 @@ public class LiveRoomController {
         return liveRoomService.checkOnline(userId);
     }
 
+    @ApiOperation("添加禁言成员-默认禁言120分钟")
+    @PostMapping(value = "/addUserUnableSpeak")
+    public boolean addUserUnableSpeak(String roomUid, String userId) {
+        return liveRoomService.addUserUnableSpeak(roomUid, userId);
+    }
+
+    @ApiOperation("移除禁言成员")
+    @PostMapping(value = "/removeUserUnableSpeak")
+    public boolean removeUserUnableSpeak(String roomUid, String userId) {
+        return liveRoomService.removeUserUnableSpeak(roomUid, userId);
+    }
+
     /**
      * https://doc.rongcloud.cn/imserver/server/v1/chatroom/status
      */
@@ -83,5 +95,5 @@ public class LiveRoomController {
     public void syncChatRoomStatus(@RequestBody String body) {
         log.info("syncChatRoomStatus body:{}", body);
     }
-    
+
 }

+ 36 - 0
mec-im/src/main/java/com/ym/mec/im/IMHelper.java

@@ -490,4 +490,40 @@ public class IMHelper {
         return (IMUserOnlineInfo) GsonUtil.fromJson(httpHelper.returnResult(conn), IMUserOnlineInfo.class);
     }
 
+    /**
+     * 添加禁言成员
+     *
+     * @param userId  用户 ID,可同时禁言多个用户,最多不超过 20 个。
+     * @param roomUid 聊天室 ID。
+     * @param minute  禁言时长,以分钟为单位,最大值为 43200 分钟。
+     */
+    public IMApiResultInfo addUserUnableSpeak(String roomUid, String userId, String minute) throws Exception {
+        String body = "&userId=" + URLEncoder.encode(userId, UTF8) +
+                "&chatroomId=" + URLEncoder.encode(roomUid, UTF8) +
+                "&minute=" + URLEncoder.encode(minute, UTF8);
+        if (body.indexOf("&") == 0) {
+            body = body.substring(1);
+        }
+        HttpURLConnection conn = httpHelper.createIMPostHttpConnection("/chatroom/user/gag/add.json", "application/x-www-form-urlencoded");
+        httpHelper.setBodyParameter(body, conn);
+        return (IMApiResultInfo) GsonUtil.fromJson(httpHelper.returnResult(conn), IMApiResultInfo.class);
+    }
+
+    /**
+     * 移除禁言成员
+     *
+     * @param userId  用户 ID
+     * @param roomUid 聊天室 ID。
+     */
+    public IMApiResultInfo removeUserUnableSpeak(String roomUid, String userId) throws Exception {
+        String body = "&userId=" + URLEncoder.encode(userId, UTF8) +
+                "&chatroomId=" + URLEncoder.encode(roomUid, UTF8);
+        if (body.indexOf("&") == 0) {
+            body = body.substring(1);
+        }
+        HttpURLConnection conn = httpHelper.createIMPostHttpConnection("/chatroom/user/gag/rollback.json", "application/x-www-form-urlencoded");
+        httpHelper.setBodyParameter(body, conn);
+        return (IMApiResultInfo) GsonUtil.fromJson(httpHelper.returnResult(conn), IMApiResultInfo.class);
+    }
+
 }

+ 49 - 2
mec-im/src/main/java/com/ym/service/Impl/LiveRoomServiceImpl.java

@@ -107,11 +107,14 @@ public class LiveRoomServiceImpl implements LiveRoomService {
     }
 
     @Override
-    public void startRecord(String roomId) throws Exception {
+    public void startRecord(String roomId, String videoResolution) throws Exception {
         log.error("开始录制直播:roomId : {} ", roomId);
         JSONObject paramJson = new JSONObject();
         paramJson.put("sessionId", getRoomSessionId(roomId));
-        paramJson.put("config", new RecordConfig());
+        RecordConfig recordConfig = new RecordConfig();
+        Optional.ofNullable(videoResolution)
+                .ifPresent(recordConfig::setVideoResolution);
+        paramJson.put("config", recordConfig);
         String body = paramJson.toJSONString();
         HttpURLConnection conn = httpHelper.createIMRtcPostHttpConnection("/rtc/record/start.json", "application/json", roomId);
         httpHelper.setBodyParameter(body, conn);
@@ -237,6 +240,50 @@ public class LiveRoomServiceImpl implements LiveRoomService {
         return Objects.equals("1", resultInfo.getStatus());
     }
 
+    /**
+     * 添加禁言成员-默认禁言120分钟
+     *
+     * @param roomUid 房间uid
+     * @param userId  用户id
+     */
+    public boolean addUserUnableSpeak(String roomUid, String userId) {
+        log.info("addUserUnableToSpeak chatroomId : {}  userId : {}", roomUid, userId);
+        IMApiResultInfo resultInfo;
+        try {
+            resultInfo = imHelper.addUserUnableSpeak(roomUid, userId, "120");
+        } catch (Exception e) {
+            log.error("addUserUnableToSpeak chatroomId error: {}  userId : {}", roomUid, userId);
+            return false;
+        }
+        if (!resultInfo.isSuccess()) {
+            log.error("addUserUnableToSpeak chatroomId : {}  userId : {}", roomUid, userId);
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 移除禁言成员
+     *
+     * @param roomUid 房间uid
+     * @param userId  用户id
+     */
+    public boolean removeUserUnableSpeak(String roomUid, String userId) {
+        log.info("removeUserUnableSpeak chatroomId : {}  userId : {}", roomUid, userId);
+        IMApiResultInfo resultInfo;
+        try {
+            resultInfo = imHelper.removeUserUnableSpeak(roomUid, userId);
+        } catch (Exception e) {
+            log.error("removeUserUnableSpeak chatroomId error: {}  userId : {}", roomUid, userId);
+            return false;
+        }
+        if (!resultInfo.isSuccess()) {
+            log.error("removeUserUnableSpeak chatroomId : {}  userId : {}", roomUid, userId);
+            return false;
+        }
+        return true;
+    }
+
     public String getRoomSessionId(String roomId) {
         RBucket<String> bucket = redissonClient.getBucket("sessionId:" + roomId);
         if (bucket.isExists()) {

+ 16 - 1
mec-im/src/main/java/com/ym/service/LiveRoomService.java

@@ -23,7 +23,7 @@ public interface LiveRoomService {
     * @author zx
     * @date 2022/2/25 10:00
     */
-    void startRecord(String roomId) throws Exception;
+    void startRecord(String roomId, String videoResolution) throws Exception;
 
     /**
     * @description: 结束录制直播
@@ -47,4 +47,19 @@ public interface LiveRoomService {
 
     boolean checkOnline(String userId);
 
+    /**
+     * 添加禁言成员-默认禁言120分钟
+     *
+     * @param roomUid 房间uid
+     * @param userId  用户id
+     */
+    boolean addUserUnableSpeak(String roomUid, String userId);
+
+    /**
+     * 移除禁言成员
+     *
+     * @param roomUid 房间uid
+     * @param userId  用户id
+     */
+    boolean removeUserUnableSpeak(String roomUid, String userId);
 }

+ 0 - 30
mec-student/src/main/java/com/ym/mec/student/controller/ImLiveBroadcastRoomController.java

@@ -48,26 +48,12 @@ public class ImLiveBroadcastRoomController extends BaseController {
         return succeed(imLiveBroadcastRoomService.queryRoomAndCheck(roomUid, userId, 1));
     }
 
-    @ApiOperation("同步点赞数量")
-    @GetMapping("/syncLike")
-    public HttpResponseResult<Object> syncLike(@ApiParam(value = "房间uid", required = true) String roomUid,
-                                               @ApiParam(value = "点赞数", required = true) Integer likeNum) {
-        imLiveBroadcastRoomService.syncLike(roomUid, likeNum);
-        return succeed();
-    }
-
     @PostMapping("/quitRoom")
     public HttpResponseResult<Object> quitRoom(@RequestBody List<ImUserState> userState) {
         imLiveBroadcastRoomService.opsRoom(userState);
         return succeed();
     }
 
-    @ApiOperation("主讲人进入房间")
-    @GetMapping("/speakerJoinRoom")
-    public HttpResponseResult<ImLiveBroadcastRoomVo> speakerJoinRoom(String roomUid) {
-        return succeed(imLiveBroadcastRoomService.speakerJoinRoom(roomUid));
-    }
-
     @ApiOperation("学生-进入房间")
     @GetMapping("/joinRoom")
     public HttpResponseResult<Object> joinRoom(String roomUid, Integer userId) {
@@ -75,21 +61,5 @@ public class ImLiveBroadcastRoomController extends BaseController {
         return succeed();
     }
 
-    @ApiOperation("开启/关闭直播的录像")
-    @GetMapping("/opsLiveVideo")
-    public HttpResponseResult<Object> opsLiveVideo(@ApiParam(value = "房间uid", required = true) String roomUid,
-                                                   @ApiParam(value = "用户id", required = true) Integer userId,
-                                                   @ApiParam(value = "type 1:开始直播-开始录像     2:关闭直播关闭录像", required = true) Integer type) {
-        if (type == 1) {
-            imLiveBroadcastRoomService.startLive(roomUid, userId);
-        } else if (type == 2) {
-            imLiveBroadcastRoomService.closeLive(roomUid, userId);
-        } else {
-            failed("type参数错误");
-        }
-        return succeed();
-    }
-
-
 }
 

+ 2 - 1
mec-student/src/main/java/com/ym/mec/student/controller/ImLiveRoomVideoController.java

@@ -1,6 +1,7 @@
 package com.ym.mec.student.controller;
 
 import com.ym.mec.biz.dal.entity.ImLiveRoomVideo;
+import com.ym.mec.biz.dal.vo.ImLiveRoomVideoVo;
 import com.ym.mec.biz.service.ImLiveRoomVideoService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -26,7 +27,7 @@ public class ImLiveRoomVideoController extends BaseController {
 
     @ApiOperation("查询该机构目前推广的直播间")
     @GetMapping(value = "/queryList")
-    public HttpResponseResult<List<ImLiveRoomVideo>> queryList(String roomUid) {
+    public HttpResponseResult<List<ImLiveRoomVideoVo>> queryList(String roomUid) {
         return succeed(imLiveRoomVideoService.queryList(roomUid));
     }
 }

+ 19 - 12
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherImLiveBroadcastRoomController.java

@@ -18,6 +18,7 @@ import javax.annotation.Resource;
 import javax.validation.Valid;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 
 /**
  * 直播房间管理表(ImLiveBroadcastRoom)表控制层
@@ -73,9 +74,9 @@ public class TeacherImLiveBroadcastRoomController extends BaseController {
     }
 
     @ApiOperation("关闭直播间")
-    @GetMapping(value = "/roomDestroy/{id}")
-    public HttpResponseResult<Object> roomDestroy(@ApiParam(value = "房间表id", required = true) @PathVariable("id") Integer id) {
-        imLiveBroadcastRoomService.roomDestroy(id);
+    @GetMapping(value = "/roomDestroy")
+    public HttpResponseResult<Object> roomDestroy(@ApiParam(value = "房间Uid", required = true) String roomUid) {
+        imLiveBroadcastRoomService.roomDestroy(roomUid);
         return succeed();
     }
 
@@ -87,21 +88,27 @@ public class TeacherImLiveBroadcastRoomController extends BaseController {
         return succeed();
     }
 
-    @PostMapping("/quitRoom")
-    public HttpResponseResult<Object> quitRoom(@RequestBody List<ImUserState> userState) {
-        imLiveBroadcastRoomService.opsRoom(userState);
+    @ApiOperation("开启/关闭直播的录像")
+    @GetMapping("/opsLiveVideo")
+    public HttpResponseResult<Object> opsLiveVideo(@ApiParam(value = "房间uid", required = true) String roomUid,
+                                                   @ApiParam(value = "用户id", required = true) Integer userId,
+                                                   @ApiParam(value = "type 1:开始直播-开始录像     2:关闭直播关闭录像", required = true) Integer type,
+                                                   @ApiParam(value = "录制视频的尺寸-默认值是720x1280") String videoResolution) {
+        if (type == 1) {
+            videoResolution = Optional.ofNullable(videoResolution).orElse("720x1280");
+            imLiveBroadcastRoomService.startLive(roomUid, userId, videoResolution);
+        } else if (type == 2) {
+            imLiveBroadcastRoomService.closeLive(roomUid, userId);
+        } else {
+            failed("type参数错误");
+        }
         return succeed();
     }
 
     @ApiOperation("主讲人进入房间")
     @GetMapping("/speakerJoinRoom")
     public HttpResponseResult<ImLiveBroadcastRoomVo> speakerJoinRoom(String roomUid) {
-        return succeed(imLiveBroadcastRoomService.speakerJoinRoom(roomUid));
-    }
-
-    @GetMapping("/test")
-    public Object test(String roomUid) {
-        return imLiveBroadcastRoomService.test(roomUid);
+        return succeed(imLiveBroadcastRoomService.speakerJoinRoom(roomUid,"mobile"));
     }
 
     @GetMapping("/shareGroup")

+ 33 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherImLiveRoomVideoController.java

@@ -0,0 +1,33 @@
+package com.ym.mec.teacher.controller;
+
+import com.ym.mec.biz.dal.entity.ImLiveRoomVideo;
+import com.ym.mec.biz.dal.vo.ImLiveRoomVideoVo;
+import com.ym.mec.biz.service.ImLiveRoomVideoService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Api(tags = "直播回放录像记录表")
+@RestController
+@RequestMapping("/imLiveRoomVideo")
+public class TeacherImLiveRoomVideoController extends BaseController {
+
+    /**
+     * 服务对象
+     */
+    @Resource
+    private ImLiveRoomVideoService imLiveRoomVideoService;
+
+    @ApiOperation("查询该机构目前推广的直播间")
+    @GetMapping(value = "/queryList")
+    public HttpResponseResult<List<ImLiveRoomVideoVo>> queryList(String roomUid) {
+        return succeed(imLiveRoomVideoService.queryList(roomUid));
+    }
+}

+ 192 - 228
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/provider/JiguangPushPlugin.java

@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.thirdparty.exception.ThirdpartyException;
 import com.ym.mec.thirdparty.message.MessageSenderPlugin;
 import com.ym.mec.util.http.HttpUtil;
-
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.InitializingBean;
@@ -15,7 +14,7 @@ import org.springframework.stereotype.Service;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.HashMap;
-import java.util.Map;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 /**
@@ -24,164 +23,173 @@ import java.util.stream.Collectors;
 @Service
 public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean {
 
-	@Value("${push.jiguang.appKey.student}")
-	private String studentAppKey;
-	@Value("${push.jiguang.masterSecret.student}")
-	private String studentMasterSecret;
-
-	@Value("${push.jiguang.appKey.teacher}")
-	private String teacherAppKey;
-	@Value("${push.jiguang.masterSecret.teacher}")
-	private String teacherMasterSecret;
-
-	@Value("${push.jiguang.appKey.system}")
-	private String systemAppKey;
-	@Value("${push.jiguang.masterSecret.system}")
-	private String systemMasterSecret;
-
-	@Value("${push.jiguang.apns_production:false}")
-	private boolean apns_production = true; // 推送环境 True 表示推送生产环境,False 表示要推送开发环境
-
-	@Value("${push.jiguang.time_to_live:86400}")
-	private int time_to_live = 86400; // 离线保留时长 秒为单位 默认1天 最大10天
-
-	@Value("${push.jiguang.reqURL:https://api.jpush.cn/v3/push}")
-	private String reqURL = "https://api.jpush.cn/v3/push";// 请求极光地址
-
-	public static String getName() {
-		return "jiguang";
-	}
-
-	/**
-	 * 组装推送Json串
-	 *
-	 * @param alias 别名推送
-	 * @param alert 消息
-	 * @param content 消息内容
-	 * @return json对象
-	 */
-	private JSONObject generateJson(String[] alias, String alert, String content, String url,String sound,String channelId) {
-		JSONObject json = new JSONObject();
-		JSONArray platform = new JSONArray();// 平台
-		platform.add("android");
-		platform.add("ios");
-
-		JSONObject audience = new JSONObject();// 推送目标
-		JSONArray aliasJsonArr = new JSONArray();
-		for (String alia : alias) {
-			aliasJsonArr.add(alia);
-		}
-		audience.put("alias", aliasJsonArr);
-
-		JSONObject notification = new JSONObject();// 通知内容
-		JSONObject android = new JSONObject();// android通知内容
-		android.put("alert", alert);
-		android.put("sound", sound.split("\\.")[0]);
-		JSONObject options = new JSONObject();// 设置参数
-		if(StringUtils.isNotEmpty(channelId)){
-			JSONObject thirdParty = new JSONObject();
-			JSONObject xiaomi = new JSONObject();
-			xiaomi.put("distribution","secondary_push");
-			xiaomi.put("channel_id",channelId);
-			thirdParty.put("xiaomi",xiaomi);
-			options.put("third_party_channel",thirdParty);
-		}
-		android.put("builder_id", 1);
-		JSONObject android_extras = new JSONObject();// android额外参数
-		android_extras.put("type", "infomation");
-		android_extras.put("url", url);
-		android_extras.put("memo", url);
-		android.put("extras", android_extras);
-        //2022年5月27日 增加以下参数,是因为安卓无法跳转到APP中
-        JSONObject intentParam = new JSONObject();
-//        intentParam.put("url", "intent:#Intent;action=android.intent.action.MAIN;end");
-        //2022年6月3日 修改参数,安卓通知需要后台修改
-        intentParam.put("url", "intent:#Intent;action=cn.jiguang.push.customAction;component=com.daya.studaya_android/com.daya.studaya_android.ui.MainActivity;end");
-        android.put("intent", intentParam);
-
-		JSONObject ios = new JSONObject();// ios通知内容
-		ios.put("alert", alert);
-		ios.put("sound", sound);
-		ios.put("badge", "+1");
-		JSONObject ios_extras = new JSONObject();// ios额外参数
-		ios_extras.put("type", "infomation");
-		ios_extras.put("url", url);
-		ios_extras.put("memo", url);
-		ios.put("extras", ios_extras);
-		notification.put("android", android);
-		notification.put("ios", ios);
-
-		JSONObject message = new JSONObject();// 通知消息内容
-		message.put("title", alert);
-		message.put("msg_content", content);
-		message.put("content_type","text");
-
-		options.put("time_to_live", this.time_to_live);
-		options.put("apns_production", this.apns_production);
-
-		json.put("platform", platform);
-		json.put("audience", audience);
-		json.put("notification", notification);
-		json.put("options", options);
-		json.put("message", message);
-		return json;
-
-	}
-
-	/**
-	 * 调用极光api
-	 * @param alias 推送对象别名
-	 * @param alert 推送消息
-	 * @param content 推送内容
-	 */
-	private String push(String[] alias, String alert, String content, String url,String type,String sound,String channelId) {
-		String base64_auth_string = "";
-		switch (type){
-			case "STUDENT":
-				base64_auth_string = encryptBASE64(this.studentAppKey + ":" + this.studentMasterSecret);
-				break;
-			case "TEACHER":
-				base64_auth_string = encryptBASE64(this.teacherAppKey + ":" + this.teacherMasterSecret);
-				break;
-			default:
-				base64_auth_string = encryptBASE64(this.systemAppKey + ":" + this.systemMasterSecret);
-				break;
-		}
-		String authorization = "Basic " + base64_auth_string;
-		return sendPostRequest(generateJson(alias, alert, content, url,sound,channelId).toString(), authorization);
-	}
-
-	/**
-	 * 发送Post请求(json格式)
-	 *
-	 * @param data //封装的json串
-	 * @param authorization 验签
-	 * @return result 返回一个json字符串
-	 */
-	private String sendPostRequest(String data, String authorization) {
-		String result = "";
-		HashMap<String, String> reqHeader = new HashMap<>();
-		reqHeader.put("Authorization", authorization.trim());
-		try {
-			result = HttpUtil.postForHttps(this.reqURL, data, reqHeader);
-		} catch (Exception e) {
-			throw new ThirdpartyException("HttpUtil Connection Exception", e);
-		}
-		return result;
-	}
-
-	/**
-	 *     * BASE64加密工具
-	 */
-	private String encryptBASE64(String str) {
-		byte[] key = str.getBytes();
-		String strs = Base64.encodeBase64String(key);
-		return strs;
-	}
-
-	@Override
-	public void afterPropertiesSet() throws Exception {
-		// 参数检查
+    @Value("${push.jiguang.appKey.student}")
+    private String studentAppKey;
+    @Value("${push.jiguang.masterSecret.student}")
+    private String studentMasterSecret;
+
+    @Value("${push.jiguang.appKey.teacher}")
+    private String teacherAppKey;
+    @Value("${push.jiguang.masterSecret.teacher}")
+    private String teacherMasterSecret;
+
+    @Value("${push.jiguang.appKey.system}")
+    private String systemAppKey;
+    @Value("${push.jiguang.masterSecret.system}")
+    private String systemMasterSecret;
+
+    @Value("${push.jiguang.apns_production:false}")
+    private boolean apns_production = true; // 推送环境 True 表示推送生产环境,False 表示要推送开发环境
+
+    @Value("${push.jiguang.time_to_live:86400}")
+    private int time_to_live = 86400; // 离线保留时长 秒为单位 默认1天 最大10天
+
+    @Value("${push.jiguang.reqURL:https://api.jpush.cn/v3/push}")
+    private String reqURL = "https://api.jpush.cn/v3/push";// 请求极光地址
+
+    public static String getName() {
+        return "jiguang";
+    }
+
+    /**
+     * 组装推送Json串
+     *
+     * @param alias   别名推送
+     * @param alert   消息
+     * @param content 消息内容
+     * @return json对象
+     */
+    private JSONObject generateJson(String[] alias, String alert, String content, String url, String sound, String channelId, JSONObject androidIntent) {
+        JSONObject json = new JSONObject();
+        JSONArray platform = new JSONArray();// 平台
+        platform.add("android");
+        platform.add("ios");
+
+        JSONObject audience = new JSONObject();// 推送目标
+        JSONArray aliasJsonArr = new JSONArray();
+        for (String alia : alias) {
+            aliasJsonArr.add(alia);
+        }
+        audience.put("alias", aliasJsonArr);
+
+        JSONObject notification = new JSONObject();// 通知内容
+        JSONObject android = new JSONObject();// android通知内容
+        android.put("alert", alert);
+        android.put("sound", sound.split("\\.")[0]);
+        JSONObject options = new JSONObject();// 设置参数
+        if (StringUtils.isNotEmpty(channelId)) {
+            JSONObject thirdParty = new JSONObject();
+            JSONObject xiaomi = new JSONObject();
+            xiaomi.put("distribution", "secondary_push");
+            xiaomi.put("channel_id", channelId);
+            thirdParty.put("xiaomi", xiaomi);
+            options.put("third_party_channel", thirdParty);
+        }
+        android.put("builder_id", 1);
+        JSONObject android_extras = new JSONObject();// android额外参数
+        android_extras.put("type", "infomation");
+        android_extras.put("url", url);
+        android_extras.put("memo", url);
+        //2022年6月22日 增加 third_url_encode 参数,极光推送数据中带有#号需要转译
+        android_extras.put("third_url_encode", true);
+        android.put("extras", android_extras);
+        Optional.ofNullable(androidIntent)
+                .ifPresent(intent -> android.put("intent", intent));
+
+        JSONObject ios = new JSONObject();// ios通知内容
+        ios.put("alert", alert);
+        ios.put("sound", sound);
+        ios.put("badge", "+1");
+        JSONObject ios_extras = new JSONObject();// ios额外参数
+        ios_extras.put("type", "infomation");
+        ios_extras.put("url", url);
+        ios_extras.put("memo", url);
+        ios.put("extras", ios_extras);
+        notification.put("android", android);
+        notification.put("ios", ios);
+
+        JSONObject message = new JSONObject();// 通知消息内容
+        message.put("title", alert);
+        message.put("msg_content", content);
+        message.put("content_type", "text");
+
+        options.put("time_to_live", this.time_to_live);
+        options.put("apns_production", this.apns_production);
+
+        json.put("platform", platform);
+        json.put("audience", audience);
+        json.put("notification", notification);
+        json.put("options", options);
+        json.put("message", message);
+        return json;
+
+    }
+
+    /**
+     * 调用极光api
+     *
+     * @param alias   推送对象别名
+     * @param alert   推送消息
+     * @param content 推送内容
+     */
+    private String push(String[] alias, String alert, String content, String url, String type, String sound, String channelId) {
+        String base64_auth_string = "";
+        JSONObject androidIntent = null;
+        switch (type) {
+            case "STUDENT":
+                base64_auth_string = encryptBASE64(this.studentAppKey + ":" + this.studentMasterSecret);
+                androidIntent = new JSONObject();
+                //2022年5月27日 增加以下参数,是因为安卓无法跳转到APP中
+                //intentParam.put("url", "intent:#Intent;action=android.intent.action.MAIN;end");
+                //2022年6月3日 修改参数,安卓通知需要后台修改
+                androidIntent.put("url", "intent:#Intent;action=cn.jiguang.push.customAction;component=com.daya.studaya_android/com.daya.studaya_android.ui.MainActivity;end");
+                break;
+            case "TEACHER":
+                base64_auth_string = encryptBASE64(this.teacherAppKey + ":" + this.teacherMasterSecret);
+                androidIntent = new JSONObject();
+                //2022年6月22日增加url参数 针对教师端
+                androidIntent.put("url", "intent:#Intent;action=cn.jiguang.push.customAction;component=com.dayayuemeng.teacher/com.dayayuemeng.teacher.ui.MainActivity;end");
+                break;
+            default:
+                base64_auth_string = encryptBASE64(this.systemAppKey + ":" + this.systemMasterSecret);
+                break;
+        }
+        String authorization = "Basic " + base64_auth_string;
+        JSONObject jsonObject = generateJson(alias, alert, content, url, sound, channelId, androidIntent);
+        return sendPostRequest(jsonObject.toString(), authorization);
+    }
+
+    /**
+     * 发送Post请求(json格式)
+     *
+     * @param data          //封装的json串
+     * @param authorization 验签
+     * @return result 返回一个json字符串
+     */
+    private String sendPostRequest(String data, String authorization) {
+        String result = "";
+        HashMap<String, String> reqHeader = new HashMap<>();
+        reqHeader.put("Authorization", authorization.trim());
+        try {
+            result = HttpUtil.postForHttps(this.reqURL, data, reqHeader);
+        } catch (Exception e) {
+            throw new ThirdpartyException("HttpUtil Connection Exception", e);
+        }
+        return result;
+    }
+
+    /**
+     *     * BASE64加密工具
+     */
+    private String encryptBASE64(String str) {
+        byte[] key = str.getBytes();
+        String strs = Base64.encodeBase64String(key);
+        return strs;
+    }
+
+    @Override
+    public void afterPropertiesSet() throws Exception {
+        // 参数检查
 		/*if (StringUtils.isBlank(appKey)) {
 			throw new RuntimeException("Init parameter [appKey] can not blank");
 		}
@@ -191,73 +199,29 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean
 		if (StringUtils.isBlank(reqURL)) {
 			throw new RuntimeException("Init parameter [reqURL] can not blank");
 		}*/
-	}
-
-	@Override
-	public boolean send(String subject, String content, String receiver, String url, String type,String sound,String channelId) throws IOException {
-		String[] alias = { receiver };
-		String result = this.push(alias, subject, content, url,type,sound,channelId);
-		JSONObject json = JSONObject.parseObject(result);
-		if (json.containsKey("error")) {
-			JSONObject jsonObject = json.getJSONObject("error");
-			throw new ThirdpartyException(jsonObject.get("message").toString());
-		}
-		return true;
-	}
-
-	@Override
-	public boolean batchSend(String subject, String content, String[] receivers, String url, String type,String sound,String channelId) throws IOException {
-		String result = this.push(receivers, subject, content, url,type,sound,channelId);
-		JSONObject json = JSONObject.parseObject(result);
-		if (json.containsKey("error")) {
-			JSONObject jsonObject = json.getJSONObject("error");
-			throw new ThirdpartyException(jsonObject.get("message").toString()+"["+Arrays.stream(receivers).collect(Collectors.joining(","))+"]");
-		}
-		return true;
-	}
-
-	public void setStudentAppKey(String studentAppKey) {
-		this.studentAppKey = studentAppKey;
-	}
-
-	public void setStudentMasterSecret(String studentMasterSecret) {
-		this.studentMasterSecret = studentMasterSecret;
-	}
-
-	public void setTeacherAppKey(String teacherAppKey) {
-		this.teacherAppKey = teacherAppKey;
-	}
-
-	public void setTeacherMasterSecret(String teacherMasterSecret) {
-		this.teacherMasterSecret = teacherMasterSecret;
-	}
-
-	public String getSystemAppKey() {
-		return systemAppKey;
-	}
-
-	public void setSystemAppKey(String systemAppKey) {
-		this.systemAppKey = systemAppKey;
-	}
-
-	public String getSystemMasterSecret() {
-		return systemMasterSecret;
-	}
-
-	public void setSystemMasterSecret(String systemMasterSecret) {
-		this.systemMasterSecret = systemMasterSecret;
-	}
-
-	public void setApns_production(boolean apns_production) {
-		this.apns_production = apns_production;
-	}
-
-	public void setTime_to_live(int time_to_live) {
-		this.time_to_live = time_to_live;
-	}
-
-	public void setReqURL(String reqURL) {
-		this.reqURL = reqURL;
-	}
+    }
+
+    @Override
+    public boolean send(String subject, String content, String receiver, String url, String type, String sound, String channelId) throws IOException {
+        String[] alias = {receiver};
+        String result = this.push(alias, subject, content, url, type, sound, channelId);
+        JSONObject json = JSONObject.parseObject(result);
+        if (json.containsKey("error")) {
+            JSONObject jsonObject = json.getJSONObject("error");
+            throw new ThirdpartyException(jsonObject.get("message").toString());
+        }
+        return true;
+    }
+
+    @Override
+    public boolean batchSend(String subject, String content, String[] receivers, String url, String type, String sound, String channelId) throws IOException {
+        String result = this.push(receivers, subject, content, url, type, sound, channelId);
+        JSONObject json = JSONObject.parseObject(result);
+        if (json.containsKey("error")) {
+            JSONObject jsonObject = json.getJSONObject("error");
+            throw new ThirdpartyException(jsonObject.get("message").toString() + "[" + Arrays.stream(receivers).collect(Collectors.joining(",")) + "]");
+        }
+        return true;
+    }
 
 }

+ 4 - 4
mec-web/src/main/java/com/ym/mec/web/controller/ImLiveBroadcastRoomController.java

@@ -174,7 +174,7 @@ public class ImLiveBroadcastRoomController extends BaseController {
     @ApiOperation("主讲人进入房间")
     @GetMapping("/speakerJoinRoom")
     public HttpResponseResult<ImLiveBroadcastRoomVo> speakerJoinRoom(String roomUid) {
-        return succeed(imLiveBroadcastRoomService.speakerJoinRoom(roomUid));
+        return succeed(imLiveBroadcastRoomService.speakerJoinRoom(roomUid, "pc"));
     }
 
     @ApiOperation("学生-进入房间")
@@ -190,7 +190,7 @@ public class ImLiveBroadcastRoomController extends BaseController {
                                                    @ApiParam(value = "用户id", required = true) Integer userId,
                                                    @ApiParam(value = "type 1:开始直播-开始录像     2:关闭直播关闭录像", required = true) Integer type) {
         if (type == 1) {
-            imLiveBroadcastRoomService.startLive(roomUid, userId);
+            imLiveBroadcastRoomService.startLive(roomUid, userId, null);
         } else if (type == 2) {
             imLiveBroadcastRoomService.closeLive(roomUid, userId);
         } else {
@@ -200,8 +200,8 @@ public class ImLiveBroadcastRoomController extends BaseController {
     }
 
     @GetMapping("/test")
-    public Object test(String roomUid) {
-        return imLiveBroadcastRoomService.test(roomUid);
+    public Object test(String roomUid, String userFlag) {
+        return imLiveBroadcastRoomService.test(roomUid, userFlag);
     }
 
     @GetMapping("/destroyExpiredLiveRoom")