Files
NBA/src/main/java/com/ping/study/controller/tx/MatchController.java
2025-04-21 11:17:19 +08:00

50 lines
1.7 KiB
Java

package com.ping.study.controller.tx;
import com.ping.study.model.dto.tx.MatchListRequest;
import com.ping.study.service.tx.MatchService;
import com.ping.study.service.tx.SportsQqService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
import java.time.LocalDate;
import java.util.List;
@RestController
@RequestMapping("/tx/nba")
public class MatchController {
private final SportsQqService sportsQqService;
private final MatchService matchService;
public MatchController(MatchService matchService,SportsQqService sportsQqService) {
this.sportsQqService = sportsQqService;
this.matchService = matchService;
}
@GetMapping("/matches")
public Mono<String> getMatches(
@RequestParam(required = false, defaultValue = "100000") Integer columnId,
@RequestParam String startTime,
@RequestParam String endTime) {
MatchListRequest request = new MatchListRequest();
request.setColumnId(columnId);
request.setStartTime(LocalDate.parse(startTime));
request.setEndTime(LocalDate.parse(endTime));
return sportsQqService.getMatchList(request);
}
@GetMapping("/lives")
public List<String> getPlayoffLiveIds(
@RequestParam String startTime,
@RequestParam String endTime) {
LocalDate startDate = LocalDate.parse(startTime);
LocalDate endDate = LocalDate.parse(endTime);
return matchService.getPlayoffLiveIdsBlocking(startDate, endDate);
}
}