From 3f5b4b159cde1ed8254c807ecc07b9d66302bfb9 Mon Sep 17 00:00:00 2001 From: suncaomei Date: Thu, 20 Feb 2025 01:30:31 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E6=B8=85=E7=90=86=E5=9C=A8=E7=BA=BF=E7=94=A8=E6=88=B7=E7=9A=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/OnlineUser/SysOnlineUserService.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Admin.NET/Admin.NET.Core/Service/OnlineUser/SysOnlineUserService.cs b/Admin.NET/Admin.NET.Core/Service/OnlineUser/SysOnlineUserService.cs index d2068f89..44a3da5b 100644 --- a/Admin.NET/Admin.NET.Core/Service/OnlineUser/SysOnlineUserService.cs +++ b/Admin.NET/Admin.NET.Core/Service/OnlineUser/SysOnlineUserService.cs @@ -119,14 +119,16 @@ public class SysOnlineUserService : IDynamicApiController, ITransient if (await _sysConfigService.GetConfigValueByCode(ConfigConst.SysSingleLogin)) return; // 相同账号最后登录的用户Id集合 - var onlineUserIds = await _sysOnlineUerRep.AsQueryable().GroupBy(u => u.UserId) + var onlineUserRecords = await _sysOnlineUerRep.AsQueryable() + .GroupBy(u => u.UserId) .Select(u => new { UserId = u.UserId, Count = SqlFunc.AggregateCount(u.UserId), Id = SqlFunc.AggregateMax(u.Id) }) - .ToListAsync(u => u.Id); + .ToListAsync(); + var onlineUserIds = onlineUserRecords.Select(x => x.Id).ToList(); // 无效登录用户集合 var offlineUsers = await _sysOnlineUerRep.AsQueryable().Where(u => !onlineUserIds.Contains(u.Id)).ToListAsync(); From abdab25e6e1ad0a07564de9d178e688b4f98b292 Mon Sep 17 00:00:00 2001 From: aq982 Date: Thu, 27 Feb 2025 09:53:22 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9(=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=AB=AF)=E6=8E=A5=E5=8F=A3=E6=9C=8D=E5=8A=A1=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=BB=9F=E8=AE=A1=E7=9A=84=E9=94=99=E8=AF=AF=EF=BC=8C?= =?UTF-8?q?=E6=9B=B4=E7=81=B5=E6=B4=BB=EF=BC=8C=E5=A2=9E=E5=8A=A0=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E7=BC=93=E5=AD=98=E5=92=8C=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wwwroot/template/service_Service.cs.vm | 56 ++++++++++++------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm index 22a284d8..faafa5af 100644 --- a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm +++ b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm @@ -36,18 +36,28 @@ namespace @Model.NameSpace; [ApiDescriptionSettings(@(@Model.ProjectLastName)Const.GroupName, Name = "@(@Model.LowerClassName)", Order = 100)] public partial class @(@Model.ClassName)Service : IDynamicApiController, ITransient { + private readonly SysCacheService _sysCacheService;//默认CacheService + private readonly UserManager _userManager;//默认用户管理 + private readonly IEventPublisher _eventPublisher;//默认事件总线 private readonly SqlSugarRepository<@(@Model.ClassName)> _@(@Model.LowerClassName)Rep; @foreach (var column in Model.TableField){ if(@column.EffectType == "ForeignKey"||@column.EffectType == "ApiTreeSelector"){ + if(@column.FkEntityName != @Model.ClassName){ @:private readonly SqlSugarRepository<@(@column.FkEntityName)> _@(@column.LowerFkEntityName)Rep; + } } } private TypeAdapterConfig _typeAdapterConfig = TypeAdapterConfig.GlobalSettings; public @(@Model.ClassName)Service(SqlSugarRepository<@(@Model.ClassName)> @(@Model.LowerClassName)Rep + ,SysCacheService sysCacheService + , UserManager userManager + ,IEventPublisher eventPublisher @foreach (var column in Model.TableField){ if(@column.EffectType == "ForeignKey"||@column.EffectType == "ApiTreeSelector"){ + if(@column.FkEntityName != @Model.ClassName){ @:,SqlSugarRepository<@(@column.FkEntityName)> @(@column.LowerFkEntityName)Rep + } } } @@ -56,10 +66,15 @@ public partial class @(@Model.ClassName)Service : IDynamicApiController, ITransi _@(@Model.LowerClassName)Rep = @(@Model.LowerClassName)Rep; @foreach (var column in Model.TableField){ if(@column.EffectType == "ForeignKey"||@column.EffectType == "ApiTreeSelector"){ + if(@column.FkEntityName != @Model.ClassName){ @:_@(@column.LowerFkEntityName)Rep = @(@column.LowerFkEntityName)Rep; + } } } _typeAdapterConfig.ForType().IgnoreNullValues(true); + _sysCacheService = sysCacheService; + _eventPublisher = eventPublisher; + _userManager = userManager; } /// @@ -168,28 +183,28 @@ if (@column.ColumnKey == "True"){ return await @(@Model.ClassName)Mid.GetQuery(_@(@Model.LowerClassName)Rep, input).OrderBuilder(input).ToListAsync(); } -@if(@Model.TableField.Any(x=>x.Statistical == "Y")){ - @:/// - @:/// 获取@(@Model.BusName) - @:/// - @:/// - @:/// - @:[ApiDescriptionSettings(Name = "GetTotalSum", Description = "获取@(@Model.BusName)统计", Order = 960), HttpPost] - @:[DisplayName("获取@(@Model.BusName)统计")] - @:public async Task> GetTotalSum(Page@(@Model.ClassName)Input input) - @:{ - @:// 单次查询同时获取统计值 - @:var querystats = @(@Model.ClassName)Mid.GetQuery(_@(@Model.LowerClassName)Rep, input) + /// + /// 获取@(@Model.BusName) + /// + /// + /// + [ApiDescriptionSettings(Name = "GetTotalSum", Description = "获取@(@Model.BusName)统计", Order = 960), HttpPost] + [DisplayName("获取@(@Model.BusName)统计")] + public async Task> GetTotalSum(Page@(@Model.ClassName)Input input) + { + // 单次查询同时获取统计值 + var querystats = @(@Model.ClassName)Mid.GetQuery(_@(@Model.LowerClassName)Rep, input) + @if(@Model.TableField.Any(x=>x.IsGroupBy == "Y")){ @foreach (var column in Model.TableField){ if (@column.IsGroupBy == "Y"){ @: .GroupByIF(input.GroupBy.Contains("@column.PropertyName"), u => u.@column.PropertyName) } } @: //.Having(it => SqlFunc.AggregateCount(it.Id) > 0)//聚合函数过滤 - @: .Select(it => new @(@Model.ClassName)Output - @: { - @: count = SqlFunc.AggregateCount(it.Id), - + } + .Select(it => new @(@Model.ClassName)Output + { + count = SqlFunc.AggregateCount(it.Id), @foreach (var column in Model.TableField){ if (@column.IsGroupBy == "Y"){ @: @(@column.PropertyName) = it.@(@column.PropertyName), @@ -198,10 +213,9 @@ if (@column.ColumnKey == "True"){ @: @(@column.PropertyName) = SqlFunc.AggregateSum(it.@(@column.PropertyName)) ?? 0, } } - @: }); - @:return await querystats.ToListAsync(); - @:} -} + }); + return await querystats.ToListAsync(); + } /// /// 根据输入参数获取@(@Model.BusName)统计 @@ -220,7 +234,7 @@ if (@column.ColumnKey == "True"){ public async Task> GetAggregTotalSum(Page@(@Model.ClassName)Input input) { - @:var query = @(@Model.ClassName)Mid.GetQuery(_@(@Model.LowerClassName)Rep, input) + var query = @(@Model.ClassName)Mid.GetQuery(_@(@Model.LowerClassName)Rep, input) // 输入参数示例 //input = new Page@(@Model.ClassName)Input //{ From 18f30c441b0209c1bfa75ee1b911bfbe648e1f38 Mon Sep 17 00:00:00 2001 From: aq982 Date: Thu, 27 Feb 2025 10:04:16 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9(=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=AB=AF)=E6=8E=A5=E5=8F=A3=E7=BB=9F=E8=AE=A1BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Admin.NET/Admin.NET.Core/Utils/AggregationBuilder.cs | 4 ++-- .../wwwroot/template/service_Service.cs.vm | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Admin.NET/Admin.NET.Core/Utils/AggregationBuilder.cs b/Admin.NET/Admin.NET.Core/Utils/AggregationBuilder.cs index 235346ac..87bfda5f 100644 --- a/Admin.NET/Admin.NET.Core/Utils/AggregationBuilder.cs +++ b/Admin.NET/Admin.NET.Core/Utils/AggregationBuilder.cs @@ -91,7 +91,7 @@ public class AggregationBuilder /// /// 验证字段有效性 /// - public static List ValidateFields(string[] fields, Type targetType) + public static List ValidateFields(string[] fields, Type targetType) { if (fields == null || fields.Length == 0) return new List(); @@ -99,7 +99,7 @@ public class AggregationBuilder .Where(f => !string.IsNullOrWhiteSpace(f)) .Select(f => f.Trim()) .Where(f => targetType.GetProperty( - targetType == typeof(UsagetokenOutput) ? + targetType == typeof(T) ? $"{f}Sum" : f) != null) .ToList(); } diff --git a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm index faafa5af..e0eb56c2 100644 --- a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm +++ b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm @@ -267,7 +267,7 @@ if (@column.ColumnKey == "True"){ // HAVING(SUM(cost) > 10000) AND(AVG(CAST(response_time AS FLOAT)) < 500) // 处理分组字段 - var groupFields = AggregationBuilder.ValidateFields(input.GroupBy, typeof(@(@Model.ClassName)Output)); + var groupFields = AggregationBuilder.ValidateFields<@(@Model.ClassName)Output>(input.GroupBy, typeof(@(@Model.ClassName)Output)); if (groupFields.Count > 0) { query = query.GroupBy(string.Join(",", groupFields)); From 3ab3a30998f308a9284b65ff26360fb7051fe009 Mon Sep 17 00:00:00 2001 From: aq982 Date: Thu, 27 Feb 2025 11:43:12 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E7=9A=84=E9=80=82=E7=94=A8=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wwwroot/template/service_Service.cs.vm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm index e0eb56c2..799b795d 100644 --- a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm +++ b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm @@ -26,7 +26,7 @@ using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; } } } -using @(@Model.NameSpace).Entity; +using Admin.NET.Core.Utils; namespace @Model.NameSpace; @@ -234,7 +234,7 @@ if (@column.ColumnKey == "True"){ public async Task> GetAggregTotalSum(Page@(@Model.ClassName)Input input) { - var query = @(@Model.ClassName)Mid.GetQuery(_@(@Model.LowerClassName)Rep, input) + var query = @(@Model.ClassName)Mid.GetQuery(_@(@Model.LowerClassName)Rep, input); // 输入参数示例 //input = new Page@(@Model.ClassName)Input //{ From 59504eed865caa957d1afb31fdc9c273fd626e18 Mon Sep 17 00:00:00 2001 From: aq982 Date: Thu, 27 Feb 2025 12:01:23 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=9A=84=E9=80=82=E7=94=A8=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Admin.NET/Admin.NET.Application/GlobalUsings.cs | 1 + Admin.NET/Admin.NET.Core/GlobalUsings.cs | 1 + .../Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Admin.NET/Admin.NET.Application/GlobalUsings.cs b/Admin.NET/Admin.NET.Application/GlobalUsings.cs index 7dd67391..240076ed 100644 --- a/Admin.NET/Admin.NET.Application/GlobalUsings.cs +++ b/Admin.NET/Admin.NET.Application/GlobalUsings.cs @@ -5,6 +5,7 @@ // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! global using Admin.NET.Core; +global using Admin.NET.Core.Utils; global using Furion; global using Furion.DependencyInjection; global using Furion.DynamicApiController; diff --git a/Admin.NET/Admin.NET.Core/GlobalUsings.cs b/Admin.NET/Admin.NET.Core/GlobalUsings.cs index 29633ba0..6e454d65 100644 --- a/Admin.NET/Admin.NET.Core/GlobalUsings.cs +++ b/Admin.NET/Admin.NET.Core/GlobalUsings.cs @@ -5,6 +5,7 @@ // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! global using Admin.NET.Core.Service; +global using Admin.NET.Core.Utils; global using Furion; global using Furion.ConfigurableOptions; global using Furion.DatabaseAccessor; diff --git a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm index 799b795d..084ab550 100644 --- a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm +++ b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm @@ -26,7 +26,6 @@ using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; } } } -using Admin.NET.Core.Utils; namespace @Model.NameSpace; From 0853907b8da6cde36ee8052b4d793b02dda9edfe Mon Sep 17 00:00:00 2001 From: aq982 Date: Thu, 27 Feb 2025 12:40:37 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9list=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin.NET.Web.Entry/wwwroot/template/web_views_List.vue.vm | 1 - 1 file changed, 1 deletion(-) diff --git a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/web_views_List.vue.vm b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/web_views_List.vue.vm index db8effb6..4e25d530 100644 --- a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/web_views_List.vue.vm +++ b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/web_views_List.vue.vm @@ -401,7 +401,6 @@ const handleQuery = async (reset = false) => { @if(@Model.TableField.Any(x=>x.Statistical == "Y")){ @if (@Model.IsApiService) { @:state.totalSum =getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)GetTotalSumPost(params).data.result; - } } else { @:state.totalSum =(await get@(@Model.ClassName)TotalSum(state.queryParams)).data.result; } From f8a1ae41f85dc496d8b2a250919a0934d2af5dbc Mon Sep 17 00:00:00 2001 From: suncaomei Date: Thu, 27 Feb 2025 13:09:46 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dedit=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wwwroot/template/web_views_editDialog.vue.vm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/web_views_editDialog.vue.vm b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/web_views_editDialog.vue.vm index 80f207a8..d131a524 100644 --- a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/web_views_editDialog.vue.vm +++ b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/web_views_editDialog.vue.vm @@ -91,7 +91,7 @@ @: @: @: - @: + @: @@ -142,7 +142,7 @@ @: @: @: - @: + @: