refactor: ♻️ 框架代码同步 (#181)

Co-authored-by: tk <fiyne1a@dingtalk.com>
This commit is contained in:
2024-10-30 14:40:52 +08:00
committed by GitHub
parent f0c3ec109f
commit bac4a39544
54 changed files with 256 additions and 111 deletions

View File

@ -1,9 +1,6 @@
using System.Collections.Concurrent;
using NetAdmin.Application.Services;
using NetAdmin.Domain.Dto.Dependency;
using NetAdmin.Domain.Dto.Sys.Cache;
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
using StackExchange.Redis;
namespace NetAdmin.SysComponent.Application.Services.Sys;
@ -82,6 +79,7 @@ public sealed class CacheService(IConnectionMultiplexer connectionMultiplexer) /
/// <inheritdoc />
public async Task<GetEntryRsp> GetEntryAsync(GetEntriesReq req)
{
req.ThrowIfInvalid();
var database = connectionMultiplexer.GetDatabase(_redisInstance.Database);
var ret = new GetEntryRsp {

View File

@ -1,7 +1,5 @@
using NetAdmin.Application.Repositories;
using NetAdmin.Application.Services;
using NetAdmin.Domain.Dto.Dependency;
using NetAdmin.Domain.Dto.Sys.Config;
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
namespace NetAdmin.SysComponent.Application.Services.Sys;
@ -53,6 +51,7 @@ public sealed class ConfigService(BasicRepository<Sys_Config, long> rpo) //
/// <inheritdoc />
public async Task<QueryConfigRsp> EditAsync(EditConfigReq req)
{
req.ThrowIfInvalid();
#if DBTYPE_SQLSERVER
return (await UpdateReturnListAsync(req, null).ConfigureAwait(false)).FirstOrDefault()?.Adapt<QueryConfigRsp>();
#else

View File

@ -1,7 +1,5 @@
using NetAdmin.Application.Repositories;
using NetAdmin.Application.Services;
using NetAdmin.Domain.Dto.Dependency;
using NetAdmin.Domain.Dto.Sys.Dept;
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
namespace NetAdmin.SysComponent.Application.Services.Sys;
@ -71,6 +69,7 @@ public sealed class DeptService(BasicRepository<Sys_Dept, long> rpo) //
/// <inheritdoc />
public async Task<QueryDeptRsp> EditAsync(EditDeptReq req)
{
req.ThrowIfInvalid();
#if DBTYPE_SQLSERVER
return (await UpdateReturnListAsync(req, null).ConfigureAwait(false)).FirstOrDefault()?.Adapt<QueryDeptRsp>();
#else

View File

@ -1,7 +1,5 @@
using NetAdmin.Application.Repositories;
using NetAdmin.Application.Services;
using NetAdmin.Domain.Dto.Dependency;
using NetAdmin.Domain.Dto.Sys.Dic.Catalog;
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
namespace NetAdmin.SysComponent.Application.Services.Sys;
@ -90,6 +88,7 @@ public sealed class DicCatalogService(BasicRepository<Sys_DicCatalog, long> rpo)
/// <inheritdoc />
public Task<IActionResult> ExportAsync(QueryReq<QueryDicCatalogReq> req)
{
req.ThrowIfInvalid();
throw new NotImplementedException();
}

View File

@ -1,7 +1,5 @@
using NetAdmin.Application.Repositories;
using NetAdmin.Application.Services;
using NetAdmin.Domain.Dto.Dependency;
using NetAdmin.Domain.Dto.Sys.Menu;
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
namespace NetAdmin.SysComponent.Application.Services.Sys;
@ -55,6 +53,7 @@ public sealed class MenuService(BasicRepository<Sys_Menu, long> rpo, IUserServic
/// <inheritdoc />
public async Task<QueryMenuRsp> EditAsync(EditMenuReq req)
{
req.ThrowIfInvalid();
#if DBTYPE_SQLSERVER
return (await UpdateReturnListAsync(req, null).ConfigureAwait(false)).FirstOrDefault()?.Adapt<QueryMenuRsp>();
#else
@ -76,6 +75,7 @@ public sealed class MenuService(BasicRepository<Sys_Menu, long> rpo, IUserServic
/// <inheritdoc />
public Task<IActionResult> ExportAsync(QueryReq<QueryMenuReq> req)
{
req.ThrowIfInvalid();
throw new NotImplementedException();
}

View File

@ -1,7 +1,5 @@
using NetAdmin.Application.Repositories;
using NetAdmin.Application.Services;
using NetAdmin.Domain.Dto.Dependency;
using NetAdmin.Domain.Dto.Sys.RequestLogDetail;
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
namespace NetAdmin.SysComponent.Application.Services.Sys;
@ -64,6 +62,7 @@ public sealed class RequestLogDetailService(BasicRepository<Sys_RequestLogDetail
/// <inheritdoc />
public Task<IActionResult> ExportAsync(QueryReq<QueryRequestLogDetailReq> req)
{
req.ThrowIfInvalid();
throw new NotImplementedException();
}

View File

@ -1,7 +1,5 @@
using NetAdmin.Application.Repositories;
using NetAdmin.Application.Services;
using NetAdmin.Domain.Dto.Dependency;
using NetAdmin.Domain.Dto.Sys.SiteMsgDept;
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
namespace NetAdmin.SysComponent.Application.Services.Sys;
@ -64,6 +62,7 @@ public sealed class SiteMsgDeptService(BasicRepository<Sys_SiteMsgDept, long> rp
/// <inheritdoc />
public Task<IActionResult> ExportAsync(QueryReq<QuerySiteMsgDeptReq> req)
{
req.ThrowIfInvalid();
throw new NotImplementedException();
}

View File

@ -1,7 +1,5 @@
using NetAdmin.Application.Repositories;
using NetAdmin.Application.Services;
using NetAdmin.Domain.Dto.Dependency;
using NetAdmin.Domain.Dto.Sys.SiteMsgFlag;
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
namespace NetAdmin.SysComponent.Application.Services.Sys;
@ -64,6 +62,7 @@ public sealed class SiteMsgFlagService(BasicRepository<Sys_SiteMsgFlag, long> rp
/// <inheritdoc />
public Task<IActionResult> ExportAsync(QueryReq<QuerySiteMsgFlagReq> req)
{
req.ThrowIfInvalid();
throw new NotImplementedException();
}

View File

@ -1,7 +1,5 @@
using NetAdmin.Application.Repositories;
using NetAdmin.Application.Services;
using NetAdmin.Domain.Dto.Dependency;
using NetAdmin.Domain.Dto.Sys.SiteMsgRole;
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
namespace NetAdmin.SysComponent.Application.Services.Sys;
@ -64,6 +62,7 @@ public sealed class SiteMsgRoleService(BasicRepository<Sys_SiteMsgRole, long> rp
/// <inheritdoc />
public Task<IActionResult> ExportAsync(QueryReq<QuerySiteMsgRoleReq> req)
{
req.ThrowIfInvalid();
throw new NotImplementedException();
}

View File

@ -1,7 +1,5 @@
using NetAdmin.Application.Repositories;
using NetAdmin.Application.Services;
using NetAdmin.Domain.Dto.Dependency;
using NetAdmin.Domain.Dto.Sys.SiteMsgUser;
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
namespace NetAdmin.SysComponent.Application.Services.Sys;
@ -64,6 +62,7 @@ public sealed class SiteMsgUserService(BasicRepository<Sys_SiteMsgUser, long> rp
/// <inheritdoc />
public Task<IActionResult> ExportAsync(QueryReq<QuerySiteMsgUserReq> req)
{
req.ThrowIfInvalid();
throw new NotImplementedException();
}

View File

@ -1,5 +1,4 @@
using NetAdmin.Application.Services;
using NetAdmin.Domain.Dto.Sys.Tool;
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
namespace NetAdmin.SysComponent.Application.Services.Sys;
@ -17,6 +16,7 @@ public sealed class ToolsService : ServiceBase<IToolsService>, IToolsService
/// <inheritdoc />
public Task<object[][]> ExecuteSqlAsync(ExecuteSqlReq req)
{
req.ThrowIfInvalid();
return App.GetService<IFreeSql>().Ado.CommandFluent(req.Sql).CommandTimeout(req.TimeoutSecs).ExecuteArrayAsync();
}

View File

@ -1,9 +1,5 @@
using NetAdmin.Application.Repositories;
using NetAdmin.Application.Services;
using NetAdmin.Domain.Contexts;
using NetAdmin.Domain.Dto.Dependency;
using NetAdmin.Domain.Dto.Sys.Dic.Content;
using NetAdmin.Domain.Dto.Sys.UserProfile;
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
namespace NetAdmin.SysComponent.Application.Services.Sys;
@ -73,6 +69,7 @@ public sealed class UserProfileService(BasicRepository<Sys_UserProfile, long> rp
/// <inheritdoc />
public Task<int> EditAsync(EditUserProfileReq req)
{
req.ThrowIfInvalid();
return UpdateAsync(req.Adapt<Sys_UserProfile>(), null);
}
@ -90,6 +87,7 @@ public sealed class UserProfileService(BasicRepository<Sys_UserProfile, long> rp
/// <inheritdoc />
public Task<IActionResult> ExportAsync(QueryReq<QueryUserProfileReq> req)
{
req.ThrowIfInvalid();
throw new NotImplementedException();
}

View File

@ -1,11 +1,5 @@
using NetAdmin.Application.Repositories;
using NetAdmin.Application.Services;
using NetAdmin.Domain.Contexts;
using NetAdmin.Domain.Dto.Dependency;
using NetAdmin.Domain.Dto.Sys.User;
using NetAdmin.Domain.Dto.Sys.UserProfile;
using NetAdmin.Domain.Dto.Sys.VerifyCode;
using NetAdmin.Domain.Events.Sys;
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
namespace NetAdmin.SysComponent.Application.Services.Sys;
@ -100,8 +94,12 @@ public sealed class UserService(
, AppConfig = appConfig
})
.ConfigureAwait(false);
var ret = await QueryAsync(new QueryReq<QueryUserReq> { Filter = new QueryUserReq { Id = dbUser.Id } }).ConfigureAwait(false);
return ret.First();
var userList = await QueryAsync(new QueryReq<QueryUserReq> { Filter = new QueryUserReq { Id = dbUser.Id } }).ConfigureAwait(false);
// 发布用户创建事件
var ret = userList.First();
await eventPublisher.PublishAsync(new UserCreatedEvent(ret.Adapt<UserInfoRsp>())).ConfigureAwait(false);
return ret;
}
/// <inheritdoc />

View File

@ -1,9 +1,5 @@
using NetAdmin.Application.Repositories;
using NetAdmin.Application.Services;
using NetAdmin.Domain.Dto.Dependency;
using NetAdmin.Domain.Dto.Sys.VerifyCode;
using NetAdmin.Domain.Enums.Sys;
using NetAdmin.Domain.Events.Sys;
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
namespace NetAdmin.SysComponent.Application.Services.Sys;
@ -74,6 +70,7 @@ public sealed class VerifyCodeService(BasicRepository<Sys_VerifyCode, long> rpo,
/// <inheritdoc />
public Task<IActionResult> ExportAsync(QueryReq<QueryVerifyCodeReq> req)
{
req.ThrowIfInvalid();
throw new NotImplementedException();
}
@ -144,6 +141,7 @@ public sealed class VerifyCodeService(BasicRepository<Sys_VerifyCode, long> rpo,
/// <inheritdoc />
public Task<int> SetVerifyCodeStatusAsync(SetVerifyCodeStatusReq req)
{
req.ThrowIfInvalid();
return UpdateAsync(req, [nameof(req.Status)]);
}