ow
This commit is contained in:
commit
f05d2d215f
678 files changed
+73865
No files matched your search
+47
@@ -0,0 +1,47 @@
|
||||
using CloudBuilder.Core.Application.Builders;
|
||||
using CloudBuilder.Core.Application.Packs;
|
||||
using CloudBuilder.Core.Authorization;
|
||||
using CloudBuilder.Core.DependencyInjection.Form;
|
||||
using CloudBuilder.Core.DependencyInjection.Request;
|
||||
using CloudBuilder.Core.Policy;
|
||||
using CloudBuilder.Security.Service;
|
||||
using CloudBuilder.Security.Service.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CloudBuilder.Gui.DependencyInjection
|
||||
{
|
||||
[PackLevel(100)]
|
||||
public class CloudBuilderSecurityServicePack : CloudBuilderPack
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取 模块级别
|
||||
/// </summary>
|
||||
public override PackLevel Level => PackLevel.Business;
|
||||
|
||||
/// <summary>
|
||||
/// 获取 模块启动顺序,模块启动的顺序先按级别启动,级别内部再按此顺序启动
|
||||
/// </summary>
|
||||
public override int Order => 2;
|
||||
|
||||
/// <summary>
|
||||
/// 将ServiceMessageManager到依赖注入服务容器中
|
||||
/// </summary>
|
||||
/// <param name="services">依赖注入服务容器</param>
|
||||
/// <returns></returns>
|
||||
public override IServiceCollection AddServices(IServiceCollection services,CloudBuilderBuilder builder)
|
||||
{
|
||||
services.TryAddScoped<ILocaleMessageManager, ServiceMessageManager>();
|
||||
services.TryAddScoped<ISecurityMasterManager, SecurityMasterManager>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
using CloudBuilder.Core.DatabaseAccessor.Entity;
|
||||
using CloudBuilder.Core.DependencyInjection.Request;
|
||||
using CloudBuilder.Core.Policy;
|
||||
using CloudBuilder.Security.Entity;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CloudBuilder.Security.Service.DependencyInjection
|
||||
{
|
||||
public class SecurityMasterManager : ISecurityMasterManager
|
||||
{
|
||||
private readonly IApplicationService service;
|
||||
private readonly IContext context;
|
||||
|
||||
public SecurityMasterManager(IApplicationService service, IContext context)
|
||||
{
|
||||
|
||||
this.service = service;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
public void InitSecurityMaster()
|
||||
{
|
||||
//暂时不处理缓存
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string GetValue(string category, string subcategory, string codeItem)
|
||||
{
|
||||
SecurityMasterEntity securityMaster = GetSecurityMaster(category, subcategory, codeItem);
|
||||
if (securityMaster == null) return null;
|
||||
return securityMaster.Value;
|
||||
}
|
||||
|
||||
public dynamic GetSecurityMaster(string category, string subcategory, string codeItem)
|
||||
{
|
||||
SecurityMasterEntityKey key = new SecurityMasterEntityKey()
|
||||
{
|
||||
MasterSubcategory = subcategory,
|
||||
MasterCategory = category,
|
||||
MasterCodeItem = codeItem
|
||||
};
|
||||
ISecurityMasterService securityMasterService = service.ServiceProvider.GetService<ISecurityMasterService>()!;
|
||||
return securityMasterService.FindByKey(key);
|
||||
|
||||
}
|
||||
|
||||
public void SetSecurityMaster(string category, string subcategory, string codeItem, string value)
|
||||
{
|
||||
SecurityMasterEntity securityMaster = new SecurityMasterEntity();
|
||||
securityMaster.MasterSubcategory = subcategory;
|
||||
securityMaster.MasterCodeItem = codeItem;
|
||||
securityMaster.MasterCategory = category;
|
||||
securityMaster.Value = value;
|
||||
securityMaster.ValidIndc = YesNoPolicy.YES;
|
||||
|
||||
ISecurityMasterService securityMasterService = service.ServiceProvider.GetService<ISecurityMasterService>()!;
|
||||
securityMasterService.Insert(securityMaster);
|
||||
}
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
using CloudBuilder.Core.DatabaseAccessor.Entity;
|
||||
using CloudBuilder.Core.DependencyInjection.Request;
|
||||
using CloudBuilder.Core.Policy;
|
||||
using CloudBuilder.Core.Service;
|
||||
using CloudBuilder.Security.Entity;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CloudBuilder.Security.Service.DependencyInjection
|
||||
{
|
||||
public class ServiceMessageManager : ILocaleMessageManager
|
||||
{
|
||||
public LocaleEntity[] LocaleEntities { get; set; } = null!;
|
||||
|
||||
public static string SYSTEM = "system";
|
||||
public static string GUI_INFORMATION = "gui_information";
|
||||
public static string GUI_ERROR = "gui_error";
|
||||
private readonly IContext context;
|
||||
|
||||
public IApplicationService Service { get; set; }
|
||||
|
||||
private readonly IApplicationService service;
|
||||
|
||||
private IRepository<LocaleEntity> repository;
|
||||
public ServiceMessageManager(IApplicationService service, IContext context)
|
||||
{
|
||||
this.service = service;
|
||||
this.context = context;
|
||||
repository = service.GetRepository<IRepository<LocaleEntity>>();
|
||||
}
|
||||
|
||||
public void InitLocale()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string ComposeMessage(string groupName, string name)
|
||||
{
|
||||
LocaleEntity localeEntity = repository.DetachedEntities.Where(x => x.GroupName == groupName && x.Name == name && x.Lang == context.GetCulture()).FirstOrDefault()!;
|
||||
|
||||
if (localeEntity == null) throw new ValidatedException();
|
||||
|
||||
return localeEntity.Value;
|
||||
}
|
||||
|
||||
public TableName<string>[] GetDataSource(string groupName)
|
||||
{
|
||||
string[] values = repository.DetachedEntities.Where(x => x.GroupName == groupName && x.Lang == context.GetCulture()).Select(x => x.Name).ToArray();
|
||||
|
||||
return GetComposeMessages<string>(groupName, values);
|
||||
}
|
||||
|
||||
public TableName<T>[] GetComposeMessages<T>(string groupName, T[] values)
|
||||
{
|
||||
if (values == null || values.Length == 0) return null;
|
||||
TableName<T> tb = null;
|
||||
List<TableName<T>> list = new List<TableName<T>>();
|
||||
foreach (T v in values)
|
||||
{
|
||||
tb = new TableName<T>();
|
||||
tb.DisplayName = ComposeMessage(groupName, v.ToString());
|
||||
tb.Value = v;
|
||||
list.Add(tb);
|
||||
}
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user