Merge branch 'dev'
This commit is contained in:
commit
c3d455074b
|
@ -12,8 +12,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.9" />
|
||||
<PackageReference Include="Longbow.Configuration" Version="2.2.3" />
|
||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.10" />
|
||||
<PackageReference Include="Longbow.Configuration" Version="2.2.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.7.10" />
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
],
|
||||
"SwaggerPathBase": "/BA",
|
||||
"AllowOrigins": "http://localhost,http://argo.zylweb.cn",
|
||||
"Sentry" : {
|
||||
"Sentry": {
|
||||
"Dsn": "https://70bdfff562e84fa7b9a43d65924ab9ad@sentry.io/1469396"
|
||||
},
|
||||
"LongbowCache": {
|
||||
|
@ -87,6 +87,13 @@
|
|||
"SlidingExpiration": true,
|
||||
"Desc": "通过菜单获得角色数据"
|
||||
},
|
||||
{
|
||||
"Enabled": true,
|
||||
"Key": "AppHelper-RetrieveAppsByUserName",
|
||||
"Interval": 600000,
|
||||
"SlidingExpiration": true,
|
||||
"Desc": "指定用户授权应用数据缓存"
|
||||
},
|
||||
{
|
||||
"Enabled": true,
|
||||
"Key": "BootstrapUser-RetrieveUsersByName",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.5" />
|
||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.6" />
|
||||
<PackageReference Include="Longbow.Cache" Version="2.2.12" />
|
||||
<PackageReference Include="Longbow.Data" Version="2.3.2" />
|
||||
<PackageReference Include="Longbow.Web" Version="2.2.14" />
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
using Bootstrap.Security;
|
||||
using Bootstrap.Security.DataAccess;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Bootstrap.Security.DataAccess;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bootstrap.Client.DataAccess
|
||||
|
@ -13,89 +8,10 @@ namespace Bootstrap.Client.DataAccess
|
|||
/// </summary>
|
||||
public static class DictHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 缓存索引,BootstrapAdmin后台清理缓存时使用
|
||||
/// </summary>
|
||||
private const string RetrieveDictsDataKey = "BootstrapDict-RetrieveDicts";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string RetrieveProfilesUrl()
|
||||
{
|
||||
return RetrieveAppName("个人中心地址");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string RetrieveSettingsUrl()
|
||||
{
|
||||
return RetrieveAppName("系统设置地址");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string RetrieveNotisUrl()
|
||||
{
|
||||
return RetrieveAppName("系统通知地址");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string RetrieveTitle()
|
||||
{
|
||||
return RetrieveAppName("网站标题");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string RetrieveFooter()
|
||||
{
|
||||
return RetrieveAppName("网站页脚");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static IEnumerable<BootstrapDict> RetrieveDicts() => CacheManager.GetOrAdd(RetrieveDictsDataKey, key => DbHelper.RetrieveDicts());
|
||||
|
||||
private static string RetrieveAppName(string name, string defaultValue = "未设置")
|
||||
{
|
||||
var dicts = RetrieveDicts();
|
||||
var platName = dicts.FirstOrDefault(d => d.Category == "应用程序" && d.Code == ConfigurationManager.AppSettings["AppId"])?.Name;
|
||||
return dicts.FirstOrDefault(d => d.Category == platName && d.Name == name)?.Code ?? $"{name}{defaultValue}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得网站设置中的当前样式
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string RetrieveActiveTheme()
|
||||
{
|
||||
var theme = RetrieveDicts().Where(d => d.Name == "使用样式" && d.Category == "当前样式" && d.Define == 0).FirstOrDefault()?.Code;
|
||||
return theme == null ? string.Empty : theme.Equals("site.css", StringComparison.OrdinalIgnoreCase) ? string.Empty : theme;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取头像路径
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string RetrieveIconFolderPath() => (RetrieveDicts().FirstOrDefault(d => d.Name == "头像路径" && d.Category == "头像地址" && d.Define == 0) ?? new BootstrapDict() { Code = "~/images/uploader/" }).Code;
|
||||
|
||||
/// <summary>
|
||||
/// 获取验证码图床
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string RetrieveImagesLibUrl() => RetrieveDicts().FirstOrDefault(d => d.Name == "验证码图床" && d.Category == "系统设置" && d.Define == 0)?.Code ?? "http://images.sdgxgz.com/";
|
||||
public static string RetrieveImagesLibUrl() => DbHelper.RetrieveDictsWithCache().FirstOrDefault(d => d.Name == "验证码图床" && d.Category == "系统设置" && d.Define == 0)?.Code ?? "http://images.sdgxgz.com/";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
using Bootstrap.Security;
|
||||
using Bootstrap.Security.DataAccess;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bootstrap.Client.DataAccess
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class MenuHelper
|
||||
{
|
||||
private const string RetrieveMenusAll = "BootstrapMenu-RetrieveMenus";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="activeUrl"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<BootstrapMenu> RetrieveAppMenus(string userName, string activeUrl)
|
||||
{
|
||||
var menus = RetrieveAllMenus(userName).Where(m => m.Category == "1" && m.IsResource == 0 && m.Application == ConfigurationManager.AppSettings["AppId"]);
|
||||
return DbHelper.CascadeMenus(menus, activeUrl);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过用户获得所有菜单
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
private static IEnumerable<BootstrapMenu> RetrieveAllMenus(string userName) => CacheManager.GetOrAdd($"{RetrieveMenusAll}-{userName}", key => DbHelper.RetrieveAllMenus(userName), RetrieveMenusAll);
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
using Bootstrap.Security.DataAccess;
|
||||
using Longbow.Cache;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Bootstrap.Client.DataAccess
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class RoleHelper
|
||||
{
|
||||
private const string RetrieveRolesByUserNameDataKey = "RoleHelper-RetrieveRolesByUserName";
|
||||
private const string RetrieveRolesByUrlDataKey = "RoleHelper-RetrieveRolesByUrl";
|
||||
/// <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);
|
||||
/// <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);
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
using Bootstrap.Security;
|
||||
using Bootstrap.Security.DataAccess;
|
||||
using Longbow.Cache;
|
||||
|
||||
namespace Bootstrap.Client.DataAccess
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户表相关操作类
|
||||
/// </summary>
|
||||
public static class UserHelper
|
||||
{
|
||||
private const string RetrieveUsersByNameDataKey = "BootstrapUser-RetrieveUsersByName";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
public static BootstrapUser RetrieveUserByUserName(string userName) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveUsersByNameDataKey, userName), k => DbHelper.RetrieveUserByUserName(userName), RetrieveUsersByNameDataKey);
|
||||
}
|
||||
}
|
|
@ -7,8 +7,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.9" />
|
||||
<PackageReference Include="Longbow.Configuration" Version="2.2.3" />
|
||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.10" />
|
||||
<PackageReference Include="Longbow.Configuration" Version="2.2.4" />
|
||||
<PackageReference Include="Longbow.Logging" Version="2.2.8" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Bootstrap.Client.Models;
|
||||
using Longbow.Configuration;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
@ -32,11 +33,13 @@ namespace Bootstrap.Client.Controllers
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
public IActionResult Error(int id)
|
||||
{
|
||||
var uriBuilder = new UriBuilder(ConfigurationManager.AppSettings["AuthHost"]) { Query = QueryString.Create(CookieAuthenticationDefaults.ReturnUrlParameter, $"{Request.Scheme}://{Request.Host}{Request.PathBase}").ToString() };
|
||||
var options = ConfigurationManager.Get<BootstrapAdminOptions>();
|
||||
var uriBuilder = new UriBuilder(options.AuthHost) { Query = QueryString.Create(CookieAuthenticationDefaults.ReturnUrlParameter, $"{Request.Scheme}://{Request.Host}{Request.PathBase}").ToString() };
|
||||
uriBuilder.Path = uriBuilder.Path == "/" ? Request.Path.Value : uriBuilder.Path + Request.Path.Value;
|
||||
return Redirect(uriBuilder.ToString());
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Bootstrap.Client.DataAccess;
|
||||
using Bootstrap.Security.DataAccess;
|
||||
using Longbow.Configuration;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
|
@ -18,12 +18,12 @@ namespace Bootstrap.Client.Models
|
|||
/// <param name="identity"></param>
|
||||
public HeaderBarModel(IIdentity identity)
|
||||
{
|
||||
var user = UserHelper.RetrieveUserByUserName(identity.Name);
|
||||
var user = DbHelper.RetrieveUserByUserName(identity.Name);
|
||||
DisplayName = user.DisplayName;
|
||||
UserName = user.UserName;
|
||||
SettingsUrl = DictHelper.RetrieveSettingsUrl();
|
||||
ProfilesUrl = DictHelper.RetrieveProfilesUrl();
|
||||
NotisUrl = DictHelper.RetrieveNotisUrl();
|
||||
SettingsUrl = DbHelper.RetrieveSettingsUrl();
|
||||
ProfilesUrl = DbHelper.RetrieveProfilesUrl();
|
||||
NotisUrl = DbHelper.RetrieveNotisUrl();
|
||||
|
||||
// set LogoutUrl
|
||||
var authHost = ConfigurationManager.Get<BootstrapAdminOptions>().AuthHost;
|
||||
|
@ -32,7 +32,7 @@ namespace Bootstrap.Client.Models
|
|||
LogoutUrl = uriBuilder.ToString();
|
||||
|
||||
// set Icon
|
||||
var icon = $"/{DictHelper.RetrieveIconFolderPath().Trim('~', '/')}/{user.Icon}";
|
||||
var icon = $"/{DbHelper.RetrieveIconFolderPath().Trim('~', '/')}/{user.Icon}";
|
||||
Icon = $"{authHost.TrimEnd('/')}{icon}";
|
||||
if (!string.IsNullOrEmpty(user.Css)) Theme = user.Css;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Bootstrap.Client.DataAccess;
|
||||
using Bootstrap.Security.DataAccess;
|
||||
|
||||
namespace Bootstrap.Client.Models
|
||||
{
|
||||
|
@ -12,9 +13,9 @@ namespace Bootstrap.Client.Models
|
|||
/// </summary>
|
||||
public ModelBase()
|
||||
{
|
||||
Title = DictHelper.RetrieveTitle();
|
||||
Footer = DictHelper.RetrieveFooter();
|
||||
Theme = DictHelper.RetrieveActiveTheme();
|
||||
Title = DbHelper.RetrieveTitle();
|
||||
Footer = DbHelper.RetrieveFooter();
|
||||
Theme = DbHelper.RetrieveActiveTheme();
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -29,4 +30,4 @@ namespace Bootstrap.Client.Models
|
|||
/// </summary>
|
||||
public string Theme { get; protected set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Bootstrap.Client.DataAccess;
|
||||
using Bootstrap.Security;
|
||||
using Bootstrap.Security.DataAccess;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@ -16,7 +17,7 @@ namespace Bootstrap.Client.Models
|
|||
/// <param name="controller"></param>
|
||||
public NavigatorBarModel(ControllerBase controller) : base(controller.User.Identity)
|
||||
{
|
||||
Navigations = MenuHelper.RetrieveAppMenus(UserName, $"~/{controller.ControllerContext.ActionDescriptor.ControllerName}/{controller.ControllerContext.ActionDescriptor.ActionName}");
|
||||
Navigations = DbHelper.RetrieveAppCascadeMenus(UserName, $"~/{controller.ControllerContext.ActionDescriptor.ControllerName}/{controller.ControllerContext.ActionDescriptor.ActionName}");
|
||||
ImageLibUrl = DictHelper.RetrieveImagesLibUrl();
|
||||
}
|
||||
|
||||
|
@ -30,4 +31,4 @@ namespace Bootstrap.Client.Models
|
|||
/// </summary>
|
||||
public string ImageLibUrl { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
using Bootstrap.Client.DataAccess;
|
||||
using Bootstrap.Security.DataAccess;
|
||||
using Longbow.Configuration;
|
||||
using Longbow.Web;
|
||||
using Longbow.Web.SignalR;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
@ -11,6 +13,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Bootstrap.Client
|
||||
{
|
||||
|
@ -90,7 +93,20 @@ namespace Bootstrap.Client
|
|||
app.UseResponseCompression();
|
||||
app.UseStaticFiles();
|
||||
app.UseCookiePolicy();
|
||||
app.UseBootstrapAdminAuthentication(RoleHelper.RetrieveRolesByUserName, RoleHelper.RetrieveRolesByUrl, DbHelper.RetrieveAppsByUserName);
|
||||
#if DEBUG
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
var userName = ConfigurationManager.GetValue("SimulateUserName", string.Empty);
|
||||
if (!string.IsNullOrEmpty(userName))
|
||||
{
|
||||
var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
identity.AddClaim(new Claim(ClaimTypes.Name, userName));
|
||||
context.User = new ClaimsPrincipal(identity);
|
||||
}
|
||||
await next();
|
||||
});
|
||||
#endif
|
||||
app.UseBootstrapAdminAuthentication();
|
||||
app.UseCacheManagerCorsHandler();
|
||||
app.UseSignalR(routes => { routes.MapHub<SignalRHub>("/NotiHub"); });
|
||||
app.UseMvc(routes =>
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
}
|
||||
}
|
||||
],
|
||||
"SimulateUserName": "Admin",
|
||||
"BootstrapAdminOptions": {
|
||||
"AuthHost": "http://localhost:50852"
|
||||
},
|
||||
|
|
|
@ -50,6 +50,13 @@
|
|||
"SlidingExpiration": true,
|
||||
"Desc": "通过菜单获得角色数据"
|
||||
},
|
||||
{
|
||||
"Enabled": true,
|
||||
"Key": "AppHelper-RetrieveAppsByUserName",
|
||||
"Interval": 600000,
|
||||
"SlidingExpiration": true,
|
||||
"Desc": "指定用户授权应用数据缓存"
|
||||
},
|
||||
{
|
||||
"Enabled": true,
|
||||
"Key": "BootstrapUser-RetrieveUsersByName",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.5" />
|
||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.6" />
|
||||
<PackageReference Include="Longbow.Data" Version="2.3.2" />
|
||||
<PackageReference Include="Longbow.Logging" Version="2.2.8" />
|
||||
<PackageReference Include="Longbow.Security.Cryptography" Version="1.3.0" />
|
||||
|
|
|
@ -74,10 +74,8 @@ namespace Bootstrap.DataAccess
|
|||
}
|
||||
if (appIds != null)
|
||||
{
|
||||
appIds.ToList().ForEach(id =>
|
||||
{
|
||||
cacheKeys.Add(string.Format("{0}-{1}", AppHelper.RetrieveAppsByRoleIdDataKey, id));
|
||||
});
|
||||
cacheKeys.Add("AppHelper-RetrieveAppsBy*");
|
||||
corsKeys.Add("AppHelper-RetrieveAppsBy*");
|
||||
}
|
||||
if (dictIds != null)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Longbow.Cache;
|
||||
using Bootstrap.Security.DataAccess;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@ -39,6 +40,6 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<string> RetrievesByUserName(string userName) => DbContextManager.Create<App>().RetrievesByUserName(userName);
|
||||
public static IEnumerable<string> RetrievesByUserName(string userName) => CacheManager.GetOrAdd($"{DbHelper.RetrieveAppsByUserNameDataKey}-{userName}", key => DbContextManager.Create<App>().RetrievesByUserName(userName), DbHelper.RetrieveAppsByUserNameDataKey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Longbow.Cache;
|
||||
using Bootstrap.Security.DataAccess;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -27,15 +28,6 @@ namespace Bootstrap.DataAccess
|
|||
///
|
||||
/// </summary>
|
||||
public const string RetrieveRolesByGroupIdDataKey = "RoleHelper-RetrieveRolesByGroupId";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const string RetrieveRolesByUserNameDataKey = "RoleHelper-RetrieveRolesByUserName";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const string RetrieveRolesByUrlDataKey = "RoleHelper-RetrieveRolesByUrl";
|
||||
|
||||
/// <summary>
|
||||
/// 查询所有角色
|
||||
/// </summary>
|
||||
|
@ -137,13 +129,13 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<string> RetrievesByUserName(string userName) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveRolesByUserNameDataKey, userName), key => DbContextManager.Create<Role>().RetrievesByUserName(userName), RetrieveRolesByUserNameDataKey);
|
||||
public static IEnumerable<string> RetrievesByUserName(string userName) => CacheManager.GetOrAdd(string.Format("{0}-{1}", DbHelper.RetrieveRolesByUserNameDataKey, userName), key => DbContextManager.Create<Role>().RetrievesByUserName(userName), DbHelper.RetrieveRolesByUserNameDataKey);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<string> RetrievesByUrl(string url) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveRolesByUrlDataKey, url), key => DbContextManager.Create<Role>().RetrievesByUrl(url), RetrieveRolesByUrlDataKey);
|
||||
public static IEnumerable<string> RetrievesByUrl(string url) => CacheManager.GetOrAdd(string.Format("{0}-{1}", DbHelper.RetrieveRolesByUrlDataKey, url), key => DbContextManager.Create<Role>().RetrievesByUrl(url), DbHelper.RetrieveRolesByUrlDataKey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ namespace Bootstrap.DataAccess
|
|||
/// <summary>
|
||||
/// 根据菜单url查询某个所拥有的角色
|
||||
/// 从NavigatorRole表查
|
||||
/// 从Navigators-〉GroupNavigatorRole-〉Role查查询某个用户所拥有的角色
|
||||
/// 从Navigators -> GroupNavigatorRole -> Role查查询某个用户所拥有的角色
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual IEnumerable<string> RetrievesByUrl(string url) => DbHelper.RetrieveRolesByUrl(url);
|
||||
|
|
|
@ -24,8 +24,10 @@ namespace Bootstrap.DataAccess.SqlServer
|
|||
UserHelper.SaveByRoleId(roleId, new string[] { userId });
|
||||
Assert.NotEmpty(AppHelper.RetrievesByUserName("Admin"));
|
||||
|
||||
var apps = AppHelper.RetrievesByRoleId(roleId);
|
||||
roleId = RoleHelper.Retrieves().FirstOrDefault(r => r.RoleName == "Default").Id;
|
||||
userId = UserHelper.Retrieves().FirstOrDefault(u => u.UserName == "User").Id;
|
||||
UserHelper.SaveByRoleId(roleId, new string[] { userId });
|
||||
var apps = AppHelper.RetrievesByRoleId(roleId);
|
||||
AppHelper.SaveByRoleId(roleId, apps.Select(a => a.Id));
|
||||
Assert.NotEmpty(AppHelper.RetrievesByUserName("User"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue