| | |
| | | <scope>runtime</scope> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>commons-beanutils</groupId> |
| | | <artifactId>commons-beanutils</artifactId> |
| | | <version>1.7.0</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>commons-codec</groupId> |
| | | <artifactId>commons-codec</artifactId> |
| | | <version>1.4</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>commons-collections</groupId> |
| | | <artifactId>commons-collections</artifactId> |
| | | <version>3.2.1</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>commons-httpclient</groupId> |
| | | <artifactId>commons-httpclient</artifactId> |
| | | <version>3.0.1</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>commons-beanutils</groupId> |
| | | <artifactId>commons-beanutils</artifactId> |
| | | <version>1.9.3</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>commons-collections</groupId> |
| | | <artifactId>commons-collections</artifactId> |
| | | <version>3.2.1</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>commons-lang</groupId> |
| | | <artifactId>commons-lang</artifactId> |
| | | <version>2.6</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>commons-logging</groupId> |
| | | <artifactId>commons-logging</artifactId> |
| | | <version>1.1.1</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>net.sf.ezmorph</groupId> |
| | | <artifactId>ezmorph</artifactId> |
| | | <version>1.0.6</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>net.sf.json-lib</groupId> |
| | | <artifactId>json-lib</artifactId> |
| | | <version>2.2.3</version> |
| | | <classifier>jdk15</classifier><!-- 指定jdk版本 --> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | <build> |
| | | <plugins> |
| | |
| | | |
| | | /** 得到classId*/ |
| | | public static String getClassId(){ |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | HttpSession session = request.getSession(); |
| | | String info = getUserInfo().getInfo(UserInfoWrapper.INF_CLASS_ID); |
| | | // HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | // HttpSession session = request.getSession(); |
| | | // String info = getUserInfo().getInfo(UserInfoWrapper.INF_CLASS_ID); |
| | | // if(info!=null){ |
| | | // info= (String) session.getAttribute(UserInfoWrapper.INF_CLASS_ID); |
| | | // } |
| | |
| | | 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.sdk.MTCloud; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import springfox.documentation.spring.web.json.Json; |
| | | |
| | | import static com.hankcs.hanlp.corpus.tag.Nature.r; |
| | | import static com.hankcs.hanlp.corpus.tag.Nature.s; |
| | | |
| | | @Api(tags="直播管理接口") |
| | | @RestController |
| | |
| | | |
| | | 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", |
| | |
| | | "pushUrl","rtmpPushUrl", |
| | | "hlsPullUrl","hlsPullUrl", |
| | | "previewImgUrl","previewImgUrl" |
| | | |
| | | )))); |
| | | } |
| | | |
| | |
| | | @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); |
| | | //将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)); |
| | | //调用第三方直播接口 |
| | | String s = client.courseAdd(name, "16624662432", 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) { |
| | | 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); |
| | | } |
| | | |
| | | @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("16624662432", 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); |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 删除/多个以逗号隔开 |
| | | * |
| | | * @param videoLiveId |
| | | * @param videoLiveIds |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "删除创建的直播") |
| | |
| | | /** |
| | | * 直播结束 |
| | | * |
| | | * @param videoLiveId |
| | | * @param videoLiveIds |
| | | * 直播id |
| | | */ |
| | | @ApiOperation(value = "直播结束") |
| | |
| | | "status","status", |
| | | "pushUrl","rtmpPushUrl", |
| | | "hlsPullUrl","hlsPullUrl", |
| | | "previewImgUrl","previewImgUrl" |
| | | "previewImgUrl","previewImgUrl", |
| | | "courseId","courseId" |
| | | )))); |
| | | } |
| | | |
New file |
| | |
| | | package com.qxueyou.scc.sdk; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | public class CommonResult<T> implements Serializable { |
| | | private static final long serialVersionUID = 7917345507074842804L; |
| | | private String code; |
| | | private String msg; |
| | | private T data; |
| | | private String format = "json"; |
| | | |
| | | public static class Builder { |
| | | public static com.qxueyou.scc.sdk.CommonResult SUCC() { |
| | | com.qxueyou.scc.sdk.CommonResult vo = new com.qxueyou.scc.sdk.CommonResult(); |
| | | vo.setCode("0"); |
| | | vo.setmsg("suc"); |
| | | return vo; |
| | | } |
| | | |
| | | public static com.qxueyou.scc.sdk.CommonResult FAIL() { |
| | | com.qxueyou.scc.sdk.CommonResult vo = new com.qxueyou.scc.sdk.CommonResult(); |
| | | return vo; |
| | | } |
| | | } |
| | | |
| | | public com.qxueyou.scc.sdk.CommonResult initErrCodeAndMsg(String code, String msg) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | return this; |
| | | } |
| | | |
| | | public com.qxueyou.scc.sdk.CommonResult initErrCodeAndMsg(int code, String msg) { |
| | | this.code = Integer.toString(code); |
| | | this.msg = msg; |
| | | return this; |
| | | } |
| | | |
| | | public com.qxueyou.scc.sdk.CommonResult initSuccCodeAndMsg(String code, String msg) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | return this; |
| | | } |
| | | |
| | | public com.qxueyou.scc.sdk.CommonResult initSuccData(T data) { |
| | | this.data = data; |
| | | return this; |
| | | } |
| | | |
| | | public static long getSerialVersionUID() { |
| | | return serialVersionUID; |
| | | } |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(String code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | public String getmsg() { |
| | | return msg; |
| | | } |
| | | |
| | | public void setmsg(String msg) { |
| | | this.msg = msg; |
| | | } |
| | | |
| | | public T getData() { |
| | | return data; |
| | | } |
| | | |
| | | public void setData(T data) { |
| | | this.data = data; |
| | | } |
| | | } |
New file |
| | |
| | | package com.qxueyou.scc.sdk.utils; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.nio.MappedByteBuffer; |
| | | import java.nio.channels.FileChannel; |
| | | import java.security.MessageDigest; |
| | | import java.security.NoSuchAlgorithmException; |
| | | |
| | | public class MD5Util { |
| | | |
| | | protected static char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9','a', 'b', 'c', 'd', 'e', 'f' }; |
| | | protected static MessageDigest messagedigest = null; |
| | | static{ |
| | | try{ |
| | | messagedigest = MessageDigest.getInstance("MD5"); |
| | | }catch(NoSuchAlgorithmException nsaex){ |
| | | System.err.println(MD5Util.class.getName()+"初始化失败,MessageDigest不支持MD5Util。"); |
| | | nsaex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | public static String getFileMD5String(File file) throws IOException { |
| | | FileInputStream in = new FileInputStream(file); |
| | | FileChannel ch = in.getChannel(); |
| | | MappedByteBuffer byteBuffer = ch.map(FileChannel.MapMode.READ_ONLY, 0, file.length()); |
| | | messagedigest.update(byteBuffer); |
| | | return bufferToHex(messagedigest.digest()); |
| | | } |
| | | |
| | | public static String getMD5String(String s) { |
| | | return getMD5String(s.getBytes()); |
| | | } |
| | | |
| | | public static String getMD5String(byte[] bytes) { |
| | | messagedigest.update(bytes); |
| | | return bufferToHex(messagedigest.digest()); |
| | | } |
| | | |
| | | private static String bufferToHex(byte bytes[]) { |
| | | return bufferToHex(bytes, 0, bytes.length); |
| | | } |
| | | |
| | | private static String bufferToHex(byte bytes[], int m, int n) { |
| | | StringBuffer stringbuffer = new StringBuffer(2 * n); |
| | | int k = m + n; |
| | | for (int l = m; l < k; l++) { |
| | | appendHexPair(bytes[l], stringbuffer); |
| | | } |
| | | return stringbuffer.toString(); |
| | | } |
| | | |
| | | |
| | | private static void appendHexPair(byte bt, StringBuffer stringbuffer) { |
| | | char c0 = hexDigits[(bt & 0xf0) >> 4]; |
| | | char c1 = hexDigits[bt & 0xf]; |
| | | stringbuffer.append(c0); |
| | | stringbuffer.append(c1); |
| | | } |
| | | |
| | | public static boolean checkPassword(String password, String md5PwdStr) { |
| | | String s = getMD5String(password); |
| | | return s.equals(md5PwdStr); |
| | | } |
| | | } |
| | |
| | | package com.qxueyou.scc.stucontroller; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.qxueyou.scc.sdk.MTCloud; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | |
| | | /** |
| | | * 查看直播明细 |
| | | * @param liveId 直播id |
| | | * @param couresId 直播id |
| | | * @return |
| | | */ |
| | | @GetMapping(value = "view") |
| | | public Result view(String liveId) { |
| | | |
| | | MediaVideoLive live = liveService.read(liveId); |
| | | |
| | | return new Result(true, "success", CollectionUtils.newObjectMap( |
| | | "startTime",live.getStartTime(), |
| | | "endTime",live.getEndTime(), |
| | | "name",live.getName(), |
| | | "hlsPullUrl",live.getHlsPullUrl(), |
| | | "imgPath",live.getPreviewImgUrl(), |
| | | "chatroomId",dao.getChatRoomId(liveId), |
| | | "remark",live.getRemark() |
| | | )); |
| | | public Result view(String couresId) throws Exception { |
| | | |
| | | |
| | | MTCloud client = new MTCloud(); |
| | | |
| | | HashMap<Object,Object> options = new HashMap<Object, Object>(); |
| | | |
| | | String res = client.courseAccess(couresId, ClientUtils.getUserId(), ClientUtils.getUserName(), MTCloud.ROLE_USER, 10000, options); |
| | | |
| | | JSONObject jsonObject = JSON.parseObject(res); |
| | | |
| | | JSONObject data = jsonObject.getJSONObject("data"); |
| | | |
| | | String liveUrl = (String) data.get("liveUrl"); |
| | | |
| | | System.out.println(liveUrl); |
| | | |
| | | return new Result(true, "success",liveUrl); |
| | | } |
| | | } |
| | |
| | | /** 唐桥加入课堂密码 */ |
| | | @Column(name="TQ_MEETING_PWD", length=32) |
| | | private String meetingPwd; |
| | | |
| | | /** 第三方直播入口 */ |
| | | @Column(name="COURSE_ID", length=32) |
| | | private int courseId; |
| | | |
| | | @OneToMany(fetch = FetchType.LAZY, mappedBy = "videoLive") |
| | | @JsonIgnore |
| | |
| | | return subject; |
| | | } |
| | | |
| | | public int getCourseId() { |
| | | return courseId; |
| | | } |
| | | |
| | | public void setCourseId(int courseId) { |
| | | this.courseId = courseId; |
| | | } |
| | | |
| | | public void setSubject(Subject subject) { |
| | | this.subject = subject; |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | * @param classId 班级ids |
| | | * @return |
| | | */ |
| | | Result add(String name,String content,String teacherId,String teacherName,String subjectId,String subjectName,String definition,String imgPath,Date startTime,Date endTime,boolean record,List<String> classIds); |
| | | Result add(String name,String content,String teacherId,String teacherName,String subjectId,String subjectName,String definition,String imgPath,Date startTime,Date endTime,Integer courseId,boolean record,List<String> classIds); |
| | | |
| | | /** |
| | | * 查询直播 |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | |
| | | |
| | | |
| | | @Override |
| | | public Result add(String name, String content, String teacherId,String teacherName ,String subjectId,String subjectName, |
| | | String definition,String imgPath, Date startTime, Date endTime, boolean record,List<String> classIds) { |
| | | public Result add(String name, String content, String teacherId, String teacherName , String subjectId, String subjectName, |
| | | String definition, String imgPath, Date startTime, Date endTime, Integer courseId, boolean record, List<String> classIds) { |
| | | |
| | | UserTeacher teacher = teacherService.getTeacherByUserId(ClientUtils.getUserId()); |
| | | |
| | | MediaVideoLive live = new MediaVideoLive(); |
| | | TraceUtils.setCreateTrace(live); |
| | | |
| | | |
| | | live.setCourseId(courseId); |
| | | live.setName(name); |
| | | live.setRemark(content); |
| | | live.setPreviewImgUrl(imgPath); |
| | |
| | | public List<MediaVideoLive> list(String keyword, String [] classIds,String subjectId,Short status,Integer pageNum, Integer pageSize) { |
| | | StringBuffer hql = new StringBuffer(1000); |
| | | Map<String,Object> params = new HashMap<String,Object>(); |
| | | hql.append("from MediaVideoLive m left join fetch m.classes c left join fetch m.subject s where m.deleteFlag is false and m.name like :name "); |
| | | hql.append("from MediaVideoLive m left join fetch m.classes c left join fetch m.subject s where m.deleteFlag is false and m.name like :name "); |
| | | |
| | | params.put("name",keyword + "%"); |
| | | |
| | | if(classIds!=null && classIds.length>0){ |
| | | hql.append(" and (c.classId in(:classIds) or s.type=:subjectType)"); |
| | | hql.append(" and (c.classId in(:classIds) or s.type=:Type)"); |
| | | params.put("classIds", classIds); |
| | | params.put("subjectType", Subject.TYPE_PUBLIC_SUBJECT); |
| | | params.put("Type", Subject.TYPE_PUBLIC_SUBJECT); |
| | | }else{ |
| | | hql.append(" and s.type=:subjectType"); |
| | | params.put("subjectType", Subject.TYPE_PUBLIC_SUBJECT); |
| | |
| | | public Result readAccessPath(String resId, String attribute) { |
| | | |
| | | Res res = read(Res.class, resId); |
| | | |
| | | String type="0"; |
| | | // Object path = Res.FILE_TYPE_VIDEO.equals(res.getType())? JSONObject.parse(resItemServiceMap.get(res.getType()).readAccessPath(res.getItemDestId(), attribute)):CollectionUtils.newObjectMap("path", resItemServiceMap.get(res.getType()).readAccessPath(res.getItemDestId(), attribute)); |
| | | Object path = Res.FILE_TYPE_VIDEO.equals(res.getType())? resItemServiceMap.get(res.getType()).readAccessPath(res.getItemDestId(), attribute):resItemServiceMap.get(res.getType()).readAccessPath(res.getItemDestId(), attribute); |
| | | Object path = Res.FILE_TYPE_VIDEO.equals(type)? resItemServiceMap.get(type).readAccessPath(res.getItemDestId(), attribute):resItemServiceMap.get(type).readAccessPath(res.getItemDestId(), attribute); |
| | | if(Res.FILE_TYPE_DOC.equals(res.getType())) { |
| | | return new Result(true, "success", |
| | | CollectionUtils.newObjectMap("path", path, "name", res.getName(), "coverPageUrl", res.getCoverPageUrl(), "size", |