"use server"; import { fetchJson } from "@/lib/utils/server"; import { ResultDto } from "@/dtos/response/common"; import { BroadcastInfo, BroadcastListResponse } from "@/types/broadcast"; // 방송 목록 조회 (페이지네이션 지원) export async function fetchBroadcastList( page: number = 1, limit: number = 20 ): Promise> { return await fetchJson(`/api/broadcasts?page=${page}&limit=${limit}`, { method: "GET", headers: { Accept: "application/json", }, }); } // 인기 방송 목록 조회 export async function fetchPopularBroadcasts( limit: number = 5 ): Promise> { return await fetchJson(`/api/broadcasts/popular?limit=${limit}`, { method: "GET", headers: { Accept: "application/json", }, }); } // 실시간 방송 목록 조회 export async function fetchLiveBroadcasts( page: number = 1, limit: number = 20 ): Promise> { return await fetchJson( `/api/broadcasts/live?page=${page}&limit=${limit}`, { method: "GET", headers: { Accept: "application/json", }, } ); } // 방송 상세 정보 조회 export async function fetchBroadcastDetail(broadcastId: string): Promise> { return await fetchJson(`/api/broadcasts/${broadcastId}`, { method: "GET", headers: { Accept: "application/json", }, }); } // 카테고리별 방송 목록 조회 export async function fetchBroadcastsByCategory( category: string, page: number = 1, limit: number = 20 ): Promise> { return await fetchJson( `/api/broadcasts/category/${category}?page=${page}&limit=${limit}`, { method: "GET", headers: { Accept: "application/json", }, } ); } // 방송 검색 export async function searchBroadcasts( query: string, page: number = 1, limit: number = 20 ): Promise> { return await fetchJson( `/api/broadcasts/search?q=${encodeURIComponent(query)}&page=${page}&limit=${limit}`, { method: "GET", headers: { Accept: "application/json", }, } ); }