/**
 * 套餐系列管理 API 服务
 */

import { BaseService } from '../BaseService'
import type {
  PackageSeriesResponse,
  PackageSeriesQueryParams,
  CreatePackageSeriesRequest,
  UpdatePackageSeriesRequest,
  UpdatePackageSeriesStatusRequest,
  BaseResponse,
  PaginationResponse
} from '@/types/api'

export class PackageSeriesService extends BaseService {
  /**
   * 获取套餐系列分页列表
   * GET /api/admin/package-series
   * @param params 查询参数
   */
  static getPackageSeries(
    params?: PackageSeriesQueryParams
  ): Promise<PaginationResponse<PackageSeriesResponse>> {
    return this.getPage<PackageSeriesResponse>('/api/admin/package-series', params)
  }

  /**
   * 创建套餐系列
   * POST /api/admin/package-series
   * @param data 套餐系列数据
   */
  static createPackageSeries(
    data: CreatePackageSeriesRequest
  ): Promise<BaseResponse<PackageSeriesResponse>> {
    return this.create<PackageSeriesResponse>('/api/admin/package-series', data)
  }

  /**
   * 获取套餐系列详情
   * GET /api/admin/package-series/{id}
   * @param id 系列ID
   */
  static getPackageSeriesDetail(id: number): Promise<BaseResponse<PackageSeriesResponse>> {
    return this.getOne<PackageSeriesResponse>(`/api/admin/package-series/${id}`)
  }

  /**
   * 更新套餐系列
   * PUT /api/admin/package-series/{id}
   * @param id 系列ID
   * @param data 套餐系列数据
   */
  static updatePackageSeries(
    id: number,
    data: UpdatePackageSeriesRequest
  ): Promise<BaseResponse<PackageSeriesResponse>> {
    return this.update<PackageSeriesResponse>(`/api/admin/package-series/${id}`, data)
  }

  /**
   * 删除套餐系列
   * DELETE /api/admin/package-series/{id}
   * @param id 系列ID
   */
  static deletePackageSeries(id: number): Promise<BaseResponse> {
    return this.remove(`/api/admin/package-series/${id}`)
  }

  /**
   * 更新套餐系列状态
   * PUT /api/admin/package-series/{id}/status
   * @param id 系列ID
   * @param status 状态 (1:启用, 2:禁用)
   */
  static updatePackageSeriesStatus(id: number, status: number): Promise<BaseResponse> {
    const data: UpdatePackageSeriesStatusRequest = { status }
    return this.patch<BaseResponse>(`/api/admin/package-series/${id}/status`, data)
  }
}
