import { client } from '../client';

export interface BgmMusicItem {
  id: number;
  title: string;
  artist: string | null;
  category: string;
  filePath: string;
  url: string;
  duration: number | null;
  sortOrder: number;
}

export interface BgmMusicListResponse {
  items: BgmMusicItem[];
  total: number;
}

/**
 * BGM 音乐 API
 */
export const bgmMusicApi = {
  /**
   * 获取背景音乐列表
   * @param category 场景分类筛选（可选）
   */
  list: async (category?: string): Promise<BgmMusicItem[]> => {
    const path = category ? `/bgm-musics?category=${encodeURIComponent(category)}` : '/bgm-musics';
    const response = await client.get<{ items: BgmMusicItem[]; total: number }>(path);
    return response.items || [];
  },
};
