diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/ConfigService.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/ConfigService.cs index 9a7c2db8..5e62a936 100644 --- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/ConfigService.cs +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/ConfigService.cs @@ -1,3 +1,4 @@ +using Microsoft.AspNetCore.Mvc; using SqlSugar; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; @@ -61,5 +62,18 @@ namespace Yi.Framework.Rbac.Application.Services throw new UserFriendlyException(ConfigConst.Exist); } } + + /// + /// 根据key查配置 + /// + /// + /// + /// + [Route("config/config-key/{configKey}")] + public async Task GetConfigKeyAsync(string configKey) + { + var entity = await _repository.GetAsync(x => x.ConfigKey == configKey); + return entity.ConfigValue; + } } } \ No newline at end of file diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.SqlSugarCore/DataSeeds/ConfigDataSeed.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.SqlSugarCore/DataSeeds/ConfigDataSeed.cs new file mode 100644 index 00000000..f2ed5b8d --- /dev/null +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.SqlSugarCore/DataSeeds/ConfigDataSeed.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Guids; +using Yi.Framework.Rbac.Domain.Entities; +using Yi.Framework.SqlSugarCore.Abstractions; + +namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds +{ + internal class ConfigDataSeed : IDataSeedContributor, ITransientDependency + { + private ISqlSugarRepository _repository; + private IGuidGenerator _guidGenerator; + + public ConfigDataSeed(ISqlSugarRepository repository, IGuidGenerator guidGenerator) + { + _repository = repository; + _guidGenerator = guidGenerator; + } + + public async Task SeedAsync(DataSeedContext context) + { + if (!await _repository.IsAnyAsync(x => true)) + { + await _repository.InsertManyAsync(GetSeedData()); + } + } + public List GetSeedData() + { + var entities = new List(); + + ConfigAggregateRoot initPassword = new ConfigAggregateRoot() + { + ConfigName = "初始密码", + ConfigKey = "sys.user.initPassword", + ConfigValue = "123456", + OrderNum = 1, + IsDeleted = false, + Remark = "初始密码" + }; + entities.Add(initPassword); + + return entities; + } + } +}