import {request} from "@/api/request";

export interface Category {
  id: number
  name: string
  parent_chain: string
  parent_id: number
  sort: number
  resource_category?: Category[]
}

interface CategoryList {
  categories: Record<number, Category[]>
}

export interface CoursesMode {
  articles: any[]
  audit_mode: boolean
  course: Courses
}

export interface Courses {

  /** 选秀 */
  is_not_required: Curriculum[]
  /** 必修 */
  is_required: Curriculum[]
  /** 总时长 */
  total_course_duration?: number
}

export type CoursesKey = keyof Omit<Courses, 'total_course_duration'>


export const publicApi = {
  /** 分类 */
  category() {
    return request<CategoryList>('/api/v1/category/all', "GET")
  },
  /** 课程 */
  course(data: { page: number, pageSize: number }) {
    return request<CoursesMode>('/api/v1/category/course/index', "GET", data)
  }
}
