From 0285eea35293912ce2de8fec5a39761c43b75cfa Mon Sep 17 00:00:00 2001 From: tk Date: Wed, 11 Dec 2024 09:35:47 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E4=BB=A3=E7=A0=81=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/RepositoryService.cs | 4 +- .../Services/Tpl/ExampleService.cs | 13 ++++++- .../Dto/Dependency/QueryReq.cs | 2 +- .../NetAdmin.Host/Filters/ApiResultHandler.cs | 5 ++- .../NetAdmin.Infrastructure/Constant/Chars.cs | 1 + .../NetAdmin.Infrastructure.csproj | 4 +- .../Services/Sys/ApiService.cs | 5 ++- .../Services/Sys/ConfigService.cs | 13 ++++++- .../Services/Sys/DicCatalogService.cs | 7 +++- .../Services/Sys/DicContentService.cs | 15 ++++++-- .../Services/Sys/DocCatalogService.cs | 7 +++- .../Services/Sys/DocContentService.cs | 13 ++++++- .../Services/Sys/JobRecordService.cs | 13 ++++++- .../Services/Sys/JobService.cs | 13 ++++++- .../Services/Sys/LoginLogService.cs | 6 ++- .../Services/Sys/RequestLogDetailService.cs | 13 ++++++- .../Services/Sys/RequestLogService.cs | 6 ++- .../Services/Sys/RoleService.cs | 9 ++++- .../Services/Sys/SiteMsgDeptService.cs | 13 ++++++- .../Services/Sys/SiteMsgFlagService.cs | 13 ++++++- .../Services/Sys/SiteMsgRoleService.cs | 13 ++++++- .../Services/Sys/SiteMsgService.cs | 6 ++- .../Services/Sys/SiteMsgUserService.cs | 13 ++++++- .../Services/Sys/UserRoleService.cs | 13 ++++++- .../Services/Sys/VerifyCodeService.cs | 13 ++++++- src/frontend/admin/src/App.vue | 30 +++++++++++++++ .../admin/src/components/scTable/index.vue | 38 ++++++++++++++++--- .../admin/src/views/sys/dic/list/index.vue | 2 +- .../admin/src/views/sys/doc/list/index.vue | 2 +- 29 files changed, 256 insertions(+), 49 deletions(-) diff --git a/src/backend/NetAdmin/NetAdmin.Application/Services/RepositoryService.cs b/src/backend/NetAdmin/NetAdmin.Application/Services/RepositoryService.cs index 9b165882..c5871793 100644 --- a/src/backend/NetAdmin/NetAdmin.Application/Services/RepositoryService.cs +++ b/src/backend/NetAdmin/NetAdmin.Application/Services/RepositoryService.cs @@ -52,7 +52,9 @@ public abstract class RepositoryService(BasicReposit { var select = selector(query).WithNoLockNoWait().Take(Numbers.MAX_LIMIT_EXPORT); - object list = listExp == null ? await select.ToListAsync().ConfigureAwait(false) : await select.ToListAsync(listExp).ConfigureAwait(false); + object list = listExp == null + ? await select.ToListAsync(a => a).ConfigureAwait(false) + : await select.ToListAsync(listExp).ConfigureAwait(false); return await GetExportFileStreamAsync(fileName, list).ConfigureAwait(false); } diff --git a/src/backend/NetAdmin/NetAdmin.Application/Services/Tpl/ExampleService.cs b/src/backend/NetAdmin/NetAdmin.Application/Services/Tpl/ExampleService.cs index 60edca34..8827f7ae 100644 --- a/src/backend/NetAdmin/NetAdmin.Application/Services/Tpl/ExampleService.cs +++ b/src/backend/NetAdmin/NetAdmin.Application/Services/Tpl/ExampleService.cs @@ -91,7 +91,12 @@ public sealed class ExampleService(BasicRepository rpo) // public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); + var list = await QueryInternal(req) + .Page(req.Page, req.PageSize) + .WithNoLockNoWait() + .Count(out var total) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -100,7 +105,11 @@ public sealed class ExampleService(BasicRepository rpo) // public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); + var ret = await QueryInternal(req) + .WithNoLockNoWait() + .Take(req.Count) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Dependency/QueryReq.cs b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Dependency/QueryReq.cs index 3b8ff65d..12b5c7b9 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Dependency/QueryReq.cs +++ b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Dependency/QueryReq.cs @@ -40,7 +40,7 @@ public record QueryReq : DataAbstraction /// /// 所需字段 /// - public string[] RequiredFields { get; set; } + public string[] RequiredFields { get; init; } /// /// 列表表达式 diff --git a/src/backend/NetAdmin/NetAdmin.Host/Filters/ApiResultHandler.cs b/src/backend/NetAdmin/NetAdmin.Host/Filters/ApiResultHandler.cs index 819c40d9..ebad9d0d 100644 --- a/src/backend/NetAdmin/NetAdmin.Host/Filters/ApiResultHandler.cs +++ b/src/backend/NetAdmin/NetAdmin.Host/Filters/ApiResultHandler.cs @@ -25,8 +25,9 @@ public abstract class ApiResultHandler { var naException = context.Exception switch { NetAdminException ex => ex - , _ => context.Exception.Message.Contains(Chars.FLG_DB_EXCEPTION_PRIMARY_KEY_CONFLICT) || - context.Exception.Message.Contains(Chars.FLG_DB_EXCEPTION_UNIQUE_CONSTRAINT_CONFLICT) + , _ => context.Exception.Message.Contains(Chars.FLG_DB_EXCEPTION_PRIMARY_KEY_CONFLICT) || + context.Exception.Message.Contains(Chars.FLG_DB_EXCEPTION_UNIQUE_CONSTRAINT_CONFLICT) || + context.Exception.Message.Contains(Chars.FLG_DB_EXCEPTION_IDX) ? new NetAdminInvalidOperationException(Ln.记录已存在) : null }; diff --git a/src/backend/NetAdmin/NetAdmin.Infrastructure/Constant/Chars.cs b/src/backend/NetAdmin/NetAdmin.Infrastructure/Constant/Chars.cs index 2da589e4..6610707a 100644 --- a/src/backend/NetAdmin/NetAdmin.Infrastructure/Constant/Chars.cs +++ b/src/backend/NetAdmin/NetAdmin.Infrastructure/Constant/Chars.cs @@ -17,6 +17,7 @@ public static class Chars public const string FLG_CRON_PER_SECS = "* * * * * *"; public const string FLG_DB_EXCEPTION_PRIMARY_KEY_CONFLICT = "PRIMARY KEY"; public const string FLG_DB_EXCEPTION_UNIQUE_CONSTRAINT_CONFLICT = "UNIQUE constraint"; + public const string FLG_DB_EXCEPTION_IDX = "idx_"; public const string FLG_DB_FIELD_TYPE_NVARCHAR = "nvarchar"; public const string FLG_DB_FIELD_TYPE_NVARCHAR_1022 = "nvarchar(1022)"; public const string FLG_DB_FIELD_TYPE_NVARCHAR_127 = "nvarchar(127)"; diff --git a/src/backend/NetAdmin/NetAdmin.Infrastructure/NetAdmin.Infrastructure.csproj b/src/backend/NetAdmin/NetAdmin.Infrastructure/NetAdmin.Infrastructure.csproj index 8a55d842..ea6d9675 100644 --- a/src/backend/NetAdmin/NetAdmin.Infrastructure/NetAdmin.Infrastructure.csproj +++ b/src/backend/NetAdmin/NetAdmin.Infrastructure/NetAdmin.Infrastructure.csproj @@ -3,8 +3,8 @@ - - + + diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ApiService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ApiService.cs index aff7ffc0..82d72a88 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ApiService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ApiService.cs @@ -92,7 +92,10 @@ public sealed class ApiService( public async Task> PlainQueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await Rpo.Select.WhereDynamicFilter(req.DynamicFilter).WhereDynamic(req.Filter).ToListAsync().ConfigureAwait(false); + var ret = await Rpo.Select.WhereDynamicFilter(req.DynamicFilter) + .WhereDynamic(req.Filter) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ConfigService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ConfigService.cs index afa3ab4a..fefbd016 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ConfigService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ConfigService.cs @@ -95,7 +95,12 @@ public sealed class ConfigService(BasicRepository rpo) // public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); + var list = await QueryInternal(req) + .Page(req.Page, req.PageSize) + .WithNoLockNoWait() + .Count(out var total) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -104,7 +109,11 @@ public sealed class ConfigService(BasicRepository rpo) // public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); + var ret = await QueryInternal(req) + .WithNoLockNoWait() + .Take(req.Count) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DicCatalogService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DicCatalogService.cs index fecd0d16..db4c81db 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DicCatalogService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DicCatalogService.cs @@ -100,7 +100,12 @@ public sealed class DicCatalogService(BasicRepository rpo) public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); + var list = await QueryInternal(req) + .Page(req.Page, req.PageSize) + .WithNoLockNoWait() + .Count(out var total) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DicContentService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DicContentService.cs index 61241265..679abf0c 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DicContentService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DicContentService.cs @@ -98,7 +98,12 @@ public sealed class DicContentService(BasicRepository rpo) public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); + var list = await QueryInternal(req) + .Page(req.Page, req.PageSize) + .WithNoLockNoWait() + .Count(out var total) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -107,7 +112,11 @@ public sealed class DicContentService(BasicRepository rpo) public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); + var ret = await QueryInternal(req) + .WithNoLockNoWait() + .Take(req.Count) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return ret.Adapt>(); } @@ -119,7 +128,7 @@ public sealed class DicContentService(BasicRepository rpo) .Include(a => a.Catalog) .Where(a => a.Catalog.Code == catalogCode) .Where(a => a.Enabled) - .ToListAsync() + .ToListAsync(a => a) .ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DocCatalogService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DocCatalogService.cs index bfc0de34..62a3353b 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DocCatalogService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DocCatalogService.cs @@ -101,7 +101,12 @@ public sealed class DocCatalogService(BasicRepository rpo) public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); + var list = await QueryInternal(req) + .Page(req.Page, req.PageSize) + .WithNoLockNoWait() + .Count(out var total) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DocContentService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DocContentService.cs index ed4dd900..4572c767 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DocContentService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DocContentService.cs @@ -104,7 +104,12 @@ public sealed class DocContentService(BasicRepository rpo) public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); + var list = await QueryInternal(req) + .Page(req.Page, req.PageSize) + .WithNoLockNoWait() + .Count(out var total) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -113,7 +118,11 @@ public sealed class DocContentService(BasicRepository rpo) public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); + var ret = await QueryInternal(req) + .WithNoLockNoWait() + .Take(req.Count) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/JobRecordService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/JobRecordService.cs index 6ad537d6..38141124 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/JobRecordService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/JobRecordService.cs @@ -130,7 +130,12 @@ public sealed class JobRecordService(BasicRepository rpo) / public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); + var list = await QueryInternal(req) + .Page(req.Page, req.PageSize) + .WithNoLockNoWait() + .Count(out var total) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -139,7 +144,11 @@ public sealed class JobRecordService(BasicRepository rpo) / public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); + var ret = await QueryInternal(req) + .WithNoLockNoWait() + .Take(req.Count) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/JobService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/JobService.cs index 5d8395e4..4ae20643 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/JobService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/JobService.cs @@ -260,7 +260,12 @@ public sealed class JobService(BasicRepository rpo, IJobRecordSer public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); + var list = await QueryInternal(req) + .Page(req.Page, req.PageSize) + .WithNoLockNoWait() + .Count(out var total) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -276,7 +281,11 @@ public sealed class JobService(BasicRepository rpo, IJobRecordSer public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); + var ret = await QueryInternal(req) + .WithNoLockNoWait() + .Take(req.Count) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/LoginLogService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/LoginLogService.cs index 990795b1..b6d7fdc7 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/LoginLogService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/LoginLogService.cs @@ -111,7 +111,11 @@ public sealed class LoginLogService(BasicRepository rpo) // public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); + var ret = await QueryInternal(req) + .WithNoLockNoWait() + .Take(req.Count) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RequestLogDetailService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RequestLogDetailService.cs index 609671a2..3464a666 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RequestLogDetailService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RequestLogDetailService.cs @@ -87,7 +87,12 @@ public sealed class RequestLogDetailService(BasicRepository> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); + var list = await QueryInternal(req) + .Page(req.Page, req.PageSize) + .WithNoLockNoWait() + .Count(out var total) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -96,7 +101,11 @@ public sealed class RequestLogDetailService(BasicRepository> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); + var ret = await QueryInternal(req) + .WithNoLockNoWait() + .Take(req.Count) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RequestLogService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RequestLogService.cs index 747fc584..d6d5e578 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RequestLogService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RequestLogService.cs @@ -184,7 +184,11 @@ public sealed class RequestLogService(BasicRepository rpo, public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); + var ret = await QueryInternal(req) + .WithNoLockNoWait() + .Take(req.Count) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RoleService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RoleService.cs index 6058662e..6a0dba3b 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RoleService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RoleService.cs @@ -101,7 +101,12 @@ public sealed class RoleService(BasicRepository rpo, IUserRoleSe public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); + var list = await QueryInternal(req) + .Page(req.Page, req.PageSize) + .WithNoLockNoWait() + .Count(out var total) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -110,7 +115,7 @@ public sealed class RoleService(BasicRepository rpo, IUserRoleSe public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req).WithNoLockNoWait().ToListAsync().ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().ToListAsync(req.GetToListExp() ?? (a => a)).ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgDeptService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgDeptService.cs index 94f79dda..a64bd867 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgDeptService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgDeptService.cs @@ -84,7 +84,12 @@ public sealed class SiteMsgDeptService(BasicRepository rp public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); + var list = await QueryInternal(req) + .Page(req.Page, req.PageSize) + .WithNoLockNoWait() + .Count(out var total) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -93,7 +98,11 @@ public sealed class SiteMsgDeptService(BasicRepository rp public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); + var ret = await QueryInternal(req) + .WithNoLockNoWait() + .Take(req.Count) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgFlagService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgFlagService.cs index 85518c8c..3aebeb8f 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgFlagService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgFlagService.cs @@ -84,7 +84,12 @@ public sealed class SiteMsgFlagService(BasicRepository rp public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); + var list = await QueryInternal(req) + .Page(req.Page, req.PageSize) + .WithNoLockNoWait() + .Count(out var total) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -93,7 +98,11 @@ public sealed class SiteMsgFlagService(BasicRepository rp public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); + var ret = await QueryInternal(req) + .WithNoLockNoWait() + .Take(req.Count) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgRoleService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgRoleService.cs index b1c2a931..c2f4b553 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgRoleService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgRoleService.cs @@ -84,7 +84,12 @@ public sealed class SiteMsgRoleService(BasicRepository rp public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); + var list = await QueryInternal(req) + .Page(req.Page, req.PageSize) + .WithNoLockNoWait() + .Count(out var total) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -93,7 +98,11 @@ public sealed class SiteMsgRoleService(BasicRepository rp public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); + var ret = await QueryInternal(req) + .WithNoLockNoWait() + .Take(req.Count) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgService.cs index c915078d..a329ad0e 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgService.cs @@ -170,7 +170,11 @@ public sealed class SiteMsgService(BasicRepository rpo, Conte public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); + var ret = await QueryInternal(req) + .WithNoLockNoWait() + .Take(req.Count) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgUserService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgUserService.cs index 0573235c..7a3dffde 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgUserService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgUserService.cs @@ -84,7 +84,12 @@ public sealed class SiteMsgUserService(BasicRepository rp public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); + var list = await QueryInternal(req) + .Page(req.Page, req.PageSize) + .WithNoLockNoWait() + .Count(out var total) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -93,7 +98,11 @@ public sealed class SiteMsgUserService(BasicRepository rp public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); + var ret = await QueryInternal(req) + .WithNoLockNoWait() + .Take(req.Count) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/UserRoleService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/UserRoleService.cs index d32a2a73..5aaf7bc4 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/UserRoleService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/UserRoleService.cs @@ -84,7 +84,12 @@ public sealed class UserRoleService(BasicRepository rpo) // public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); + var list = await QueryInternal(req) + .Page(req.Page, req.PageSize) + .WithNoLockNoWait() + .Count(out var total) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -93,7 +98,11 @@ public sealed class UserRoleService(BasicRepository rpo) // public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); + var ret = await QueryInternal(req) + .WithNoLockNoWait() + .Take(req.Count) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/VerifyCodeService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/VerifyCodeService.cs index 73985d27..e05500f3 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/VerifyCodeService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/VerifyCodeService.cs @@ -94,7 +94,12 @@ public sealed class VerifyCodeService(BasicRepository rpo, public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); + var list = await QueryInternal(req) + .Page(req.Page, req.PageSize) + .WithNoLockNoWait() + .Count(out var total) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -103,7 +108,11 @@ public sealed class VerifyCodeService(BasicRepository rpo, public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); + var ret = await QueryInternal(req) + .WithNoLockNoWait() + .Take(req.Count) + .ToListAsync(req.GetToListExp() ?? (a => a)) + .ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/frontend/admin/src/App.vue b/src/frontend/admin/src/App.vue index 4f7f61a5..e6525660 100644 --- a/src/frontend/admin/src/App.vue +++ b/src/frontend/admin/src/App.vue @@ -90,6 +90,36 @@ export default { // 设置语言 this.$i18n.locale = this.$TOOL.data.get('APP_SET_LANG') || this.$CONFIG.APP_SET_LANG + + //ctrl + enter 触发主按钮点击事件 + document.onkeydown = (e) => { + if (e.ctrlKey && e.keyCode === 13) { + document + .getElementsByClassName('el-dialog__footer')[0] + ?.getElementsByClassName('el-button--primary')[0] + ?.dispatchEvent( + new MouseEvent('click', { + view: window, + bubbles: true, + cancelable: false, + }), + ) + } + if (!e.altKey && !e.ctrlKey && !e.shiftKey) { + for (const el of document.getElementsByClassName('sc-contextmenu__menu')[0]?.getElementsByTagName('li') ?? []) { + if (el.getElementsByClassName('sc-contextmenu__suffix')[0]?.innerText === String.fromCharCode(e.keyCode)) { + el.dispatchEvent( + new MouseEvent('click', { + view: window, + bubbles: true, + cancelable: false, + }), + ) + break + } + } + } + } }, } diff --git a/src/frontend/admin/src/components/scTable/index.vue b/src/frontend/admin/src/components/scTable/index.vue index a60d6ede..85cb616b 100644 --- a/src/frontend/admin/src/components/scTable/index.vue +++ b/src/frontend/admin/src/components/scTable/index.vue @@ -174,10 +174,32 @@ :command="`${menu}^|^NotAny^|^${tool.getNestedProperty(current.row, menu) ?? ''}`" :title="$t('非其一')"> - - - - + + + + + - + @@ -211,7 +233,7 @@ export default { props: { vue: { type: Object }, contextMenus: { type: Array }, - contextOpers: { type: Array, default: ['copy', 'view', 'edit', 'del'] }, + contextOpers: { type: Array, default: ['copy', 'add', 'view', 'edit', 'del'] }, contextAdvs: { type: Array, default: [] }, tableName: { type: String, default: '' }, beforePost: { @@ -373,6 +395,10 @@ export default { await this.exportData() return } + if (command === 'add') { + this.vue.dialog.save = { mode: 'add' } + return + } if (command === 'edit') { this.vue.dialog.save = { mode: 'edit', row: { id: this.current.row.id } } return diff --git a/src/frontend/admin/src/views/sys/dic/list/index.vue b/src/frontend/admin/src/views/sys/dic/list/index.vue index 234ec481..e8e0df98 100644 --- a/src/frontend/admin/src/views/sys/dic/list/index.vue +++ b/src/frontend/admin/src/views/sys/dic/list/index.vue @@ -22,7 +22,7 @@ ], }, ]" - :label-width="6" + :label-width="8" @on-change="filterChange" ref="selectFilter"> diff --git a/src/frontend/admin/src/views/sys/doc/list/index.vue b/src/frontend/admin/src/views/sys/doc/list/index.vue index ddb89e09..bd982343 100644 --- a/src/frontend/admin/src/views/sys/doc/list/index.vue +++ b/src/frontend/admin/src/views/sys/doc/list/index.vue @@ -36,7 +36,7 @@ ], }, ]" - :label-width="6" + :label-width="8" @on-change="filterChange" ref="selectFilter">