重构代码:删除BAHelper静态类,使用Bootstrap.Security类方法

This commit is contained in:
Argo-MacBookPro 2018-10-23 20:54:46 +08:00
parent 8f5ee8b373
commit e66f5e0fdf
2 changed files with 2 additions and 51 deletions

View File

@ -1,50 +0,0 @@
using Bootstrap.Security;
using Longbow;
using Longbow.Configuration;
using System;
using System.Collections.Generic;
using System.Net.Http;
namespace Bootstrap.Client.DataAccess
{
internal static class BAHelper
{
private readonly static LgbHttpClient _client = new LgbHttpClient(new HttpClient() { BaseAddress = new Uri($"{ConfigurationManager.AppSettings["AuthHost"]}/api/Interface/") });
private static T ExecuteRemoteAction<T>(string actionName, object data = null)
{
var task = _client.PostAsJsonAsync<T>(actionName, data);
task.Wait();
return task.Result;
}
/// <summary>
///
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
public static IEnumerable<BootstrapMenu> RetrieveAppMenus(object args) => ExecuteRemoteAction<IEnumerable<BootstrapMenu>>("RetrieveAppMenus", args);
/// <summary>
///
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public static IEnumerable<string> RetrieveRolesByUrl(string url) => ExecuteRemoteAction<IEnumerable<string>>("RetrieveRolesByUrl", url);
/// <summary>
///
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
public static IEnumerable<string> RetrieveRolesByUserName(string userName) => ExecuteRemoteAction<IEnumerable<string>>("RetrieveRolesByUserName", userName);
/// <summary>
///
/// </summary>
/// <returns></returns>
public static IEnumerable<BootstrapDict> RetrieveDicts() => ExecuteRemoteAction<IEnumerable<BootstrapDict>>("RetrieveDicts");
/// <summary>
///
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
public static BootstrapUser RetrieveUserByUserName(string userName) => ExecuteRemoteAction<BootstrapUser>("RetrieveUserByUserName", userName);
}
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using Bootstrap.Security;
using System.Collections.Generic;
namespace Bootstrap.Client.DataAccess
{