import { http } from "./index";

// ==================== 课程包管理 ====================

/**
 * 课程包（已移除商业字段，如 price, status 等）
 * 注意：商业字段已移至 ProductBundle
 */
export interface CoursePackage {
  id: string;
  name: string;
  description?: string;
  coverUrl?: string;
  courseCount: number;
  isSystem: number;
  createdAt: string;
  updatedAt: string;
  packageCourses?: PackageCourse[];
}

/**
 * 课程包 - 课程关联
 */
export interface PackageCourse {
  id: string;
  coursePackageId: string;
  courseId: string;
  sortOrder: number;
  course?: {
    id: string;
    name: string;
    coverImagePath?: string;
    duration?: number;
    gradeTags?: string;
  };
}

export interface PackageListParams {
  page?: number;
  pageSize?: number;
  keyword?: string;
}

export interface CreatePackageData {
  name: string;
  description?: string;
  coverUrl?: string;
}

export interface UpdatePackageData {
  name?: string;
  description?: string;
  coverUrl?: string;
}

// 获取课程包列表（通用）
export function getPackages(params: PackageListParams) {
  return http.get("/api/v1/admin/packages", { params });
}

// ==================== 学校端课程包 ====================

// 获取学校已授权课程包
export function getTenantPackages() {
  return http.get("/api/v1/school/packages");
}
