fix(#I10GWQ): 重新分配菜单后前台缓存未更新
#Comment comment #I10GWQ 升级 Longbow.Cache 修复本问题 #Issue close https://gitee.com/LongbowEnterprise/dashboard/issues?id=I10GWQ
This commit is contained in:
parent
bb6a48a48d
commit
54997a53ef
|
@ -66,7 +66,7 @@ $(function () {
|
|||
var menus = $nestMenu.find('input:checkbox');
|
||||
menus.prop('checked', false);
|
||||
$.each(result, function (index, item) {
|
||||
var selector = $.format('[value={0}]', item.Id);
|
||||
var selector = $.format('[value={0}]', item);
|
||||
menus.filter(selector).prop('checked', true);
|
||||
});
|
||||
$dialogSubMenu.show();
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<PackageReference Include="Longbow.Web" Version="2.2.15" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Longbow.Cache" Version="2.2.14" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace Bootstrap.Client
|
|||
app.UseStaticFiles();
|
||||
app.UseCookiePolicy();
|
||||
app.UseBootstrapAdminAuthentication();
|
||||
app.UseCacheManagerCorsHandler();
|
||||
app.UseCacheManager();
|
||||
app.UseSignalR(routes => { routes.MapHub<SignalRHub>("/NotiHub"); });
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
|
|
|
@ -6,12 +6,12 @@ using System.Linq;
|
|||
namespace Bootstrap.DataAccess.MongoDB
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// 菜单实体类
|
||||
/// </summary>
|
||||
public class Menu : DataAccess.Menu
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// 获取指定用户的所有菜单
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -29,7 +29,7 @@ namespace Bootstrap.DataAccess.MongoDB
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 保存菜单
|
||||
/// </summary>
|
||||
/// <param name="p"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -58,7 +58,7 @@ namespace Bootstrap.DataAccess.MongoDB
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 删除菜单
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -74,14 +74,14 @@ namespace Bootstrap.DataAccess.MongoDB
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 获取指定角色相关菜单
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public override IEnumerable<object> RetrieveMenusByRoleId(string roleId) => DbManager.Roles.Find(md => md.Id == roleId).FirstOrDefault().Menus.Select(m => new { Id = m });
|
||||
public override IEnumerable<string> RetrieveMenusByRoleId(string roleId) => DbManager.Roles.Find(md => md.Id == roleId).FirstOrDefault().Menus;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 保存指定角色相关菜单
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <param name="menuIds"></param>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<PackageReference Include="Longbow.PetaPoco" Version="1.0.2" />
|
||||
<PackageReference Include="Longbow.Security.Cryptography" Version="1.3.0" />
|
||||
<PackageReference Include="Longbow.Web" Version="2.2.15" />
|
||||
<PackageReference Include="Longbow.Cache" Version="2.2.13" />
|
||||
<PackageReference Include="Longbow.Cache" Version="2.2.14" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="PetaPoco.Extensions" Version="1.0.9" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -5,13 +5,13 @@ using System.Linq;
|
|||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// 缓存清理操作类
|
||||
/// </summary>
|
||||
public static class CacheCleanUtility
|
||||
{
|
||||
private const string RetrieveAllRolesDataKey = "BootstrapAdminRoleMiddleware-RetrieveRoles";
|
||||
/// <summary>
|
||||
///
|
||||
/// 清理缓存
|
||||
/// </summary>
|
||||
/// <param name="roleIds"></param>
|
||||
/// <param name="userIds"></param>
|
||||
|
@ -44,11 +44,11 @@ namespace Bootstrap.DataAccess
|
|||
cacheKeys.Add(string.Format("{0}-{1}", RoleHelper.RetrieveRolesByUserIdDataKey, id));
|
||||
cacheKeys.Add(string.Format("{0}-{1}", GroupHelper.RetrieveGroupsByUserIdDataKey, id));
|
||||
cacheKeys.Add(MenuHelper.RetrieveMenusAll + "*");
|
||||
corsKeys.Add(MenuHelper.RetrieveMenusAll + "*");
|
||||
});
|
||||
cacheKeys.Add(UserHelper.RetrieveNewUsersDataKey + "*");
|
||||
cacheKeys.Add(UserHelper.RetrieveUsersDataKey + "*");
|
||||
corsKeys.Add(UserHelper.RetrieveUsersDataKey + "*");
|
||||
corsKeys.Add(MenuHelper.RetrieveMenusAll + "*");
|
||||
}
|
||||
if (groupIds != null)
|
||||
{
|
||||
|
@ -89,7 +89,7 @@ namespace Bootstrap.DataAccess
|
|||
corsKeys.Add(cacheKey);
|
||||
}
|
||||
CacheManager.Clear(cacheKeys);
|
||||
CacheManager.CorsClear(corsKeys);
|
||||
CacheManager.CorsClear(corsKeys.Distinct());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,22 +8,22 @@ using System.Linq;
|
|||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// 菜单操作类
|
||||
/// </summary>
|
||||
public static class MenuHelper
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// 通过指定角色ID相关菜单缓存键值
|
||||
/// </summary>
|
||||
public const string RetrieveMenusByRoleIdDataKey = "MenuHelper-RetrieveMenusByRoleId";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 通过当前用户获取所有菜单数据缓存键名称 "BootstrapMenu-RetrieveMenus"
|
||||
/// </summary>
|
||||
public const string RetrieveMenusAll = DbHelper.RetrieveMenusAll;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 保存菜单
|
||||
/// </summary>
|
||||
/// <param name="p"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -38,7 +38,7 @@ namespace Bootstrap.DataAccess
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 删除菜单
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -64,14 +64,14 @@ namespace Bootstrap.DataAccess
|
|||
public static IEnumerable<BootstrapMenu> RetrieveMenusByUserName(string userName) => RetrieveAllMenus(userName);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 通过角色获取相关菜单集合
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<object> RetrieveMenusByRoleId(string roleId) => CacheManager.GetOrAdd($"{RetrieveMenusByRoleIdDataKey}-{roleId}", k => DbContextManager.Create<Menu>().RetrieveMenusByRoleId(roleId), RetrieveMenusByRoleIdDataKey);
|
||||
public static IEnumerable<string> RetrieveMenusByRoleId(string roleId) => CacheManager.GetOrAdd($"{RetrieveMenusByRoleIdDataKey}-{roleId}", k => DbContextManager.Create<Menu>().RetrieveMenusByRoleId(roleId), RetrieveMenusByRoleIdDataKey);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 保存指定角色的所有菜单
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <param name="menuIds"></param>
|
||||
|
@ -84,7 +84,7 @@ namespace Bootstrap.DataAccess
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 获取指定用户的应用程序菜单
|
||||
/// </summary>
|
||||
/// <param name="appId"></param>
|
||||
/// <param name="userName"></param>
|
||||
|
|
|
@ -8,7 +8,7 @@ using System.Linq;
|
|||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// 菜单实体类
|
||||
/// </summary>
|
||||
[TableName("Navigations")]
|
||||
public class Menu : BootstrapMenu
|
||||
|
@ -24,10 +24,9 @@ namespace Bootstrap.DataAccess
|
|||
var db = DbManager.Create();
|
||||
try
|
||||
{
|
||||
var ids = string.Join(",", value);
|
||||
db.BeginTransaction();
|
||||
db.Execute($"delete from NavigationRole where NavigationID in ({ids})");
|
||||
db.Delete<Menu>($"where ID in ({ids})");
|
||||
db.Execute($"delete from NavigationRole where NavigationID in @value", new { value });
|
||||
db.Delete<Menu>($"where ID in @value", new { value });
|
||||
db.CompleteTransaction();
|
||||
ret = true;
|
||||
}
|
||||
|
@ -38,6 +37,7 @@ namespace Bootstrap.DataAccess
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存新建/更新的菜单信息
|
||||
/// </summary>
|
||||
|
@ -53,16 +53,18 @@ namespace Bootstrap.DataAccess
|
|||
DbManager.Create().Save(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询某个角色所配置的菜单
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public virtual IEnumerable<object> RetrieveMenusByRoleId(string roleId)
|
||||
public virtual IEnumerable<string> RetrieveMenusByRoleId(string roleId)
|
||||
{
|
||||
var menus = DbManager.Create().Fetch<BootstrapMenu>("select NavigationID as Id from NavigationRole where RoleID = @0", roleId);
|
||||
return menus.Select(m => new { m.Id });
|
||||
return menus.Select(m => m.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过角色ID保存当前授权菜单
|
||||
/// </summary>
|
||||
|
@ -88,6 +90,7 @@ namespace Bootstrap.DataAccess
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过当前用户名获得所有菜单
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue