// @ts-ignore
/* eslint-disable */
import {request} from 'umi';

export async function institutionUserList(params: API.UserListParams) {
  return request<API.Response<API.Page<API.UserList>>>('/api/v1/user/institutionList', {
    method: 'POST',
    data: params,
  });
}

export async function platformUserList(params: API.UserListParams) {
  return request<API.Response<API.Page<API.UserList>>>('/api/v1/user/platformList', {
    method: 'POST',
    data: params,
  });
}

export async function add(params: API.AddUserParams) {
  return request<API.Response<API.Page<API.UserList>>>('/api/v1/user/add', {
    method: 'POST',
    data: params,
    skipErrorHandler: true
  });
}

export async function batchAdd(params: { institutionId: number, file: any }) {
  let fileData = new FormData();
  fileData.append('file', params.file);
  fileData.append('institutionId', params.institutionId.toString());
  return request<API.Response<API.BatchResult<string>>>('/api/v1/user/batchAdd', {
    headers: {},
    method: 'POST',
    requestType: 'form',
    data: fileData,
  });
}

export async function update(params: API.UpdateUserParams) {
  return request<API.Response<any>>('/api/v1/user/update', {
    method: 'POST',
    data: params,
  });
}

export async function updateSelf(params: API.UpdateUserParams) {
  return request<API.Response<any>>('/api/v1/user/updateSelf', {
    method: 'POST',
    data: params,
  });
}

export async function deleteUser(userId: number) {
  return request<API.Response<any>>('/api/v1/user/delete', {
    method: 'POST',
    data: {userId,}
  });
}

export async function stopUser(userId: number) {
  return request<API.Response<any>>('/api/v1/user/stop', {
    method: 'POST',
    data: {userId,}
  });
}

export async function restartUser(userId: number) {
  return request<API.Response<any>>('/api/v1/user/restart', {
    method: 'POST',
    data: {userId,}
  });
}

export async function changePassword(oldPassword: string, newPassword: string) {
  return request<API.Response<any>>('/api/v1/user/changePassword', {
    method: 'POST',
    data: {oldPassword, newPassword}
  });
}

export async function resetPassword(userId: number) {
  return request<API.Response<any>>('/api/v1/user/resetPassword', {
    method: 'POST',
    data: {userId,}
  });
}


