import { get, post } from '@/utils/request'
import type {
  IPageResponse,
  IBaseResponse,
  IListResponse,
  BaseResponse,
  StreamChannelDTO,
  StreamChannelListRequest,
  StreamChannelAddRequest,
  StreamChannelUpdateRequest
} from '@/types'

/**
 * 获取推流通道列表（分页）
 * POST /api/admin/stream-channels/list
 */
export function listStreamChannels(params?: StreamChannelListRequest): Promise<IPageResponse<StreamChannelDTO>> {
  return post('/admin/stream-channels/list', params || {})
}

/**
 * 获取推流通道列表（全部，不分页）
 * GET /api/admin/stream-channels/listAll
 */
export function listAllStreamChannels(): Promise<IListResponse<StreamChannelDTO>> {
  return get('/admin/stream-channels/listAll')
}

/**
 * 获取推流通道详情
 * GET /api/admin/stream-channels/detail?id=X
 */
export function getStreamChannelDetail(id: number): Promise<IBaseResponse<StreamChannelDTO>> {
  return get('/admin/stream-channels/detail', { id })
}

/**
 * 添加推流通道
 * POST /api/admin/stream-channels/add
 */
export function addStreamChannel(data: StreamChannelAddRequest): Promise<IBaseResponse<StreamChannelDTO>> {
  return post('/admin/stream-channels/add', data)
}

/**
 * 更新推流通道
 * POST /api/admin/stream-channels/update
 */
export function updateStreamChannel(data: StreamChannelUpdateRequest): Promise<IBaseResponse<StreamChannelDTO>> {
  return post('/admin/stream-channels/update', data)
}

/**
 * 删除推流通道
 * POST /api/admin/stream-channels/delete?id=X
 */
export function deleteStreamChannel(id: number): Promise<BaseResponse> {
  return post('/admin/stream-channels/delete', null, { params: { id } })
}
