| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- "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<ResultDto<BroadcastListResponse>> {
- return await fetchJson<BroadcastListResponse>(`/api/broadcasts?page=${page}&limit=${limit}`, {
- method: "GET",
- headers: {
- Accept: "application/json",
- },
- });
- }
- // 인기 방송 목록 조회
- export async function fetchPopularBroadcasts(
- limit: number = 5
- ): Promise<ResultDto<BroadcastInfo[]>> {
- return await fetchJson<BroadcastInfo[]>(`/api/broadcasts/popular?limit=${limit}`, {
- method: "GET",
- headers: {
- Accept: "application/json",
- },
- });
- }
- // 실시간 방송 목록 조회
- export async function fetchLiveBroadcasts(
- page: number = 1,
- limit: number = 20
- ): Promise<ResultDto<BroadcastListResponse>> {
- return await fetchJson<BroadcastListResponse>(
- `/api/broadcasts/live?page=${page}&limit=${limit}`,
- {
- method: "GET",
- headers: {
- Accept: "application/json",
- },
- }
- );
- }
- // 방송 상세 정보 조회
- export async function fetchBroadcastDetail(broadcastId: string): Promise<ResultDto<BroadcastInfo>> {
- return await fetchJson<BroadcastInfo>(`/api/broadcasts/${broadcastId}`, {
- method: "GET",
- headers: {
- Accept: "application/json",
- },
- });
- }
- // 카테고리별 방송 목록 조회
- export async function fetchBroadcastsByCategory(
- category: string,
- page: number = 1,
- limit: number = 20
- ): Promise<ResultDto<BroadcastListResponse>> {
- return await fetchJson<BroadcastListResponse>(
- `/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<ResultDto<BroadcastListResponse>> {
- return await fetchJson<BroadcastListResponse>(
- `/api/broadcasts/search?q=${encodeURIComponent(query)}&page=${page}&limit=${limit}`,
- {
- method: "GET",
- headers: {
- Accept: "application/json",
- },
- }
- );
- }
|