From fe7c1763ba11a5c5f134342d6e21c1c918092753 Mon Sep 17 00:00:00 2001 From: wcg Date: Sun, 4 Jan 2026 10:13:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(config):=20=E6=B7=BB=E5=8A=A0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=95=B0=E6=8D=AE=E7=A7=8D=E5=AD=90=E5=92=8C=E6=A0=B9?= =?UTF-8?q?=E6=8D=AEkey=E6=9F=A5=E8=AF=A2=E9=85=8D=E7=BD=AE=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=20-=20=E6=B7=BB=E5=8A=A0=E5=88=9D=E5=A7=8B=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E9=85=8D=E7=BD=AE=E9=A1=B9=E7=9A=84=E7=A7=8D=E5=AD=90?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=20(sys.user.initPassword:=20123456)=20-=20?= =?UTF-8?q?=E5=9C=A8=20ConfigService=20=E4=B8=AD=E6=96=B0=E5=A2=9E=20GetCo?= =?UTF-8?q?nfigKeyAsync=20=E6=96=B9=E6=B3=95=E6=94=AF=E6=8C=81=E6=A0=B9?= =?UTF-8?q?=E6=8D=AEkey=E6=9F=A5=E8=AF=A2=E9=85=8D=E7=BD=AE=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/ConfigService.cs | 14 ++++++ .../DataSeeds/ConfigDataSeed.cs | 50 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.SqlSugarCore/DataSeeds/ConfigDataSeed.cs 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; + } + } +}