2018-10-28 21:05:22 +08:00
|
|
|
|
using Bootstrap.Security.SQLServer;
|
|
|
|
|
using Longbow.Cache;
|
2018-10-23 20:54:46 +08:00
|
|
|
|
using System.Collections.Generic;
|
2018-10-19 23:09:52 +08:00
|
|
|
|
|
|
|
|
|
namespace Bootstrap.Client.DataAccess
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class RoleHelper
|
|
|
|
|
{
|
2018-10-28 21:05:22 +08:00
|
|
|
|
public const string RetrieveRolesByUserNameDataKey = "BootstrapRole-RetrieveRolesByUserName";
|
|
|
|
|
public const string RetrieveRolesByUrlDataKey = "BootstrapRole-RetrieveRolesByUrl";
|
2018-10-19 23:09:52 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="userName"></param>
|
|
|
|
|
/// <returns></returns>
|
2018-10-28 21:05:22 +08:00
|
|
|
|
public static IEnumerable<string> RetrieveRolesByUserName(string userName) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveRolesByUserNameDataKey, userName), key => BASQLHelper.RetrieveRolesByUserName(userName), RetrieveRolesByUserNameDataKey);
|
2018-10-19 23:09:52 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="url"></param>
|
|
|
|
|
/// <returns></returns>
|
2018-10-28 21:05:22 +08:00
|
|
|
|
public static IEnumerable<string> RetrieveRolesByUrl(string url) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveRolesByUrlDataKey, url), key => BASQLHelper.RetrieveRolesByUrl(url), RetrieveRolesByUrlDataKey);
|
2018-10-19 23:09:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|