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

interface HourHistorys {
  course: Curriculum
  data: Record<number, HourHistory[]>
  hour: Hour
}

export interface CourseAllParam {
  page: number
  page_size: number
  title?: string
  dep_id: number
}

export const courseApi = {
  /** 课时学习记录 */
  hourHistory(courseId: string, hourId: string) {
    return request<HourHistorys>(`/api/v1/course/${courseId}/hour/${hourId}/info`, "GET", {})
  },
  /** 获取部门课程 */
  getCourseAll(data: CourseAllParam) {
    return request<{ data: Curriculum[], total: number }>('/api/v1/course/all/company', "GET", data)
  },
  /** 删除公司课程 */
  delCourse(course_id: number) {
    return request(`/api/v1/course/del/${course_id}`, "DELETE")
  },
  /**
   * 类型查询课程
   */
  courseType(type: string, data: Pages) {
    return request<{ data: Curriculum[], total: number }>(`/api/v1/course/course/info/type/${type}`, 'GET', data)
  }
}
