package com.qxueyou.scc.controller;
|
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Map;
|
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import com.qxueyou.scc.admin.classes.model.ClsClass;
|
import com.qxueyou.scc.admin.classes.service.IClassService;
|
import com.qxueyou.scc.admin.teacher.service.ITeacherService;
|
import com.qxueyou.scc.base.model.Result;
|
import com.qxueyou.scc.base.util.ClientUtils;
|
import com.qxueyou.scc.base.util.CollectionUtils;
|
import com.qxueyou.scc.base.util.QBeanUtils;
|
import com.qxueyou.scc.teach.live.dao.MediaLiveDAO;
|
import com.qxueyou.scc.teach.live.model.MediaVideoLive;
|
import com.qxueyou.scc.teach.live.model.MediaVideoLiveReplay;
|
import com.qxueyou.scc.teach.live.service.IMediaLiveService;
|
import com.qxueyou.scc.teach.live.service.IMediaVideoLivePlayBackService;
|
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
|
@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;
|
|
@Autowired
|
IMediaLiveService liveService;
|
|
@Autowired
|
IMediaVideoLivePlayBackService mediaVideoLivePlayBackService;
|
|
@Autowired
|
IClassService classService;
|
|
@Autowired
|
MediaLiveDAO dao;
|
|
/**
|
* »ñȡֱ²¥Áбí
|
*
|
* @param keyword
|
* ËÑË÷¹Ø¼ü×Ö
|
* @param pageNum
|
* Ò³Âë
|
* @param pageSize
|
* Ò³Êý
|
* @return
|
*/
|
@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",
|
"startTime","startTime",
|
"endTime","endTime",
|
"updateTime","lastUpdateTime",
|
"videoLiveId","videoLiveId",
|
"name","name",
|
"subjectId","subjectId",
|
"subjectName","subjectName",
|
"status","status",
|
"pushUrl","rtmpPushUrl",
|
"hlsPullUrl","hlsPullUrl",
|
"previewImgUrl","previewImgUrl"
|
))));
|
}
|
|
/**
|
* ÐÂÔöÖ±²¥/¸üÐÂÖ±²¥
|
*
|
* @param videoLiveId
|
* Ö±²¥id£¨¸üеÄʱºò²ÅÐèÒª´«£©
|
* @param name
|
* Ö±²¥Ãû³Æ
|
* @param content
|
* Ö±²¥½éÉÜ
|
* @param imgPath
|
* ͼƬµØÖ·
|
* @param startTime
|
* ¿ªÊ¼Ê±¼ä
|
* @param endTime
|
* ½áÊøÊ±¼ä
|
* @param isPlayBack
|
* ÊÇ·ñ»Ø·Å
|
* @param classIds
|
* °à¼¶id
|
* @return
|
*/
|
@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(",")));
|
}
|
}
|
|
/**
|
* ²éѯֱ²¥ÏêÇé
|
*
|
* @param videoLiveId
|
* Ö±²¥id
|
* @return
|
*/
|
@ApiOperation(value = "»ñȡֱ²¥ÏêÇé")
|
@GetMapping(value = "queryDetail")
|
public Result detail(String videoLiveId) {
|
List<String> lstClassIds = null;
|
List<Map<String,Object>> lstClassIdNames = null;
|
|
MediaVideoLive live = liveService.read(videoLiveId);
|
List<ClsClass> lstClassses = live.getClasses();
|
|
if(lstClassses!=null){
|
lstClassIds = new ArrayList<String>(lstClassses.size());
|
lstClassIdNames = new ArrayList<Map<String,Object>>(lstClassses.size());
|
|
for(ClsClass cls: lstClassses){
|
lstClassIds.add(cls.getClassId());
|
lstClassIdNames.add(CollectionUtils.newObjectMap("classId",cls.getClassId(),"className",cls.getName()));
|
}
|
}
|
|
return new Result(true, "success",
|
CollectionUtils.newObjectMap(
|
"videoLiveId",live.getVideoLiveId(),
|
"name", live.getName(),
|
"content", live.getRemark(),
|
"imgPath", live.getPreviewImgUrl(),
|
"isplayBack",1,
|
"startTime", live.getStartTime(),
|
"endTime", live.getEndTime(),
|
"rtmpPushUrl", live.getPushUrl(),
|
"hlsPullUrl", live.getHlsPullUrl(),
|
"chatroomId", dao.getChatRoomId(videoLiveId),
|
"watchTimes",live.getWatchTimes(),
|
"praiseTimes",live.getPraiseTimes(),
|
"definition",live.getDefinition(),
|
"subjectId",live.getSubjectId(),
|
"subjectName",live.getSubjectName(),
|
"status",live.getStatus(),
|
"teacherId",live.getAnchorId(),
|
"teacherName",live.getAnchor(),
|
"classIds",lstClassIds ,
|
"classes", lstClassIdNames));
|
}
|
|
/**
|
* ·¢²¼/¶à¸öÒÔ¶ººÅ¸ô¿ª
|
*
|
* @param videoLiveIds
|
* Ö±²¥ids
|
* @return
|
*/
|
@ApiOperation(value = "·¢²¼Ö±²¥")
|
@PostMapping(value = "release")
|
public Result release(String videoLiveIds) {
|
for(String liveId:videoLiveIds.split(",")) {
|
liveService.doIssue(liveId);
|
}
|
return Result.SUCCESS;
|
}
|
|
/**
|
* È¡Ïû·¢²¼/¶à¸öÒÔ¶ººÅ¸ô¿ª
|
*
|
* @param videoLiveIds
|
* Ö±²¥ids
|
* @return
|
*/
|
@ApiOperation(value = "È¡Ïû·¢²¼Ö±²¥")
|
@PostMapping(value = "cancel")
|
public Result cance(String videoLiveIds) {
|
|
for(String liveId:videoLiveIds.split(",")) {
|
liveService.doCancel(liveId);
|
}
|
return Result.SUCCESS;
|
}
|
|
/**
|
* ɾ³ý/¶à¸öÒÔ¶ººÅ¸ô¿ª
|
*
|
* @param videoLiveId
|
* @return
|
*/
|
@ApiOperation(value = "ɾ³ý´´½¨µÄÖ±²¥")
|
@PostMapping(value = "delete")
|
public Result delete(String videoLiveIds) {
|
return liveService.delete(videoLiveIds.split(","));
|
}
|
|
|
/**
|
* Ö±²¥¿ªÊ¼
|
*
|
* @param videoLiveIds
|
* Ö±²¥id
|
*/
|
@ApiOperation(value = "Ö±²¥¿ªÊ¼")
|
@PostMapping(value = "start")
|
public Result start(String videoLiveIds) {
|
|
for(String liveId:videoLiveIds.split(",")) {
|
liveService.doStart(liveId);
|
}
|
return Result.SUCCESS;
|
}
|
|
|
/**
|
* Ö±²¥ÔÝÍ£
|
*
|
* @param videoLiveIds
|
* Ö±²¥id
|
*/
|
@ApiOperation(value = "Ö±²¥ÔÝÍ£")
|
@PostMapping(value = "pause")
|
public Result pause(String videoLiveIds) {
|
|
for(String liveId:videoLiveIds.split(",")) {
|
liveService.doPause(liveId);
|
}
|
return Result.SUCCESS;
|
}
|
|
/**
|
* Ö±²¥½áÊø
|
*
|
* @param videoLiveId
|
* Ö±²¥id
|
*/
|
@ApiOperation(value = "Ö±²¥½áÊø")
|
@PostMapping(value = "stop")
|
public Result stop(String videoLiveIds) {
|
|
for(String liveId:videoLiveIds.split(",")) {
|
liveService.doStop(liveId);
|
}
|
return Result.SUCCESS;
|
}
|
|
|
|
/**
|
* Ö±²¥µãÔÞ
|
*
|
* @param videoLiveId
|
* Ö±²¥id
|
*/
|
@ApiOperation(value = "Ö±²¥µãÔÞ")
|
@PostMapping(value = "praise")
|
public Result praise(String videoLiveId) {
|
return liveService.doPraise(videoLiveId);
|
}
|
|
@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;
|
pageNum = pageNum != null && pageNum > 0 ? pageNum : DEFAULT_PAGE_NUM;
|
|
String [] arrClassIds = null;
|
if(StringUtils.isNotEmpty(classIds) || StringUtils.isNotBlank(ClientUtils.getClassId())){
|
arrClassIds = StringUtils.isEmpty(classIds)?new String[]{ClientUtils.getClassId()}:classIds.split(",");
|
}
|
|
int count = liveService.listCount(keyword==null?"":keyword.trim() , arrClassIds , subjectId , status);
|
List<MediaVideoLive> data = liveService.list(keyword==null?"":keyword.trim(),StringUtils.isEmpty(classIds)?new String[]{ClientUtils.getClassId()}:classIds.split(","),subjectId,status, pageNum, pageSize);
|
|
return new Result(true, "success", CollectionUtils.newObjectMap("videoLiveCount", count,
|
"videoLiveLst",QBeanUtils.listBean2ListMap(data, CollectionUtils.newStringMap(
|
"creator","creator",
|
"startTime","startTime",
|
"endTime","endTime",
|
"updateTime","lastUpdateTime",
|
"videoLiveId","videoLiveId",
|
"name","name",
|
"subjectId","subjectId",
|
"subjectName","subjectName",
|
"status","status",
|
"pushUrl","rtmpPushUrl",
|
"hlsPullUrl","hlsPullUrl",
|
"previewImgUrl","previewImgUrl"
|
))));
|
}
|
|
@ApiOperation(value = "Ö±²¥»Ø·ÅÁбí")
|
@GetMapping(value = "replay/list")
|
public Result listReplay(String videoLiveId) {
|
|
List<MediaVideoLiveReplay> data = mediaVideoLivePlayBackService.queryVideoLiveReplay(videoLiveId);
|
|
return new Result(true, "success", CollectionUtils.newObjectMap(
|
"replayList",QBeanUtils.listBean2ListMap(data, CollectionUtils.newStringMap(
|
"name","replayName",
|
"creator","creator",
|
"beginTime","beginTime",
|
"endTime","endTime",
|
"updateTime","updateTime",
|
"duration","duration",
|
"initialSize","initialSize",
|
"url","url",
|
"videoLiveId","videoLiveId",
|
"status","status",
|
"liveReplayId","liveReplayId"
|
))));
|
}
|
|
@ApiOperation(value = "²âÊÔÖ±²¥»Ø·Å")
|
@GetMapping(value = "replay/test")
|
public Result testReplay(String liveId) {
|
mediaVideoLivePlayBackService.testPlayBack(liveId);
|
return new Result(true);
|
}
|
|
}
|