Browse Source

增加定时任务

hgw 3 years ago
parent
commit
a3ebfd2b59

+ 7 - 0
cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/TeacherFeignService.java

@@ -34,6 +34,13 @@ public interface TeacherFeignService {
     HttpResponseResult<Object> destroyExpiredLiveRoom();
 
     /**
+     * 定时任务-创建直播间-直播间
+     * 每分钟执行一次
+     */
+    @GetMapping(value = "/task/createCourseLiveRoom")
+    HttpResponseResult<Object> createCourseLiveRoom();
+
+    /**
      * @Description: 课程提醒(每晚9点)
      * @Author: cy
      * @Date: 2022/5/6

+ 5 - 0
cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/fallback/TeacherFeignServiceFallback.java

@@ -23,6 +23,11 @@ public class TeacherFeignServiceFallback implements TeacherFeignService {
     }
 
     @Override
+    public HttpResponseResult<Object> createCourseLiveRoom() {
+        return null;
+    }
+
+    @Override
     public HttpResponseResult<Object> courseRemind() {
         return null;
     }

+ 18 - 0
cooleshow-task/src/main/java/com/yonge/cooleshow/task/jobs/CreateCourseLiveRoomTask.java

@@ -0,0 +1,18 @@
+package com.yonge.cooleshow.task.jobs;
+
+import com.yonge.cooleshow.api.feign.TeacherFeignService;
+import com.yonge.cooleshow.task.core.BaseTask;
+import com.yonge.cooleshow.task.core.TaskException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class CreateCourseLiveRoomTask extends BaseTask {
+    @Autowired
+    private TeacherFeignService teacherFeignService;
+
+    @Override
+    public void execute() throws TaskException {
+        teacherFeignService.createCourseLiveRoom();
+    }
+}

+ 0 - 6
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherLiveRoomController.java

@@ -80,12 +80,6 @@ public class TeacherLiveRoomController extends BaseController {
         return succeed(liveRoomService.speakerJoinRoom(roomUid));
     }
 
-    @ApiOperation("定时任务-创建房间-直播间")
-    @GetMapping("/createCourseLiveRoom")
-    public void createCourseLiveRoom() {
-        liveRoomService.createCourseLiveRoom();
-    }
-
     @ApiOperation("手动关闭直播间")
     @GetMapping("/destroyLiveRoom")
     public HttpResponseResult<Object> destroyLiveRoom(@ApiParam(value = "房间uid", required = true) String roomUid) {

+ 6 - 0
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/task/TaskController.java

@@ -61,6 +61,12 @@ public class TaskController extends BaseController {
         liveRoomService.destroyExpiredLiveRoom();
     }
 
+    @ApiOperation("定时任务-创建房间-直播间")
+    @GetMapping("/createCourseLiveRoom")
+    public void createCourseLiveRoom() {
+        liveRoomService.createCourseLiveRoom();
+    }
+
     @GetMapping("/getRedisValueByKey")
     public HttpResponseResult<Object> getRedisValueByKey(String key) {
         return succeed(teacherTotalService.getRedisValueByKey(key));