import request from '@/framework/utils/request';
import { AxiosPromise } from 'axios';
import { UserInfo } from './types';

function replaceAcasService(url){
  if(publicData.replaceAcasService){
    return url.replace('/acas/','/'+publicData.replaceAcasService+'/')
  }
  return url
}



/**
 * 获取路由列表
 */
export function listRoutes(params: any = {}) {
  return request({
    url: replaceAcasService('/acas/user/allowAccessMenuAndModules'),
    method: 'get',
    params
  });
}


/**获取key */
export function getKey(params: any = {}) {
  return request({
    url:replaceAcasService('/acas/pk'),
    method: 'get',
    params,
  });
}


/**刷新*/
export function baseRefresh(url:string,data: any = {}) {
  return request({
    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
    url:replaceAcasService(url),
    method: 'post',
    data,
  });
}

/**退出登录 */
export function baseLogout(url:string,data: any = {}) {
  return request({
    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
    url:replaceAcasService(url),
    method: 'post',
    data,
  });
}

/**登录后修改密码 */
export function baseLoginUpdatePwd(url:string,data: any = {}) {
  return request({
    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
    url:replaceAcasService(url),
    method: 'post',
    data,
  });
}


/**获取key */
export function getEmployee(params: any = {}) {
  return request({
    url:replaceAcasService('/acas/employee/getEmployee'),
    method: 'get',
    params,
  });
}


/**获取员工管理业务域*/
export function getBusinessDomain(params: any = {}) {
  return request({
    url: replaceAcasService('/acas/user/loginUserdomain'),
    method: 'get',
    params
  });
}

/**获取有权限的子系统*/
export function getAllowAccessSubsystem(params: any = {}) {
  return request({
    url: replaceAcasService('/acas/user/allowAccessSubsystem'),
    method: 'get',
    params
  });
}

/**获取员工信息 */
export function getUsermessage(params: any = {}) {
  if (import.meta.env.MODE === 'development'){
    return new Promise((resolve) => {
      resolve({"user":{"tenantId":"0000","tenantName":"奥博克","userId":"0","userName":"系统管理员","deptId":"01","deptName":"开发部","avatarUrl":""}});
    });
  }else{
    return request({
      url:'/acas/user/message',
      method: 'get',
      params,
    });
  }
  
}



