派生自 projectDept/qhighschool

yn147
2023-11-25 63c8bc319fd02d9f39b729f136fb3af01c773de1
src/main/java/com/qxueyou/scc/controller/VideoLiveController.java
@@ -9,6 +9,7 @@
import com.alibaba.fastjson.JSONObject;
import com.hankcs.hanlp.corpus.tag.Nature;
import com.qxueyou.scc.base.dao.CommonDAO;
import com.qxueyou.scc.base.util.UUIDUtils;
import com.qxueyou.scc.config.IpUtils;
import com.qxueyou.scc.sdk.MTCloud;
import com.qxueyou.scc.teach.live.model.AccessLog;
@@ -70,6 +71,41 @@
   @Autowired
   private RedisCache redisCache;
   /**
    * 获取直播回放地址
    *
    * @param videoLiveId
    *            直播id(更新的时候才需要传)
    */
   @ApiOperation(value = "获取直播回放地址")
   @GetMapping(value = "livePlaybackURL")
   public Result livePlaybackURL(String videoLiveId,String nickname) throws Exception {
      if (StringUtils.isEmpty(videoLiveId)) {
         return new Result(false,"videoLiveId不能为空");
      }
      if (StringUtils.isEmpty(nickname)) {
         return new Result(false,"nickname不能为空");
      }
      MTCloud client = new MTCloud();
      HashMap<Object,Object> options = new HashMap<Object,Object>();
      options.put("ssl", true);
      //获取直播对象
      MediaVideoLive mediaVideoLive = liveService.read(videoLiveId);
      //调用第三方直播接口 4028815c8c0063f0018c006e083d0001
      String uuid = UUIDUtils.generateUUID();
      String courseAccess = client.courseAccessPlayback(String.valueOf(mediaVideoLive.getCourseId()),uuid,nickname,"user",3600,options);
      //json转换拿到courseId
      JSONObject jsonObject = JSON.parseObject(courseAccess);
      JSONObject data = jsonObject.getJSONObject("data");
      if(jsonObject.getString("code").equals("0")) {
         String playbackUrl = (String) data.get("playbackUrl");//带聊天区地址
//         String playbackOutUrl = (String) data.get("playbackOutUrl");//纯视频地址
         return new Result(true, "成功", playbackUrl);
      }
      return new Result(false,jsonObject.getString("msg"));
   }
   /**
    * 获取直播列表
    * 
@@ -83,9 +119,9 @@
    */
   @ApiOperation(value = "获取创建人的直播列表")
   @GetMapping(value = "list")
   public Result list(String keyword, Integer pageNum, Integer pageSize) {
   public Result list(String keyword,String portalStatus, Integer pageNum, Integer pageSize) {
      
      List<MediaVideoLive> data = liveService.listOfMine(keyword, pageNum, pageSize);
      List<MediaVideoLive> data = liveService.listOfMine(keyword,portalStatus, pageNum, pageSize);
      int count = liveService.listCountOfMine(keyword);
      return new Result(true, "success", CollectionUtils.newObjectMap("videoLiveCount", count, 
@@ -102,7 +138,8 @@
                  "pushUrl","rtmpPushUrl",
                  "hlsPullUrl","hlsPullUrl",
                  "previewImgUrl","previewImgUrl",
                  "courseId","courseId"
                  "courseId","courseId",
                  "portalStatus","portalStatus"
                  ))));
   }
@@ -138,7 +175,7 @@
   @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) throws Exception {
         String subjectName,String definition,String imgPath, long startTime,long endTime, boolean isPlayBack, String classIds,String portalStatus) throws Exception {
      MTCloud client = new MTCloud();
      HashMap<Object,Object> options = new HashMap<Object,Object>();
      options.put("barrage", 1);
@@ -159,7 +196,7 @@
      JSONObject data = jsonObject.getJSONObject("data");
      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(",")));
         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(",")),portalStatus);
         return new Result(true, "成功", s);
      }
      return new Result(false,jsonObject.getString("msg"));