| | |
| | | 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.*; |
| | |
| | | |
| | | @Autowired |
| | | MediaLiveDAO dao; |
| | | |
| | | @Autowired |
| | | CommonDAO commonDAO; |
| | | |
| | | /** |
| | | * 获取直播列表 |
| | |
| | | "status","status", |
| | | "pushUrl","rtmpPushUrl", |
| | | "hlsPullUrl","hlsPullUrl", |
| | | "previewImgUrl","previewImgUrl" |
| | | |
| | | "previewImgUrl","previewImgUrl", |
| | | "courseId","courseId" |
| | | )))); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取已结束直播列表") |
| | | @GetMapping(value = "listvideo") |
| | | public Result listvideo() { |
| | | |
| | | List<MediaVideoLive> data = liveService.listvideo("9"); |
| | | |
| | | return new Result(true, "success", CollectionUtils.newObjectMap("listVideo",data)); |
| | | } |
| | | /** |
| | | * 新增直播/更新直播 |
| | | * |
| | |
| | | options.put("robotNumber", 1); |
| | | options.put("robotType", 1); |
| | | options.put("pptDisplay", 1); |
| | | options.put("modetype", 6); |
| | | //将long类型转换为String类型 |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+00:00")); |
| | | String startTime1 = simpleDateFormat.format(new Date(startTime)); |
| | | String endTime1 = simpleDateFormat.format(new Date(endTime)); |
| | | System.out.println(startTime1+"------"+endTime1); |
| | | //调用第三方直播接口 |
| | | String s = client.courseAdd(name, "16624662432", startTime1, endTime1, ClientUtils.getUserName(), "222", options); |
| | | 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"); |
| | | String course_id = (String) data.get("course_id"); |
| | | // System.out.println(Integer.parseInt(course_id)); |
| | | if(Nature.s !=null) { |
| | | 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); |
| | | return new Result(false,jsonObject.getString("msg")); |
| | | } |
| | | |
| | | @ApiOperation(value = "开启直播") |
| | |
| | | HashMap<Object,Object> options = new HashMap<Object, Object>(); |
| | | options.put("ssl", false); |
| | | |
| | | String res = client.courseLogin("16624662432", MTCloud.ACCOUNT_TYPE_THIRD, options); |
| | | String res = client.courseLogin(ClientUtils.getUserId(),MTCloud.ACCOUNT_TYPE_THIRD, options); |
| | | System.out.println(res); |
| | | JSONObject jsonObject = JSON.parseObject(res); |
| | | JSONObject data = jsonObject.getJSONObject("data"); |
| | | String protocol = (String) data.get("url"); |
| | | return new Result(true,"开启成功",protocol); |
| | | 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); |
| | | } |
| | | |
| | | // @ApiOperation(value = "查看详情") |
| | | // @GetMapping(value = "detailLive") |
| | | // public Result detailLive(String liveId) { |
| | | // commonDAO.find |
| | | // return new Result(true,"开启成功",res); |
| | | // } |
| | | /** |
| | | * 查询直播详情 |
| | | * |
| | |
| | | */ |
| | | @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(",")); |
| | | } |
| | | |
| | | |