import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StaffForm, StaffQuery, StaffVO, StaffAssignForm } from './types';

// 查询员工列表
export function listStaff(query: StaffQuery): AxiosPromise<StaffVO[]> {
  return request({
    url: '/edu/staff/list',
    method: 'get',
    params: query
  });
}

// 查询员工详细
export function getStaff(id: number | string): AxiosPromise<StaffVO> {
  return request({
    url: '/edu/staff/' + id,
    method: 'get'
  });
}

// 新增员工
export function addStaff(data: StaffForm) {
  return request({
    url: '/edu/staff',
    method: 'post',
    data: data
  });
}

// 修改员工
export function updateStaff(data: StaffForm) {
  return request({
    url: '/edu/staff',
    method: 'put',
    data: data
  });
}

// 删除员工
export function delStaff(id: string | number | (string | number)[]) {
  return request({
    url: '/edu/staff/' + id,
    method: 'delete'
  });
}

// 按角色查询在职员工下拉
export function staffOptionselect(role?: string): AxiosPromise<StaffVO[]> {
  return request({
    url: '/edu/staff/optionselect',
    method: 'get',
    params: { role }
  });
}

// 查询某学生的服务员工
export function listStaffByStudent(studentId: number | string): AxiosPromise<StaffVO[]> {
  return request({
    url: '/edu/staff/byStudent/' + studentId,
    method: 'get'
  });
}

// 给员工分配学生
export function assignStudents(data: StaffAssignForm) {
  return request({
    url: '/edu/staff/assign',
    method: 'post',
    data: data
  });
}
