This commit is contained in:
2025-06-13 16:41:47 +08:00
parent 1c68932238
commit 332b79c13e
5 changed files with 8 additions and 15 deletions

View File

@@ -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("=========开始执行更新直播链接=========");

View File

@@ -39,5 +39,5 @@ public interface UrlsMapper {
void deleteAllUrls();
//更新比赛直播链接
void updateUrlsWithGameId(String gameId, String s);
void updateUrlsWithGameId(String gameId, String s,String type);
}

View File

@@ -141,7 +141,8 @@ public class LiveInfoService {
try {
List<String> 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("解析直播信息失败");

View File

@@ -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;
}

View File

@@ -96,6 +96,6 @@
</delete>
<update id="updateUrlsWithGameId" parameterType="map">
update urls set url = #{s} where game_id = #{gameId} and type = 'tx'
update urls set url = #{s} where game_id = #{gameId} and type = #{type}
</update>
</mapper>