diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/DictService.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/DictService.cs
index 93e38ca8..cae8d1d9 100644
--- a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/DictService.cs
+++ b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/DictService.cs
@@ -463,7 +463,7 @@ class DictService : IDict
public bool DeleteClient(string appId)
{
- var ret = false;
+ bool ret;
try
{
Database.BeginTransaction();
diff --git a/src/blazor/client/BootstrapClient.DataAccess/Services/DictService.cs b/src/blazor/client/BootstrapClient.DataAccess/Services/DictService.cs
index 714e7c18..384c4ef8 100644
--- a/src/blazor/client/BootstrapClient.DataAccess/Services/DictService.cs
+++ b/src/blazor/client/BootstrapClient.DataAccess/Services/DictService.cs
@@ -1,6 +1,5 @@
using BootstrapClient.DataAccess.Models;
using BootstrapClient.Web.Core;
-using Microsoft.Extensions.Configuration;
using PetaPoco;
namespace BootstrapClient.DataAccess.PetaPoco.Services;
@@ -9,17 +8,13 @@ class DictService : IDict
{
private IDatabase Database { get; }
- private string AppId { get; set; }
-
///
///
///
///
- ///
- public DictService(IDatabase db, IConfiguration configuration)
+ public DictService(IDatabase db)
{
Database = db;
- AppId = configuration.GetValue("AppId", "BA");
}
public List GetAll() => Database.Fetch();
@@ -31,11 +26,11 @@ class DictService : IDict
return code == "1";
}
- public string GetWebTitle()
+ public string GetWebTitle(string appId)
{
var dicts = GetAll();
var title = "网站标题";
- var name = dicts.FirstOrDefault(d => d.Category == "应用程序" && d.Code == AppId)?.Name;
+ var name = dicts.FirstOrDefault(d => d.Category == "应用程序" && d.Code == appId)?.Name;
if (!string.IsNullOrEmpty(name))
{
var dict = dicts.FirstOrDefault(d => d.Category == name && d.Name == "网站标题") ?? dicts.FirstOrDefault(d => d.Category == "网站设置" && d.Name == "网站标题");
@@ -44,11 +39,11 @@ class DictService : IDict
return title;
}
- public string GetWebFooter()
+ public string GetWebFooter(string appId)
{
var dicts = GetAll();
var title = "网站页脚";
- var name = dicts.FirstOrDefault(d => d.Category == "应用程序" && d.Code == AppId)?.Name;
+ var name = dicts.FirstOrDefault(d => d.Category == "应用程序" && d.Code == appId)?.Name;
if (!string.IsNullOrEmpty(name))
{
var dict = dicts.FirstOrDefault(d => d.Category == name && d.Name == "网站页脚") ?? dicts.FirstOrDefault(d => d.Category == "网站设置" && d.Name == "网站页脚");
diff --git a/src/blazor/client/BootstrapClient.DataAccess/Services/NavigationService.cs b/src/blazor/client/BootstrapClient.DataAccess/Services/NavigationService.cs
index b07e6c88..55d97067 100644
--- a/src/blazor/client/BootstrapClient.DataAccess/Services/NavigationService.cs
+++ b/src/blazor/client/BootstrapClient.DataAccess/Services/NavigationService.cs
@@ -30,39 +30,4 @@ class NavigationService : INavigation
var order = Database.Provider.EscapeSqlIdentifier("Order");
return Database.Fetch($"select n.ID, n.ParentId, n.Name, n.{order}, n.Icon, n.Url, n.Category, n.Target, n.IsResource, n.Application from Navigations n inner join (select nr.NavigationID from Users u inner join UserRole ur on ur.UserID = u.ID inner join NavigationRole nr on nr.RoleID = ur.RoleID where u.UserName = @UserName union select nr.NavigationID from Users u inner join UserGroup ug on u.ID = ug.UserID inner join RoleGroup rg on rg.GroupID = ug.GroupID inner join NavigationRole nr on nr.RoleID = rg.RoleID where u.UserName = @UserName union select n.ID from Navigations n where EXISTS (select UserName from Users u inner join UserRole ur on u.ID = ur.UserID inner join Roles r on ur.RoleID = r.ID where u.UserName = @UserName and r.RoleName = 'Administrators')) nav on n.ID = nav.NavigationID Where n.Category = '1' ORDER BY n.Application, n.{order}", new { UserName = userName });
}
-
- ///
- ///
- ///
- ///
- ///
- public List GetMenusByRoleId(string? roleId)
- {
- return Database.Fetch("select NavigationID from NavigationRole where RoleID = @0", roleId);
- }
-
- ///
- ///
- ///
- ///
- ///
- ///
- public bool SaveMenusByRoleId(string? roleId, List menuIds)
- {
- var ret = false;
- try
- {
- Database.BeginTransaction();
- Database.Execute("delete from NavigationRole where RoleID = @0", roleId);
- Database.InsertBatch("NavigationRole", menuIds.Select(g => new { NavigationID = g, RoleID = roleId }));
- Database.CompleteTransaction();
- ret = true;
- }
- catch (Exception)
- {
- Database.AbortTransaction();
- throw;
- }
- return ret;
- }
}
diff --git a/src/blazor/client/BootstrapClient.DataAccess/Services/UserService.cs b/src/blazor/client/BootstrapClient.DataAccess/Services/UserService.cs
index bf57d446..e08802ca 100644
--- a/src/blazor/client/BootstrapClient.DataAccess/Services/UserService.cs
+++ b/src/blazor/client/BootstrapClient.DataAccess/Services/UserService.cs
@@ -32,7 +32,6 @@ class UserService : IUser
///
///
///
- ///
public List GetApps(string userName)
{
return Database.Fetch($"select d.Code from Dicts d inner join RoleApp ra on d.Code = ra.AppId inner join (select r.Id from Roles r inner join UserRole ur on r.ID = ur.RoleID inner join Users u on ur.UserID = u.ID where u.UserName = @0 union select r.Id from Roles r inner join RoleGroup rg on r.ID = rg.RoleID inner join {Database.Provider.EscapeSqlIdentifier("Groups")} g on rg.GroupID = g.ID inner join UserGroup ug on ug.GroupID = g.ID inner join Users u on ug.UserID = u.ID where u.UserName = @0) r on ra.RoleId = r.ID union select Code from Dicts where Category = @1 and exists(select r.ID from Roles r inner join UserRole ur on r.ID = ur.RoleID inner join Users u on ur.UserID = u.ID where u.UserName = @0 and r.RoleName = @2 union select r.ID from Roles r inner join RoleGroup rg on r.ID = rg.RoleID inner join {Database.Provider.EscapeSqlIdentifier("Groups")} g on rg.GroupID = g.ID inner join UserGroup ug on ug.GroupID = g.ID inner join Users u on ug.UserID = u.ID where u.UserName = @0 and r.RoleName = @2)", userName, "应用程序", "Administrators");
@@ -43,7 +42,6 @@ class UserService : IUser
///
///
///
- ///
public List GetRoles(string userName)
{
return Database.Fetch($"select r.RoleName from Roles r inner join UserRole ur on r.ID=ur.RoleID inner join Users u on ur.UserID = u.ID and u.UserName = @0 union select r.RoleName from Roles r inner join RoleGroup rg on r.ID = rg.RoleID inner join {Database.Provider.EscapeSqlIdentifier("Groups")} g on rg.GroupID = g.ID inner join UserGroup ug on ug.GroupID = g.ID inner join Users u on ug.UserID = u.ID and u.UserName=@0", userName);
diff --git a/src/blazor/client/BootstrapClient.Shared/Shared/MainLayout.razor.cs b/src/blazor/client/BootstrapClient.Shared/Shared/MainLayout.razor.cs
index 26c238bd..6fc186df 100644
--- a/src/blazor/client/BootstrapClient.Shared/Shared/MainLayout.razor.cs
+++ b/src/blazor/client/BootstrapClient.Shared/Shared/MainLayout.razor.cs
@@ -108,8 +108,8 @@ public sealed partial class MainLayout
MenuItems = NavigationsService.GetMenus(userName).Where(i => i.Application == Context.AppId).ToMenus();
Context.DisplayName = user?.DisplayName ?? "未注册账户";
- Title = DictsService.GetWebTitle();
- Footer = DictsService.GetWebFooter();
+ Title = DictsService.GetWebTitle(Context.AppId);
+ Footer = DictsService.GetWebFooter(Context.AppId);
}
}
diff --git a/src/blazor/client/BootstrapClient.Web.Core/IDict.cs b/src/blazor/client/BootstrapClient.Web.Core/IDict.cs
index 00d89fac..5a5728bb 100644
--- a/src/blazor/client/BootstrapClient.Web.Core/IDict.cs
+++ b/src/blazor/client/BootstrapClient.Web.Core/IDict.cs
@@ -15,13 +15,13 @@ public interface IDict
/// 获取 站点 Title 配置信息
///
///
- string GetWebTitle();
+ string GetWebTitle(string appId);
///
/// 获取站点 Footer 配置信息
///
///
- string GetWebFooter();
+ string GetWebFooter(string appId);
///
///