BootstrapAdmin11/Bootstrap.Client.DataAccess/RoleHelper.cs

27 lines
1.1 KiB
C#
Raw Normal View History

using Bootstrap.Security.SQLServer;
using Longbow.Cache;
using System.Collections.Generic;
2018-10-19 23:09:52 +08:00
namespace Bootstrap.Client.DataAccess
{
/// <summary>
///
/// </summary>
public static class RoleHelper
{
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>
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>
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
}
}