添加联赛列表接口

This commit is contained in:
xianyi
2026-01-13 17:13:40 +08:00
parent 5fa261591c
commit 91cf23cd11
3 changed files with 41 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ export const API_CONFIG = {
export const API_ENDPOINTS = { export const API_ENDPOINTS = {
SPORTS: "/v1/api/sports", SPORTS: "/v1/api/sports",
COUNTRIES: "/v1/api/countries", COUNTRIES: "/v1/api/countries",
LEAGUES: "/v1/api/leagues",
MATCHES_TODAY: "/v1/api/matches/today", MATCHES_TODAY: "/v1/api/matches/today",
MATCH_DETAIL: (id: string) => `/v1/api/matches/${id}`, MATCH_DETAIL: (id: string) => `/v1/api/matches/${id}`,
}; };

View File

@@ -3,6 +3,7 @@ import {
ApiListResponse, ApiListResponse,
ApiResponse, ApiResponse,
Country, Country,
League,
Match, Match,
MatchDetailData, MatchDetailData,
Sport, Sport,
@@ -48,6 +49,30 @@ export const fetchCountries = async (): Promise<Country[]> => {
} }
}; };
export const fetchLeagues = async (
sportId: number,
countryKey: string
): Promise<League[]> => {
try {
const response = await apiClient.get<ApiResponse<ApiListResponse<League>>>(
API_ENDPOINTS.LEAGUES,
{
params: {
sportId,
countryKey,
},
}
);
if (response.data.code === 0) {
return response.data.data.list;
}
throw new Error(response.data.message);
} catch (error) {
console.error("Fetch leagues error:", error);
throw error;
}
};
export const fetchTodayMatches = async (sportId: number): Promise<Match[]> => { export const fetchTodayMatches = async (sportId: number): Promise<Match[]> => {
try { try {
const response = await apiClient.get<ApiResponse<ApiListResponse<Match>>>( const response = await apiClient.get<ApiResponse<ApiListResponse<Match>>>(

View File

@@ -40,6 +40,21 @@ export interface Country {
isActive: boolean; isActive: boolean;
} }
export interface League {
id: number;
key: string;
name: string;
description: string;
sportId: number;
countryKey: string;
countryName: string;
countryLogo: string;
logo: string;
isActive: boolean;
createdAt: string;
updatedAt: string;
}
export interface GoalEvent { export interface GoalEvent {
time: string; time: string;
home_scorer?: string; home_scorer?: string;