package com.ping.study.controller.tx; import com.ping.study.service.UrlsService; import com.ping.study.service.tx.LiveInfoService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/tx/nba") @Slf4j public class LiveInfoController { private final LiveInfoService liveInfoService; public LiveInfoController(LiveInfoService liveInfoService) { this.liveInfoService = liveInfoService; } @GetMapping("/live/{cnlid}") public String getLiveInfo(@PathVariable String cnlid) throws Exception { log.info("执行查询直播id: {}", cnlid); return liveInfoService.getLiveInfo(cnlid); } //定时执行更新直播链接 //定时任务 从北京时间凌晨到12:00点,每过5分钟执行一次 @Scheduled(cron = "0 0/10 0-12 * * ?") @RequestMapping("/live/refresh") public String refreshLiveInfo() throws Exception { log.info("=========开始执行更新直播链接========="); return liveInfoService.refreshLiveInfo(); } }