refactor: 重命名方法名称
This commit is contained in:
parent
e5c072f891
commit
3bed951046
|
@ -30,7 +30,7 @@ namespace Bootstrap.Admin.Controllers
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IEnumerable<string> RetrieveRolesByUrl([FromBody]string url)
|
public IEnumerable<string> RetrieveRolesByUrl([FromBody]string url)
|
||||||
{
|
{
|
||||||
return RoleHelper.RetrieveRolesByUrl(url);
|
return RoleHelper.RetrievesByUrl(url);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
@ -39,7 +39,7 @@ namespace Bootstrap.Admin.Controllers
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IEnumerable<string> RetrieveRolesByUserName([FromBody]string userName)
|
public IEnumerable<string> RetrieveRolesByUserName([FromBody]string userName)
|
||||||
{
|
{
|
||||||
return RoleHelper.RetrieveRolesByUserName(userName);
|
return RoleHelper.RetrievesByUserName(userName);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|
|
@ -121,7 +121,7 @@ namespace Bootstrap.Admin
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
app.UseResponseCompression();
|
app.UseResponseCompression();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseBootstrapAdminAuthentication(RoleHelper.RetrieveRolesByUserName, RoleHelper.RetrieveRolesByUrl, AppHelper.RetrievesByUserName);
|
app.UseBootstrapAdminAuthentication(RoleHelper.RetrievesByUserName, RoleHelper.RetrievesByUrl, AppHelper.RetrievesByUserName);
|
||||||
app.UseOnlineUsers(callback: TraceHelper.Save);
|
app.UseOnlineUsers(callback: TraceHelper.Save);
|
||||||
app.UseCacheManagerCorsHandler();
|
app.UseCacheManagerCorsHandler();
|
||||||
app.UseSignalR(routes => { routes.MapHub<SignalRHub>("/NotiHub"); });
|
app.UseSignalR(routes => { routes.MapHub<SignalRHub>("/NotiHub"); });
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace Bootstrap.DataAccess.MongoDB
|
||||||
public override IEnumerable<string> RetrievesByUserName(string userName)
|
public override IEnumerable<string> RetrievesByUserName(string userName)
|
||||||
{
|
{
|
||||||
var ret = new List<string>();
|
var ret = new List<string>();
|
||||||
var roles = RoleHelper.RetrieveRolesByUserName(userName);
|
var roles = RoleHelper.RetrievesByUserName(userName);
|
||||||
if (roles.Contains("Administrators", StringComparer.OrdinalIgnoreCase))
|
if (roles.Contains("Administrators", StringComparer.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
ret.AddRange(DictHelper.RetrieveApps().Select(kv => kv.Key));
|
ret.AddRange(DictHelper.RetrieveApps().Select(kv => kv.Key));
|
||||||
|
|
|
@ -75,7 +75,7 @@ namespace Bootstrap.DataAccess.MongoDB
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userName"></param>
|
/// <param name="userName"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override IEnumerable<string> RetrieveRolesByUserName(string userName)
|
public override IEnumerable<string> RetrievesByUserName(string userName)
|
||||||
{
|
{
|
||||||
var roles = new List<string>();
|
var roles = new List<string>();
|
||||||
var user = UserHelper.Retrieves().Cast<User>().FirstOrDefault(u => u.UserName.ToLowerInvariant() == userName.ToLowerInvariant());
|
var user = UserHelper.Retrieves().Cast<User>().FirstOrDefault(u => u.UserName.ToLowerInvariant() == userName.ToLowerInvariant());
|
||||||
|
@ -185,7 +185,7 @@ namespace Bootstrap.DataAccess.MongoDB
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="url"></param>
|
/// <param name="url"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override IEnumerable<string> RetrieveRolesByUrl(string url)
|
public override IEnumerable<string> RetrievesByUrl(string url)
|
||||||
{
|
{
|
||||||
var menu = DbManager.Menus.Find(md => md.Url.StartsWith(url)).FirstOrDefault();
|
var menu = DbManager.Menus.Find(md => md.Url.StartsWith(url)).FirstOrDefault();
|
||||||
var ret = RoleHelper.Retrieves().Cast<Role>().Where(md => md.Menus != null && md.Menus.Contains(menu.Id)).Select(m => m.RoleName).ToList();
|
var ret = RoleHelper.Retrieves().Cast<Role>().Where(md => md.Menus != null && md.Menus.Contains(menu.Id)).Select(m => m.RoleName).ToList();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Longbow.Cache;
|
using Longbow.Cache;
|
||||||
using Longbow.Data;
|
using Longbow.Data;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -119,13 +119,13 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userName"></param>
|
/// <param name="userName"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IEnumerable<string> RetrieveRolesByUserName(string userName) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveRolesByUserNameDataKey, userName), key => DbContextManager.Create<Role>().RetrieveRolesByUserName(userName), RetrieveRolesByUserNameDataKey);
|
public static IEnumerable<string> RetrievesByUserName(string userName) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveRolesByUserNameDataKey, userName), key => DbContextManager.Create<Role>().RetrievesByUserName(userName), RetrieveRolesByUserNameDataKey);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="url"></param>
|
/// <param name="url"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IEnumerable<string> RetrieveRolesByUrl(string url) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveRolesByUrlDataKey, url), key => DbContextManager.Create<Role>().RetrieveRolesByUrl(url), RetrieveRolesByUrlDataKey);
|
public static IEnumerable<string> RetrievesByUrl(string url) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveRolesByUrlDataKey, url), key => DbContextManager.Create<Role>().RetrievesByUrl(url), RetrieveRolesByUrlDataKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -187,7 +187,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userName"></param>
|
/// <param name="userName"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual IEnumerable<string> RetrieveRolesByUserName(string userName) => DbHelper.RetrieveRolesByUserName(userName);
|
public virtual IEnumerable<string> RetrievesByUserName(string userName) => DbHelper.RetrieveRolesByUserName(userName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据菜单url查询某个所拥有的角色
|
/// 根据菜单url查询某个所拥有的角色
|
||||||
|
@ -195,6 +195,6 @@ namespace Bootstrap.DataAccess
|
||||||
/// 从Navigators-〉GroupNavigatorRole-〉Role查查询某个用户所拥有的角色
|
/// 从Navigators-〉GroupNavigatorRole-〉Role查查询某个用户所拥有的角色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual IEnumerable<string> RetrieveRolesByUrl(string url) => DbHelper.RetrieveRolesByUrl(url);
|
public virtual IEnumerable<string> RetrievesByUrl(string url) => DbHelper.RetrieveRolesByUrl(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,13 +80,13 @@ namespace Bootstrap.DataAccess.SqlServer
|
||||||
{
|
{
|
||||||
var id = RoleHelper.Retrieves().FirstOrDefault(r => r.RoleName == "Administrators").Id;
|
var id = RoleHelper.Retrieves().FirstOrDefault(r => r.RoleName == "Administrators").Id;
|
||||||
UserHelper.SaveByRoleId(id, UserHelper.Retrieves().Select(u => u.Id));
|
UserHelper.SaveByRoleId(id, UserHelper.Retrieves().Select(u => u.Id));
|
||||||
Assert.NotEmpty(RoleHelper.RetrieveRolesByUserName("Admin"));
|
Assert.NotEmpty(RoleHelper.RetrievesByUserName("Admin"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void RetrieveRolesByUrl_Ok()
|
public void RetrieveRolesByUrl_Ok()
|
||||||
{
|
{
|
||||||
Assert.NotEmpty(RoleHelper.RetrieveRolesByUrl("~/Home/Index"));
|
Assert.NotEmpty(RoleHelper.RetrievesByUrl("~/Home/Index"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
Loading…
Reference in New Issue