重构代码:删除BAHelper静态类,使用Bootstrap.Security类方法
This commit is contained in:
parent
8f5ee8b373
commit
e66f5e0fdf
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using Bootstrap.Security;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Bootstrap.Client.DataAccess
|
namespace Bootstrap.Client.DataAccess
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue