BootstrapAdmin/Bootstrap.Client.DataAccess/RoleHelper.cs

27 lines
1.1 KiB
C#
Raw Normal View History

using Bootstrap.Security.DataAccess;
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 = "RoleHelper-RetrieveRolesByUserName";
public const string RetrieveRolesByUrlDataKey = "RoleHelper-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 => DbHelper.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 => DbHelper.RetrieveRolesByUrl(url), RetrieveRolesByUrlDataKey);
2018-10-19 23:09:52 +08:00
}
}