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

// ==================== LiveStream Admin APIs ====================

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

// 获取单个 LiveStream
export function getLiveStream(id: number): Promise<IBaseResponse<LiveStreamDTO>> {
  return post('/admin/live-stream/get', { id })
}

// 创建 LiveStream
export function addLiveStream(data: LiveStreamAddRequest): Promise<IBaseResponse<LiveStreamDTO>> {
  return post('/admin/live-stream/add', data)
}

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

// 删除 LiveStream
export function deleteLiveStream(id: number): Promise<BaseResponse> {
  return post('/admin/live-stream/delete', { id })
}

// 启动 LiveStream
export function startLiveStream(id: number): Promise<BaseResponse> {
  return post('/admin/live-stream/start', { id })
}

// 停止 LiveStream
export function stopLiveStream(id: number): Promise<BaseResponse> {
  return post('/admin/live-stream/stop', { id })
}

// 获取 LSS 下拉列表（用于选择）
export function getLssOptions(): Promise<IBaseResponse<LssDTO[]>> {
  return post('/admin/lss/options', {})
}

// 获取摄像头下拉列表（用于选择）
export function getCameraOptions(): Promise<IBaseResponse<CameraInfoDTO[]>> {
  return post('/admin/camera/options', {})
}
