import BasicService from './BasicService';
import config from '@/config';

/**
 * @desc 菜单服务接口
 */
class MenuService extends BasicService {
  constructor() {
    super();
  }

  getAccountMenu = async () => {
    return this.get(`/gateway/idm/api/menus`)
    // return new Promise((resolve, reject)=>{
    //
    // })
    // return this.get(
    //   `/gateway/idm/api/account/menus/${config.get('/app/code')}`,
    // );
  };

  /**
   * 获取所有菜单信息
   */
  query = async (searchKey?: string) => {
    return this.get(`/gateway/idm/api/menus?searchKey=${searchKey}`);
  };

  queryByAppId = async (appId: string) => {
    return this.get(`/gateway/idm/api/menus/${appId}/menu`);
  };

  /**
   * 获取菜单信息
   */
  getById = async (id: string) => {
    return this.get(`/gateway/idm/api/menus/${id}`);
  };

  /**
   * 获取菜单信息
   */
  getChild = async (id: string) => {
    return this.get(`/gateway/idm/api/menus/${id}/children`);
  };
}

const menuService = new MenuService();

export default menuService;
