From 58a1078809f129905ae30e676c8705e2a083e2ec Mon Sep 17 00:00:00 2001
From: EricsHu <hrr145632>
Date: 星期三, 24 五月 2023 16:45:38 +0800
Subject: [PATCH] 111
---
src/main/java/com/qxueyou/scc/controller/VideoLiveController.java | 191 +++++++++++++++++++++++++++++++++--------------
1 files changed, 132 insertions(+), 59 deletions(-)
diff --git a/src/main/java/com/qxueyou/scc/controller/VideoLiveController.java b/src/main/java/com/qxueyou/scc/controller/VideoLiveController.java
index e1046b7..34870b1 100644
--- a/src/main/java/com/qxueyou/scc/controller/VideoLiveController.java
+++ b/src/main/java/com/qxueyou/scc/controller/VideoLiveController.java
@@ -1,10 +1,15 @@
package com.qxueyou.scc.controller;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.hankcs.hanlp.corpus.tag.Nature;
+import com.qxueyou.scc.base.dao.CommonDAO;
+import com.qxueyou.scc.sdk.MTCloud;
+import io.swagger.models.auth.In;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -24,14 +29,18 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
+import springfox.documentation.spring.web.json.Json;
-@Api(tags="直播管理接口")
+import static com.hankcs.hanlp.corpus.tag.Nature.r;
+import static com.hankcs.hanlp.corpus.tag.Nature.s;
+
+@Api(tags="鐩存挱绠$悊鎺ュ彛")
@RestController
@CrossOrigin(origins="*",maxAge=3600)
@RequestMapping(value = "/admin/videoLive")
public class VideoLiveController {
- // 分页查询中,默认记录条数和页数
+ // 鍒嗛〉鏌ヨ涓紝榛樿璁板綍鏉℃暟鍜岄〉鏁�
private static final int DEFAULT_PAGE_SIZE = 10;
private static final int DEFAULT_PAGE_NUM = 1;
@@ -46,25 +55,28 @@
@Autowired
MediaLiveDAO dao;
+
+ @Autowired
+ CommonDAO commonDAO;
/**
- * 获取直播列表
+ * 鑾峰彇鐩存挱鍒楄〃
*
* @param keyword
- * 搜索关键字
+ * 鎼滅储鍏抽敭瀛�
* @param pageNum
- * 页码
+ * 椤电爜
* @param pageSize
- * 页数
+ * 椤垫暟
* @return
*/
- @ApiOperation(value = "获取创建人的直播列表")
+ @ApiOperation(value = "鑾峰彇鍒涘缓浜虹殑鐩存挱鍒楄〃")
@GetMapping(value = "list")
public Result list(String keyword, Integer pageNum, Integer pageSize) {
List<MediaVideoLive> data = liveService.listOfMine(keyword, pageNum, pageSize);
int count = liveService.listCountOfMine(keyword);
-
+
return new Result(true, "success", CollectionUtils.newObjectMap("videoLiveCount", count,
"videoLiveLst",QBeanUtils.listBean2ListMap(data, CollectionUtils.newStringMap(
"creator","creator",
@@ -78,50 +90,110 @@
"status","status",
"pushUrl","rtmpPushUrl",
"hlsPullUrl","hlsPullUrl",
- "previewImgUrl","previewImgUrl"
+ "previewImgUrl","previewImgUrl",
+ "courseId","courseId"
))));
}
/**
- * 新增直播/更新直播
+ * 鏂板鐩存挱/鏇存柊鐩存挱
*
* @param videoLiveId
- * 直播id(更新的时候才需要传)
+ * 鐩存挱id锛堟洿鏂扮殑鏃跺�欐墠闇�瑕佷紶锛�
* @param name
- * 直播名称
+ * 鐩存挱鍚嶇О
* @param content
- * 直播介绍
+ * 鐩存挱浠嬬粛
* @param imgPath
- * 图片地址
+ * 鍥剧墖鍦板潃
* @param startTime
- * 开始时间
+ * 寮�濮嬫椂闂�
* @param endTime
- * 结束时间
+ * 缁撴潫鏃堕棿
* @param isPlayBack
- * 是否回放
+ * 鏄惁鍥炴斁
* @param classIds
- * 班级id
+ * 鐝骇id
* @return
*/
- @ApiOperation(value = "创建编辑直播")
+ @ApiOperation(value = "鍒涘缓缂栬緫鐩存挱")
@PostMapping(value = "addOrUpdate")
public Result addOrUpdate(String videoLiveId, String name, String content,String teacherId,String teacherName,String subjectId,
- String subjectName,String definition,String imgPath, long startTime,long endTime, boolean isPlayBack, String classIds) {
- if(StringUtils.isEmpty(videoLiveId)) {
- return liveService.add(name, content,teacherId,teacherName,subjectId,subjectName,definition,imgPath, new Date(startTime), new Date(endTime), isPlayBack, StringUtils.isEmpty(classIds)?null:CollectionUtils.newList(String.class,classIds.split(",")));
- }else {
- return liveService.update(videoLiveId,name, content,teacherId,teacherName,subjectId,subjectName,definition,imgPath, new Date(startTime), new Date(endTime), isPlayBack, StringUtils.isEmpty(classIds)?null:CollectionUtils.newList(String.class,classIds.split(",")));
+ String subjectName,String definition,String imgPath, long startTime,long endTime, boolean isPlayBack, String classIds) throws Exception {
+ MTCloud client = new MTCloud();
+ HashMap<Object,Object> options = new HashMap<Object,Object>();
+ options.put("barrage", 1);
+ options.put("isPublic", 1);
+ options.put("robotNumber", 1);
+ options.put("robotType", 1);
+ options.put("pptDisplay", 1);
+ options.put("modetype", 6);
+ //灏唋ong绫诲瀷杞崲涓篠tring绫诲瀷
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ String startTime1 = simpleDateFormat.format(new Date(startTime));
+ String endTime1 = simpleDateFormat.format(new Date(endTime));
+ System.out.println(startTime1+"------"+endTime1);
+ //璋冪敤绗笁鏂圭洿鎾帴鍙�
+ String s = client.courseAdd(name, ClientUtils.getUserId(), startTime1, endTime1, ClientUtils.getUserName(), "222", options);
+ //json杞崲鎷垮埌courseId
+ JSONObject jsonObject = JSON.parseObject(s);
+ JSONObject data = jsonObject.getJSONObject("data");
+// System.out.println(Integer.parseInt(course_id));
+ if(jsonObject.getString("code").equals("0")) {
+ String course_id = (String) data.get("course_id");
+ liveService.add(name, content,teacherId,teacherName,subjectId,subjectName,definition,imgPath, new Date(startTime), new Date(endTime),Integer.parseInt(course_id), isPlayBack, StringUtils.isEmpty(classIds)?null:CollectionUtils.newList(String.class,classIds.split(",")));
+ return new Result(true, "鎴愬姛", s);
}
+ return new Result(false,jsonObject.getString("msg"));
}
+ @ApiOperation(value = "寮�鍚洿鎾�")
+ @GetMapping(value = "OpenLive")
+ public Result OpenLive(int courseId) throws Exception {
+ MTCloud client = new MTCloud();
+
+ HashMap<Object,Object> options = new HashMap<Object, Object>();
+ options.put("ssl", false);
+
+ String res = client.courseLogin(ClientUtils.getUserId(),MTCloud.ACCOUNT_TYPE_THIRD, options);
+ System.out.println(res);
+ JSONObject jsonObject = JSON.parseObject(res);
+ if(jsonObject.getString("code").equals("0")){
+ JSONObject data = jsonObject.getJSONObject("data");
+ String protocol = (String) data.get("url");
+ return new Result(true,"寮�鍚垚鍔�",protocol);
+ }
+ return new Result(false,jsonObject.getString("msg"));
+ }
+
+ @ApiOperation(value = "淇敼鐩存挱鐘舵��")
+ @GetMapping(value = "updateLive")
+ public Result updateLive(Integer courseId) {
+
+ MediaVideoLive revamp = liveService.revamp(courseId);
+ revamp.setStatus(MediaVideoLive.STATUS_LIVE_STOP);
+ commonDAO.update(revamp);
+
+ return new Result(true,"鍏抽棴鎴愬姛");
+ }
+
+ @ApiOperation(value = "鍦ㄧ嚎鏃堕暱")
+ @GetMapping(value = "onlineCommunication")
+ public Result onlineCommunication(String courseId,Integer page, Integer size) throws Exception {
+ MTCloud client = new MTCloud();
+ HashMap<Object,Object> options = new HashMap<Object, Object>();
+ options.put("ssl", false);
+ String res = client.courseVisitorList(courseId,page,size,options);
+ return new Result(true,"寮�鍚垚鍔�",res);
+ }
/**
- * 查询直播详情
+ * 鏌ヨ鐩存挱璇︽儏
*
* @param videoLiveId
- * 直播id
+ * 鐩存挱id
* @return
*/
- @ApiOperation(value = "获取直播详情")
+ @ApiOperation(value = "鑾峰彇鐩存挱璇︽儏")
@GetMapping(value = "queryDetail")
public Result detail(String videoLiveId) {
List<String> lstClassIds = null;
@@ -165,13 +237,13 @@
}
/**
- * 发布/多个以逗号隔开
+ * 鍙戝竷/澶氫釜浠ラ�楀彿闅斿紑
*
* @param videoLiveIds
- * 直播ids
+ * 鐩存挱ids
* @return
*/
- @ApiOperation(value = "发布直播")
+ @ApiOperation(value = "鍙戝竷鐩存挱")
@PostMapping(value = "release")
public Result release(String videoLiveIds) {
for(String liveId:videoLiveIds.split(",")) {
@@ -181,13 +253,13 @@
}
/**
- * 取消发布/多个以逗号隔开
+ * 鍙栨秷鍙戝竷/澶氫釜浠ラ�楀彿闅斿紑
*
* @param videoLiveIds
- * 直播ids
+ * 鐩存挱ids
* @return
*/
- @ApiOperation(value = "取消发布直播")
+ @ApiOperation(value = "鍙栨秷鍙戝竷鐩存挱")
@PostMapping(value = "cancel")
public Result cance(String videoLiveIds) {
@@ -198,25 +270,25 @@
}
/**
- * 删除/多个以逗号隔开
+ * 鍒犻櫎/澶氫釜浠ラ�楀彿闅斿紑
*
- * @param videoLiveId
+ * @param videoLiveIds
* @return
*/
- @ApiOperation(value = "删除创建的直播")
+ @ApiOperation(value = "鍒犻櫎鍒涘缓鐨勭洿鎾�")
@PostMapping(value = "delete")
- public Result delete(String videoLiveIds) {
- return liveService.delete(videoLiveIds.split(","));
+ public Result delete(String videoLiveIds,String courseIds) throws Exception {
+ return liveService.delete(videoLiveIds.split(","),courseIds.split(","));
}
/**
- * 直播开始
+ * 鐩存挱寮�濮�
*
* @param videoLiveIds
- * 直播id
+ * 鐩存挱id
*/
- @ApiOperation(value = "直播开始")
+ @ApiOperation(value = "鐩存挱寮�濮�")
@PostMapping(value = "start")
public Result start(String videoLiveIds) {
@@ -228,12 +300,12 @@
/**
- * 直播暂停
+ * 鐩存挱鏆傚仠
*
* @param videoLiveIds
- * 直播id
+ * 鐩存挱id
*/
- @ApiOperation(value = "直播暂停")
+ @ApiOperation(value = "鐩存挱鏆傚仠")
@PostMapping(value = "pause")
public Result pause(String videoLiveIds) {
@@ -244,12 +316,12 @@
}
/**
- * 直播结束
+ * 鐩存挱缁撴潫
*
- * @param videoLiveId
- * 直播id
+ * @param videoLiveIds
+ * 鐩存挱id
*/
- @ApiOperation(value = "直播结束")
+ @ApiOperation(value = "鐩存挱缁撴潫")
@PostMapping(value = "stop")
public Result stop(String videoLiveIds) {
@@ -262,18 +334,18 @@
/**
- * 直播点赞
+ * 鐩存挱鐐硅禐
*
* @param videoLiveId
- * 直播id
+ * 鐩存挱id
*/
- @ApiOperation(value = "直播点赞")
+ @ApiOperation(value = "鐩存挱鐐硅禐")
@PostMapping(value = "praise")
public Result praise(String videoLiveId) {
return liveService.doPraise(videoLiveId);
}
- @ApiOperation(value = "学生端根据班级,课程过滤直播列表")
+ @ApiOperation(value = "瀛︾敓绔牴鎹彮绾э紝璇剧▼杩囨护鐩存挱鍒楄〃")
@GetMapping(value = "student/list")
public Result list(String keyword,String classIds,String subjectId,Short status,Integer pageNum, Integer pageSize) {
pageSize = pageSize != null && pageSize > 0 ? pageSize : DEFAULT_PAGE_SIZE;
@@ -300,11 +372,12 @@
"status","status",
"pushUrl","rtmpPushUrl",
"hlsPullUrl","hlsPullUrl",
- "previewImgUrl","previewImgUrl"
+ "previewImgUrl","previewImgUrl",
+ "courseId","courseId"
))));
}
- @ApiOperation(value = "直播回放列表")
+ @ApiOperation(value = "鐩存挱鍥炴斁鍒楄〃")
@GetMapping(value = "replay/list")
public Result listReplay(String videoLiveId) {
@@ -326,7 +399,7 @@
))));
}
- @ApiOperation(value = "测试直播回放")
+ @ApiOperation(value = "娴嬭瘯鐩存挱鍥炴斁")
@GetMapping(value = "replay/test")
public Result testReplay(String liveId) {
mediaVideoLivePlayBackService.testPlayBack(liveId);
--
Gitblit v1.8.0