import { get, post } from '@/utils/request'
import type {
  IPageResponse,
  IBaseResponse,
  IListResponse,
  BaseResponse,
  LiveStreamDTO,
  LiveStreamListRequest,
  LiveStreamAddRequest,
  LiveStreamUpdateRequest
} from '@/types'

/**
 * 获取 LiveStream 列表（分页）
 * POST /api/admin/live-stream/list
 */
export function listLiveStreams(params?: LiveStreamListRequest): Promise<IPageResponse<LiveStreamDTO>> {
  return post('/admin/live-stream/list', params || {})
}

/**
 * 获取全部 LiveStream 列表（不分页）
 * GET /api/admin/live-stream/listAll
 */
export function listAllLiveStreams(): Promise<IListResponse<LiveStreamDTO>> {
  return get('/admin/live-stream/listAll')
}

/**
 * 根据 LSS ID 获取 LiveStream 列表
 * GET /api/admin/live-stream/listByLssId?lssId=xxx
 */
export function listLiveStreamsByLssId(lssId: string): Promise<IListResponse<LiveStreamDTO>> {
  return get('/admin/live-stream/listByLssId', { lssId })
}

/**
 * 获取 LiveStream 详情
 * GET /api/admin/live-stream/detail?id=X
 */
export function getLiveStreamDetail(id: number): Promise<IBaseResponse<LiveStreamDTO>> {
  return get('/admin/live-stream/detail', { id })
}

/**
 * 根据 streamSn 获取 LiveStream 详情
 * GET /api/admin/live-stream/detailByStreamSn?streamSn=xxx
 */
export function getLiveStreamByStreamSn(streamSn: string): Promise<IBaseResponse<LiveStreamDTO>> {
  return get('/admin/live-stream/detailByStreamSn', { streamSn })
}

/**
 * 添加 LiveStream
 * POST /api/admin/live-stream/add
 */
export function addLiveStream(data: LiveStreamAddRequest): Promise<IBaseResponse<LiveStreamDTO>> {
  return post('/admin/live-stream/add', data)
}

/**
 * 更新 LiveStream
 * POST /api/admin/live-stream/update
 */
export function updateLiveStream(data: LiveStreamUpdateRequest): Promise<IBaseResponse<LiveStreamDTO>> {
  return post('/admin/live-stream/update', data)
}

/**
 * 删除 LiveStream
 * POST /api/admin/live-stream/delete?id=X
 */
export function deleteLiveStream(id: number): Promise<BaseResponse> {
  return post('/admin/live-stream/delete', null, { params: { id } })
}

/**
 * 批量删除 LiveStream
 * POST /api/admin/live-stream/deleteBatch
 */
export function deleteLiveStreamBatch(ids: number[]): Promise<IBaseResponse<number>> {
  return post('/admin/live-stream/deleteBatch', { ids })
}
