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

/**
 * 查询学员简历与个人信息总表列表
 * @param query
 * @returns {*}
 */
export const listStudent = (query: StudentQuery): AxiosPromise<StudentVO[]> => {
  return request({
    url: '/main/student/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询学员简历与个人信息总表详细
 * @param id
 * @returns {*}
 */
export const getStudent = (id: string | number): AxiosPromise<StudentVO> => {
  return request({
    url: '/main/student/' + id,
    method: 'get'
  });
};

/**
 * 新增学员简历与个人信息总表
 * @param data
 * @returns {*}
 */
export const addStudent = (data: StudentForm) => {
  return request({
    url: '/main/student',
    method: 'post',
    data: data
  });
};

/**
 * 修改学员简历与个人信息总表
 * @param data
 * @returns {*}
 */
export const updateStudent = (data: StudentForm) => {
  return request({
    url: '/main/student',
    method: 'put',
    data: data
  });
};

/**
 * 删除学员简历与个人信息总表
 * @param id
 * @returns {*}
 */
export const delStudent = (id: string | number | Array<string | number>) => {
  return request({
    url: '/main/student/' + id,
    method: 'delete'
  });
};

/**
 * 更新学员用户类型（黑名单管理）
 * @param id
 * @param userType
 */
export const updateUserType = (id: string | number, userType: string) => {
  return request({
    url: '/main/student/updateUserType',
    method: 'put',
    data: { id, userType }
  });
};

/**
 * 更新学员状态
 * @param id
 * @param status
 */
export const updateStatus = (id: string | number, status: string) => {
  return request({
    url: '/main/student/updateStatus',
    method: 'put',
    data: { id, status }
  });
};
