import { http } from '@/utils/http/axios';
import { ApiEnum } from '@/enums/apiEnum';

export interface BasicResponseModel<T = any> {
  code: number;
  msg: string;
  data: T;
}

export interface BasicPageParams {
  pageNumber: number;
  pageSize: number;
  total: number;
}

export function getUserInfo() {
  return http.request({
    url: ApiEnum.MemberInfo,
    method: 'get',
  });
}

export function getConfig() {
  return http.request({
    url: '/gm/config',
    method: 'get',
  });
}

export function login(params) {
  return http.request<BasicResponseModel>(
    {
      url: ApiEnum.SiteLogin,
      method: 'POST',
      params,
    },
    {
      isTransformResponse: false,
    }
  );
}

export function changePassword(params, uid) {
  return http.request(
    {
      url: `/user/u${uid}/changepw`,
      method: 'POST',
      params,
    },
    {
      isTransformResponse: false,
    }
  );
}

export function logout(params) {
  return http.request({
    url: '/login/logout',
    method: 'POST',
    params,
  });
}

export function feiShuUserLogin(params) {
  return http.request<BasicResponseModel>(
    {
      url: ApiEnum.FeiShuUserLogin,
      method: 'GET',
      params,
    },
    {
      isTransformResponse: false,
    }
  );
}
