From 332b79c13e4524e39c7bd75cfbbb4ee4b556a523 Mon Sep 17 00:00:00 2001 From: Bravepping <1131302745@qq.com> Date: Fri, 13 Jun 2025 16:41:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ping/study/controller/tx/LiveInfoController.java | 4 ++-- src/main/java/com/ping/study/mapper/UrlsMapper.java | 2 +- .../com/ping/study/service/tx/LiveInfoService.java | 3 ++- src/main/java/com/ping/study/utils/NbaApi.java | 12 ++---------- src/main/resources/mapper/UrlsMapper.xml | 2 +- 5 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/ping/study/controller/tx/LiveInfoController.java b/src/main/java/com/ping/study/controller/tx/LiveInfoController.java index ccc7e3f..bcd2108 100644 --- a/src/main/java/com/ping/study/controller/tx/LiveInfoController.java +++ b/src/main/java/com/ping/study/controller/tx/LiveInfoController.java @@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Mono; + @RestController @RequestMapping("/tx/nba") @@ -28,7 +28,7 @@ public class LiveInfoController { //定时执行更新直播链接 //定时任务 从北京时间凌晨到12点,每过半个小时执行一次 - @Scheduled(cron = "0 0/30 0-11 * * ?") + @Scheduled(cron = "0 0/15 0-12 * * ?") @RequestMapping("/live/refresh") public String refreshLiveInfo() throws Exception { log.info("=========开始执行更新直播链接========="); diff --git a/src/main/java/com/ping/study/mapper/UrlsMapper.java b/src/main/java/com/ping/study/mapper/UrlsMapper.java index 305f645..268a869 100644 --- a/src/main/java/com/ping/study/mapper/UrlsMapper.java +++ b/src/main/java/com/ping/study/mapper/UrlsMapper.java @@ -39,5 +39,5 @@ public interface UrlsMapper { void deleteAllUrls(); //更新比赛直播链接 - void updateUrlsWithGameId(String gameId, String s); + void updateUrlsWithGameId(String gameId, String s,String type); } diff --git a/src/main/java/com/ping/study/service/tx/LiveInfoService.java b/src/main/java/com/ping/study/service/tx/LiveInfoService.java index d5f4ae4..f1bf7e3 100644 --- a/src/main/java/com/ping/study/service/tx/LiveInfoService.java +++ b/src/main/java/com/ping/study/service/tx/LiveInfoService.java @@ -141,7 +141,8 @@ public class LiveInfoService { try { List urls = extractPlayUrls(liveInfo); log.info("提取到的播放URL: {}", urls); - urlsMapper.updateUrlsWithGameId(games.getGameId(), urls.get(urls.size()-1)); + urlsMapper.updateUrlsWithGameId(games.getGameId(), urls.get(urls.size()-1),"tx"); + urlsMapper.updateUrlsWithGameId(games.getGameId(), urls.get(0),"zb"); // 这里可以保存urls到数据库或其他处理 } catch (Exception e) { log.error("解析直播信息失败"); diff --git a/src/main/java/com/ping/study/utils/NbaApi.java b/src/main/java/com/ping/study/utils/NbaApi.java index 40a3a73..8208506 100644 --- a/src/main/java/com/ping/study/utils/NbaApi.java +++ b/src/main/java/com/ping/study/utils/NbaApi.java @@ -91,7 +91,7 @@ public class NbaApi { // 处理异常或设置默认值 entity.setStartTime(null); } - for (int j = 0; j < 4; j++){ + for (int j = 0; j < 2; j++){ Urls urls = new Urls(); // 每次新建一个对象 urls.setGameId(entity.getGameId()); switch (j) { @@ -100,15 +100,7 @@ public class NbaApi { urls.setUrl(""); break; case 1: - urls.setType("wl"); - urls.setUrl(""); - break; - case 2: - urls.setType("mg"); - urls.setUrl(""); - break; - case 3: - urls.setType("nba"); + urls.setType("zb"); urls.setUrl(""); break; } diff --git a/src/main/resources/mapper/UrlsMapper.xml b/src/main/resources/mapper/UrlsMapper.xml index 248fb87..611c37c 100644 --- a/src/main/resources/mapper/UrlsMapper.xml +++ b/src/main/resources/mapper/UrlsMapper.xml @@ -96,6 +96,6 @@ - update urls set url = #{s} where game_id = #{gameId} and type = 'tx' + update urls set url = #{s} where game_id = #{gameId} and type = #{type}