Browse Source

fix 直播聊天内容

he2802 3 years ago
parent
commit
d687ce8cc2

+ 20 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/polyv/PolyvLiveController.java

@@ -4,6 +4,10 @@ import com.zhongzheng.common.core.controller.BaseController;
 import com.zhongzheng.common.core.domain.AjaxResult;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.framework.web.service.WxTokenService;
+import com.zhongzheng.modules.course.bo.CourseMenuQueryBo;
+import com.zhongzheng.modules.course.bo.CourseSectionQueryBo;
+import com.zhongzheng.modules.course.service.ICourseSectionService;
+import com.zhongzheng.modules.course.vo.CourseUserChapterSectionVo;
 import com.zhongzheng.modules.polyv.bo.PolyvLiveQueryBo;
 import com.zhongzheng.modules.polyv.service.IPolyvLiveService;
 import com.zhongzheng.modules.polyv.service.IPolyvVideoService;
@@ -11,13 +15,17 @@ import com.zhongzheng.modules.user.entity.ClientLoginUser;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
+import net.polyv.live.v1.entity.chat.LiveGetMessageListResponse;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -34,6 +42,8 @@ public class PolyvLiveController extends BaseController {
 
     private final IPolyvLiveService iPolyvLiveService;
 
+    private final ICourseSectionService iCourseSectionService;
+
     @Autowired
     private WxTokenService wxTokenService;
 
@@ -47,4 +57,14 @@ public class PolyvLiveController extends BaseController {
         return AjaxResult.success(map);
     }
 
+    /**
+     * 查询保利威节聊天历史
+     */
+    @ApiOperation("查询保利威节聊天历史")
+    @GetMapping("/historyChatMsgList")
+    public AjaxResult<List<LiveGetMessageListResponse.MessageList>> historyChatMsg(CourseSectionQueryBo bo) throws IOException, NoSuchAlgorithmException {
+        List<LiveGetMessageListResponse.MessageList> list = iCourseSectionService.GetHistoryChatMsg(bo);
+        return AjaxResult.success(list);
+    }
+
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseSectionQueryBo.java

@@ -97,4 +97,6 @@ public class CourseSectionQueryBo extends BaseEntity {
 	/** 保利威真实直播时长,单位秒 */
 	@ApiModelProperty("保利威真实直播时长,单位秒")
 	private Long realDuration;
+	@ApiModelProperty("节ID")
+	private Long sectionId;
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/ICourseSectionService.java

@@ -9,8 +9,11 @@ import com.zhongzheng.modules.course.bo.CourseSectionQueryBo;
 import com.zhongzheng.modules.course.domain.CourseSection;
 import com.zhongzheng.modules.course.vo.CourseSectionImport;
 import com.zhongzheng.modules.course.vo.CourseSectionVo;
+import net.polyv.live.v1.entity.chat.LiveGetMessageListResponse;
 import org.apache.ibatis.annotations.Param;
 
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
 import java.text.ParseException;
 import java.util.Collection;
 import java.util.List;
@@ -63,4 +66,6 @@ public interface ICourseSectionService extends IService<CourseSection> {
 	Map<String,Object> importSection(List<CourseSectionImport> sectionList, Boolean isUpdateSupport, String operName) throws ParseException;
 
 	List<CourseSectionVo> overSectionList(Long startTime,Long endTime);
+
+	List<LiveGetMessageListResponse.MessageList> GetHistoryChatMsg(CourseSectionQueryBo bo) throws IOException, NoSuchAlgorithmException;
 }

+ 29 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseSectionServiceImpl.java

@@ -20,9 +20,12 @@ import com.zhongzheng.modules.course.mapper.CourseSectionMapper;
 import com.zhongzheng.modules.course.service.*;
 import com.zhongzheng.modules.course.vo.CourseSectionImport;
 import com.zhongzheng.modules.course.vo.CourseSectionVo;
+import com.zhongzheng.modules.polyv.bo.PolyvLiveQueryBo;
+import com.zhongzheng.modules.polyv.service.IPolyvLiveService;
 import com.zhongzheng.modules.polyv.service.IPolyvVideoService;
 import com.zhongzheng.modules.polyv.vo.PolyvVideoQuerVo;
 import com.zhongzheng.modules.system.domain.SysRoleMenu;
+import net.polyv.live.v1.entity.chat.LiveGetMessageListResponse;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -31,6 +34,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.pagehelper.Page;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -75,6 +80,9 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
     @Autowired
     private IPolyvVideoService iPolyvVideoService;
 
+    @Autowired
+    private IPolyvLiveService iPolyvLiveService;
+
     @Override
     public CourseSectionVo queryById(Long sectionId){
         CourseSection db = this.baseMapper.selectById(sectionId);
@@ -343,6 +351,27 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
         return this.baseMapper.overSectionList(startTime,endTime);
     }
 
+    /**
+     * 获取节保利威聊天历史
+     * @param bo
+     * @return
+     */
+    @Override
+    public List<LiveGetMessageListResponse.MessageList> GetHistoryChatMsg(CourseSectionQueryBo bo) throws IOException, NoSuchAlgorithmException {
+        CourseSectionVo section = queryById(bo.getSectionId());
+        if(Validator.isNotEmpty(section)){
+            if(section.getSectionType()!=2){
+                throw new CustomException("只支持查询回放聊天内容");
+            }
+            PolyvLiveQueryBo queryBo = BeanUtil.toBean(bo, PolyvLiveQueryBo.class);
+            queryBo.setSectionId(bo.getSectionId());
+            queryBo.setStartTime(section.getRealLiveStartTime());
+            queryBo.setEndTime(section.getRealLiveEndTime());
+            return iPolyvLiveService.GetHistoryChatMsg(queryBo);
+        }
+        return null;
+    }
+
     @Transactional(rollbackFor = Exception.class)
     public String insertByAddBoImport(CourseSectionAddBo bo, String errorLog, Integer no) {
         CourseSection add = BeanUtil.toBean(bo, CourseSection.class);

+ 2 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/polyv/bo/PolyvLiveQueryBo.java

@@ -33,7 +33,8 @@ public class PolyvLiveQueryBo extends BaseEntity {
 	@ApiModelProperty("用户账号")
 	private String userAccount;
 	@ApiModelProperty("当前页")
-	private Integer currentPage;
+	private Integer pageNum;
 	@ApiModelProperty("页面大小")
 	private Integer pageSize;
+
 }

+ 2 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/polyv/service/IPolyvLiveService.java

@@ -15,6 +15,7 @@ import net.polyv.live.v1.entity.channel.operate.LiveChannelBasicInfoResponse;
 import net.polyv.live.v1.entity.channel.playback.LiveChannelVideoListResponse;
 import net.polyv.live.v1.entity.channel.playback.LiveListChannelSessionInfoResponse;
 import net.polyv.live.v1.entity.channel.viewdata.LiveListChannelViewlogResponse;
+import net.polyv.live.v1.entity.chat.LiveGetMessageListResponse;
 
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
@@ -44,5 +45,5 @@ public interface IPolyvLiveService {
 
 	void GetConsultingRecord(PolyvLiveQueryBo bo) throws IOException, NoSuchAlgorithmException;
 
-	void GetBannedList(PolyvLiveQueryBo bo) throws IOException, NoSuchAlgorithmException;
+	List<LiveGetMessageListResponse.MessageList> GetHistoryChatMsg(PolyvLiveQueryBo bo) throws IOException, NoSuchAlgorithmException;
 }

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/polyv/service/IPolyvVideoService.java

@@ -1,6 +1,7 @@
 package com.zhongzheng.modules.polyv.service;
 
 import com.zhongzheng.common.core.page.TableDataInfo;
+import com.zhongzheng.modules.polyv.bo.PolyvLiveQueryBo;
 import com.zhongzheng.modules.polyv.domain.PolyvVideo;
 import com.zhongzheng.modules.polyv.vo.PolyvCataData;
 import com.zhongzheng.modules.polyv.vo.PolyvVideoQuerVo;

+ 15 - 11
zhongzheng-system/src/main/java/com/zhongzheng/modules/polyv/service/impl/PolyvLiveServiceImpl.java

@@ -49,9 +49,7 @@ import net.polyv.live.v1.entity.channel.playback.LiveListChannelSessionInfoReque
 import net.polyv.live.v1.entity.channel.playback.LiveListChannelSessionInfoResponse;
 import net.polyv.live.v1.entity.channel.viewdata.LiveListChannelViewlogRequest;
 import net.polyv.live.v1.entity.channel.viewdata.LiveListChannelViewlogResponse;
-import net.polyv.live.v1.entity.chat.LiveGetBannedListRequest;
-import net.polyv.live.v1.entity.chat.LiveGetConsultingRecordRequest;
-import net.polyv.live.v1.entity.chat.LiveGetConsultingRecordResponse;
+import net.polyv.live.v1.entity.chat.*;
 import net.polyv.live.v1.service.channel.impl.LiveChannelOperateServiceImpl;
 import net.polyv.live.v1.service.channel.impl.LiveChannelPlaybackServiceImpl;
 import net.polyv.live.v1.service.channel.impl.LiveChannelViewdataServiceImpl;
@@ -293,16 +291,21 @@ public class PolyvLiveServiceImpl implements IPolyvLiveService {
     }
 
     @Override
-    public void GetBannedList(PolyvLiveQueryBo bo) throws IOException, NoSuchAlgorithmException {
-        LiveGetBannedListRequest liveGetBannedListRequest = new LiveGetBannedListRequest();
-        List<String> liveGetBannedListResponseList = null;
+    public List<LiveGetMessageListResponse.MessageList> GetHistoryChatMsg(PolyvLiveQueryBo bo) throws IOException, NoSuchAlgorithmException {
+        LiveGetMessageListRequest liveGetMessageListRequest = new LiveGetMessageListRequest();
+        LiveGetMessageListResponse liveGetMessageListResponses;
         try {
-            liveGetBannedListRequest.setChannelId(bo.getChannelId())
-                    .setType(LiveConstant.BannedType.IP.getType());
-            liveGetBannedListResponseList = new LiveChatRoomServiceImpl().getBannedList(liveGetBannedListRequest);
-            if (liveGetBannedListResponseList != null) {
+            liveGetMessageListRequest.setChannelId(bo.getChannelId())
+                    .setStartDay(new Date((bo.getStartTime()*1000)))
+                    .setEndDay(new Date((bo.getEndTime()*1000)))
+                    .setStatus("pass")
+                    .setPageSize(bo.getPageSize())
+                    .setCurrentPage(bo.getPageNum());
+            liveGetMessageListResponses = new LiveChatRoomServiceImpl().getPageHistoryChatMsg(
+                    liveGetMessageListRequest);
+            if (liveGetMessageListResponses != null) {
+                return liveGetMessageListResponses.getContents();
                 //to do something ......
-
             }
         } catch (PloyvSdkException e) {
             //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
@@ -311,5 +314,6 @@ public class PolyvLiveServiceImpl implements IPolyvLiveService {
         } catch (Exception e) {
             throw e;
         }
+        return null;
     }
 }