import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StudentForm, StudentQuery, StudentVO } from './types';

// 查询学生列表
export function listStudent(query: StudentQuery): AxiosPromise<StudentVO[]> {
  return request({
    url: '/edu/student/list',
    method: 'get',
    params: query
  });
}

// 查询学生详细(含家长、紧急联系人)
export function getStudent(id: number | string): AxiosPromise<StudentVO> {
  return request({
    url: '/edu/student/' + id,
    method: 'get'
  });
}

// 新增学生
export function addStudent(data: StudentForm) {
  return request({
    url: '/edu/student',
    method: 'post',
    data: data
  });
}

// 修改学生
export function updateStudent(data: StudentForm) {
  return request({
    url: '/edu/student',
    method: 'put',
    data: data
  });
}

// 删除学生
export function delStudent(id: string | number | (string | number)[]) {
  return request({
    url: '/edu/student/' + id,
    method: 'delete'
  });
}
