From 0ad2f07a292895eeb3b9618eb1e275568c63a59e Mon Sep 17 00:00:00 2001
From: EricsHu <hrr145632>
Date: 星期五, 24 十一月 2023 18:09:23 +0800
Subject: [PATCH] 优化直播、添加班级

---
 src/main/java/com/qxueyou/scc/teach/live/service/impl/MediaLiveService.java |   66 ++++++++++++++++++++-------------
 1 files changed, 40 insertions(+), 26 deletions(-)

diff --git a/src/main/java/com/qxueyou/scc/teach/live/service/impl/MediaLiveService.java b/src/main/java/com/qxueyou/scc/teach/live/service/impl/MediaLiveService.java
index da26763..07e2c27 100644
--- a/src/main/java/com/qxueyou/scc/teach/live/service/impl/MediaLiveService.java
+++ b/src/main/java/com/qxueyou/scc/teach/live/service/impl/MediaLiveService.java
@@ -80,7 +80,8 @@
 
 		live.setSubjectId(subjectId);
 		live.setSubjectName(subjectName);
-
+		live.setCreateId(teacher.getTeacherId());
+		live.setCreateTime(new Date());
 		String uuid = UUIDUtils.UUID();
 		live.setWyLiveNumber(uuid);
 		live.setPushUrl(cfg.getRtmpService().concat(uuid));
@@ -109,7 +110,7 @@
 		live.setEndTime(endTime);
 		live.setSubjectId(subjectId);
 		live.setSubjectName(subjectName);
-
+		live.setCreateTime(new Date());
 		save(live);
 
 		//鏇存柊鐝骇璇剧▼鍏宠仈鍏崇郴
@@ -195,26 +196,26 @@
 		}
 	}
 
-	@Scheduled(cron = " 0 0/5 * * * ?")
-	protected void doTimer() {
-//		System.out.println("鎵ц鐩存挱鎻愰啋瀹氭椂鍣�");
-		Calendar cal = Calendar.getInstance();
-		cal.add(Calendar.HOUR, 1);
-		Date beginDate = cal.getTime();
-
-		cal.add(Calendar.MINUTE, 5);
-		Date endDate = cal.getTime();
-
-		//鏌ヨ1灏忔椂鍐呭皢寮�濮嬬殑鐩存挱
-		List<MediaVideoLive> lstLives = this.find("from MediaVideoLive where startTime>=? and startTime<? and status=? and deleteFlag is false ",
-				CollectionUtils.newList(beginDate,endDate,MediaVideoLive.STATUS_LIVE_REVIEW), MediaVideoLive.class);
-
-		if(lstLives!=null && lstLives.size()>0){
-			for(MediaVideoLive live:lstLives){
-				this.doLiveRemindMsg(live.getVideoLiveId(),MsgInfo.TYPE_REMIND, "鐩存挱椹笂寮�濮嬩簡锛岃鍋氬ソ鐩存挱鍑嗗");
-			}
-		}
-	}
+//	@Scheduled(cron = " 0 0/5 * * * ?")
+//	protected void doTimer() {
+////		System.out.println("鎵ц鐩存挱鎻愰啋瀹氭椂鍣�");
+//		Calendar cal = Calendar.getInstance();
+//		cal.add(Calendar.HOUR, 1);
+//		Date beginDate = cal.getTime();
+//
+//		cal.add(Calendar.MINUTE, 5);
+//		Date endDate = cal.getTime();
+//
+//		//鏌ヨ1灏忔椂鍐呭皢寮�濮嬬殑鐩存挱
+//		List<MediaVideoLive> lstLives = this.find("from MediaVideoLive where startTime>=? and startTime<? and status=? and deleteFlag is false ",
+//				CollectionUtils.newList(beginDate,endDate,MediaVideoLive.STATUS_LIVE_REVIEW), MediaVideoLive.class);
+//
+//		if(lstLives!=null && lstLives.size()>0){
+//			for(MediaVideoLive live:lstLives){
+//				this.doLiveRemindMsg(live.getVideoLiveId(),MsgInfo.TYPE_REMIND, "鐩存挱椹笂寮�濮嬩簡锛岃鍋氬ソ鐩存挱鍑嗗");
+//			}
+//		}
+//	}
 
 	private void doLiveRemindMsg(String liveId,short type,String msg){
 		MediaVideoLive  liveInfo = this.read(liveId);
@@ -336,22 +337,35 @@
 
 	@Override
 	public List<MediaVideoLive> listvideo(String status) {
-
-		String hql = "from MediaVideoLive where deleteFlag is false and status=?  order by createTime desc";
+		//鏄惁鏄�佸笀
+		String teacherId = ClientUtils.isAdmin() ? null : teacherService.getTeacherIdByUserId(ClientUtils.getUserId());
+		String hql = "from MediaVideoLive where deleteFlag is false and status=? ";
+		List<Object> args =CollectionUtils.newList(status);
+		if (StringUtils.isNotBlank(teacherId)) {
+			hql.concat(" and createId=?");
+			args.add(teacherId);
+		}
+		hql.concat(" order by createTime desc");
 
 
-		return find(hql, CollectionUtils.newList(status), MediaVideoLive.class);
+
+		return find(hql, args, MediaVideoLive.class);
 	}
 
 	@Override
 	public List<MediaVideoLive> listOfMine(String keyword,String portalStatus, Integer pageNum, Integer pageSize) {
-
+		//鏄惁鏄�佸笀
+		String teacherId = ClientUtils.isAdmin() ? null : teacherService.getTeacherIdByUserId(ClientUtils.getUserId());
 		StringBuffer hql = new StringBuffer("from MediaVideoLive where deleteFlag is false and name like ? ");
 		List<Object> args =CollectionUtils.newList(keyword + "%");
 		if(portalStatus != ""){
 			hql.append(" and portalStatus = ?");
 			args.add(portalStatus);
 		}
+		if (StringUtils.isNotBlank(teacherId)) {
+			hql.append(" and createId=?");
+			args.add(teacherId);
+		}
 		hql.append(" order by createTime desc");
 		return findList(hql.toString(), new Pager(pageSize, pageNum),args , MediaVideoLive.class);
 	}

--
Gitblit v1.8.0