import { Login } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import authMenuList from "@/assets/json/authMenuList.json";
import authButtonList from "@/assets/json/authButtonList.json";
import http from "@/api";
import type { Menu } from "@/typings/global";

// 获取菜单列表
export const getAuthMenuListApi = () => {
  return http.get<Menu.MenuOptions[]>(PORT1 + `/menu/list`, {});
  // 如果想让菜单变为本地数据，注释上一行代码，并引入本地 authMenuList.json 数据
  // return authMenuList;
};

// // 获取按钮权限
// export const getAuthButtonListApi = () => {
//   return http.get<Login.ResAuthButtons>(PORT1 + `/auth/buttons`, {});
//   // 如果想让按钮权限变为本地数据，注释上一行代码，并引入本地 authButtonList.json 数据
//   // return authButtonList;
// };

// 用户退出登录
export const logoutApi = () => {
  return http.post(PORT1 + `/logout`, {});
};

/**
 *  @name 获取账套信息
 */
export const getTokenApi = () => {
  return http.postOri<Login.ResToken>(PORT1 + `/GetToken`);
};

/**
 * @name 登录模块
 */
export const loginApi = (params: Login.ReqLoginForm) => {
  return http.post<Login.ResLogin>(PORT1 + `/Login`, params); // 正常 post json 请求  ==>  application/json
};

/**
 * @name 基础信息模块
 */
export const getL1APPUserInfoApi = (params: Login.ReqL1APPUserInfo) => {
  return http.post<Login.ResL1APPUserInfo>(PORT1 + `/GetUserInfo`, params); // 正常 post json 请求  ==>  application/json
};
