import { requestClient } from './request';

interface ChangeLanguagePayload {
  langId: 0 | 1;
}

export interface curUserInfoPayload {
  account: string;
  avatarFileId: string;
  cellPhone: string;
  employeeNumber: string;
  enterpriseName: string;
  id: string;
  isLoginToB: boolean;
  isOut: number;
  isSuperAdmin: boolean;
  langName: string;
  language: string;
  name: string;
  nickName: string;
  telephone: string;
  avatar?: string;
}

interface CurUserInfoResponse {
  code: number;
  isAuthorized: boolean;
  isSuccess: boolean;
  result: curUserInfoPayload;
}
interface Ts {
  value: string;
}
interface SubMenuList {
  bindLink: boolean;
  code: string;
  deleted: boolean;
  enableApply: boolean;
  enableMobile: boolean;
  fullName: string;
  fullPath: string;
  icon: string;
  iconClass: string;
  iconColor?: string;
  id: string;
  isBindLink: boolean;
  isDeleted: boolean;
  isFavourite: boolean;
  isManuallyCreate: boolean;
  langName: string;
  languageCulture: string;
  link: string;
  linkType: number;
  manuallyCreate: boolean;
  menuDepth: number;
  menuIndex: number;
  menuType: number;
  name: string;
  openType: number;
  parentId: string;
  subMenuList: any[];
  target: string;
  ts: Ts;
  remark?: string;
}
interface SubMenuList2 {
  bindLink: boolean;
  code: string;
  deleted: boolean;
  enableApply: boolean;
  enableMobile: boolean;
  fullName: string;
  fullPath: string;
  icon: string;
  iconClass: string;
  iconColor: string;
  id: string;
  isBindLink: boolean;
  isDeleted: boolean;
  isFavourite: boolean;
  isManuallyCreate: boolean;
  langName: string;
  languageCulture: string;
  link: string;
  linkType: number;
  manuallyCreate: boolean;
  menuDepth: number;
  menuIndex: number;
  menuType: number;
  name: string;
  openType: number;
  parentId: string;
  subMenuList: SubMenuList[];
  target: string;
  ts: Ts;
}

interface leftMenuResult {
  bindLink: boolean;
  code: string;
  deleted: boolean;
  enableApply: boolean;
  enableMobile: boolean;
  fullName: string;
  fullPath: string;
  icon: string;
  iconClass: string;
  iconColor: string;
  id: string;
  isBindLink: boolean;
  isDeleted: boolean;
  isFavourite: boolean;
  isManuallyCreate: boolean;
  langName: string;
  languageCulture: string;
  link: string;
  linkType: number;
  manuallyCreate: boolean;
  menuDepth: number;
  menuIndex: number;
  menuType: number;
  name: string;
  openType: number;
  parentId: string;
  remark: string;
  subMenuList: SubMenuList2[];
  target: string;
  ts: Ts;
}
interface leftMenuResponse {
  isSuccess: boolean;
  code: number;
  result: leftMenuResult;
  isAuthorized: boolean;
}

// 切换语言接口
export async function changeLanguageApi(payload: ChangeLanguagePayload) {
  return requestClient.post('/api/account/v2/doChangeLanguage', payload);
}

// 获取当前用户信息接口
export async function curUserInfo() {
  return requestClient.get<CurUserInfoResponse>('/api/account/curUserInfo');
}

// 获取左侧菜单列表接口
export async function leftMenuListFromB() {
  return requestClient.get<leftMenuResponse>('/api/menu/leftMenuListFromB');
}
