import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {
  SchoolList,
  GradeList,
  GradeItem,
  StudentList,
  TeacherList,
  TeacherEquipment,
} from "./types";

/**
 * 获取学校列表
 */
export function getSchoolSelect(): AxiosPromise<SchoolList[]> {
  return request({
    url: "/board/v1/schools",
    method: "get",
  });
}
/**
 * 获取班级列表（班级select下拉列表）
 */
export function getGradeSelect(id: number): AxiosPromise<GradeList[]> {
  return request({
    url: "/board/v1/choose-grade",
    method: "get",
    params: { school_id: id },
  });
}
/**
 * 班级管理
 * status: 0全部1未结课2已结课
 */
export function getGradeList(
  id: number,
  status: number
): AxiosPromise<GradeItem[]> {
  return request({
    url: "/board/v1/grade",
    method: "get",
    params: { school_id: id, status: status },
  });
}
/**
 * 班级管理-学生列表
 */
export function getGradeStudents(id: number): AxiosPromise<StudentList[]> {
  return request({
    url: "/board/v1/students",
    method: "get",
    params: { grade_id: id },
  });
}
/**
 * 获取教师列表
 */
export function getTeacherList(
  id: number,
  keyword: string
): AxiosPromise<TeacherList[]> {
  return request({
    url: "/board/v1/teacher",
    method: "get",
    params: { school_id: id, search: keyword },
  });
}
/**
 * 获取教师设备
 */
export function getTeacherEquipment(
  id: number
): AxiosPromise<TeacherEquipment> {
  return request({
    url: "/board/v1/teacher-equipment",
    method: "get",
    params: { teacher_id: id },
  });
}
/**
 * 获取教师班级
 */
export function getTeacherGrade(id: number): AxiosPromise<GradeList[]> {
  return request({
    url: "/board/v1/teacher-class",
    method: "get",
    params: { teacher_id: id },
  });
}
