😎代码清理

This commit is contained in:
zuohuaijun 2025-02-27 16:27:16 +08:00
parent 2c607ae49b
commit c8d6d7ce1e
6 changed files with 46 additions and 39 deletions

View File

@ -20,9 +20,9 @@
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
<PackageReference Include="BouncyCastle.Cryptography" Version="2.5.1" Aliases="BouncyCastleV2" />
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.17.1" />
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.7.13" />
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.7.13" />
<PackageReference Include="Furion.Pure" Version="4.9.7.13" />
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.7.15" />
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.7.15" />
<PackageReference Include="Furion.Pure" Version="4.9.7.15" />
<PackageReference Include="Hardware.Info" Version="101.0.1" />
<PackageReference Include="Hashids.net" Version="1.7.0" />
<PackageReference Include="IPTools.China" Version="1.6.0" />
@ -40,15 +40,15 @@
<PackageReference Include="Novell.Directory.Ldap.NETStandard" Version="3.6.0" />
<PackageReference Include="OnceMi.AspNetCore.OSS" Version="1.2.0" />
<PackageReference Include="QRCoder" Version="1.6.0" />
<PackageReference Include="RabbitMQ.Client" Version="7.1.0" />
<PackageReference Include="RabbitMQ.Client" Version="7.1.1" />
<PackageReference Include="SixLabors.ImageSharp.Web" Version="3.1.3" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="3.7.0" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.10.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.178" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.179" />
<PackageReference Include="SSH.NET" Version="2024.2.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.6.0.2" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1186" />
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1188" />
<PackageReference Include="UAParser" Version="3.1.47" />
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
</ItemGroup>

View File

@ -110,9 +110,9 @@ public partial class SysCodeGenConfig : EntityBase
public string? DictTypeCode { get; set; }
/// <summary>
/// 列表是否缩进(字典)
/// 是否缩进列表(字典)
/// </summary>
[SugarColumn(ColumnDescription = "列表是否缩进", Length = 8)]
[SugarColumn(ColumnDescription = "是否缩进列表", Length = 8)]
[MaxLength(8)]
public string? WhetherRetract { get; set; }
@ -136,10 +136,11 @@ public partial class SysCodeGenConfig : EntityBase
[SugarColumn(ColumnDescription = "是否是统计字段", Length = 8)]
[MaxLength(8)]
public string? Statistical { get; set; }
/// <summary>
/// 是否是GroupBy字段
/// 是否是分组字段
/// </summary>
[SugarColumn(ColumnDescription = "是否是GroupBy字段", Length = 8)]
[SugarColumn(ColumnDescription = "是否是分组字段", Length = 8)]
[MaxLength(8)]
public string? IsGroupBy { get; set; }

View File

@ -122,6 +122,7 @@ public class CodeGenConfig
/// 是否是统计字段
/// </summary>
public string Statistical { get; set; }
/// <summary>
/// 是否是GroupBy字段
/// </summary>

View File

@ -1,24 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
namespace Admin.NET.Core.Utils;
// 聚合配置增强版(独立类)
/// <summary>
/// 聚合配置增强版(独立类)
/// </summary>
public class AggregationBuilder
{
private readonly List<AggregationConfig> _configs;
private readonly Type _entityType;
private readonly Type _outputType;
public List<string> SelectParts { get; } = new();
public List<string> HavingConditions { get; } = new();
public List<string> SelectParts { get; } = [];
public List<string> HavingConditions { get; } = [];
public AggregationBuilder(
IEnumerable<AggregationConfig> configs,
Type entityType,
Type outputType)
public AggregationBuilder(IEnumerable<AggregationConfig> configs, Type entityType, Type outputType)
{
_configs = configs.ToList();
_entityType = entityType;
@ -55,10 +55,11 @@ public class AggregationBuilder
// 输出属性验证
return _outputType.GetProperty(config.Alias) != null;
}
/// <summary>
/// 验证聚合配置有效性
/// </summary>
private bool ValidateAggregation(AggregationConfig config, Type entityType, Type outputType)
private static bool ValidateAggregation(AggregationConfig config, Type entityType, Type outputType)
{
// 验证实体字段存在性
var entityProp = entityType.GetProperty(config.Field);
@ -88,24 +89,24 @@ public class AggregationBuilder
_ => false
};
}
/// <summary>
/// 验证字段有效性
/// </summary>
public static List<string> ValidateFields<T>(string[] fields, Type targetType)
{
if (fields == null || fields.Length == 0) return new List<string>();
if (fields == null || fields.Length == 0) return [];
return fields
.Where(f => !string.IsNullOrWhiteSpace(f))
.Select(f => f.Trim())
.Where(f => targetType.GetProperty(
targetType == typeof(T) ?
$"{f}Sum" : f) != null)
return fields.Where(u => !string.IsNullOrWhiteSpace(u))
.Select(u => u.Trim())
.Where(u => targetType.GetProperty(targetType == typeof(T) ? $"{u}Sum" : u) != null)
.ToList();
}
}
// 增强版聚合配置类
/// <summary>
/// 增强版聚合配置类
/// </summary>
public class AggregationConfig
{
/// <summary>
@ -126,13 +127,17 @@ public class AggregationConfig
/// <summary>
/// 输出字段别名必须与DTO属性名一致
/// </summary>
public required string Alias { get; set; }
public string Alias { get; set; }
/// <summary>
/// HAVING条件表达式如"> 100"
/// </summary>
public string HavingCondition { get; set; }
}
/// <summary>
/// 函数枚举
/// </summary>
public enum AggregateFunction
{
Sum,
@ -141,4 +146,4 @@ public enum AggregateFunction
Max,
Min,
// 可扩展其他函数
}
}

View File

@ -2,7 +2,7 @@
"name": "admin.net.pro",
"type": "module",
"version": "2.4.33",
"lastBuildTime": "2025.02.25",
"lastBuildTime": "2025.02.27",
"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
"author": "zuohuaijun",
"license": "MIT",
@ -29,7 +29,7 @@
"@wangeditor/editor-for-vue": "^5.1.12",
"animate.css": "^4.1.1",
"async-validator": "^4.2.5",
"axios": "^1.7.9",
"axios": "^1.8.1",
"countup.js": "^2.8.0",
"cropperjs": "^1.6.2",
"crypto-js": "^4.2.0",
@ -48,7 +48,7 @@
"md-editor-v3": "^5.3.2",
"mitt": "^3.0.1",
"monaco-editor": "^0.52.2",
"mqtt": "^5.10.3",
"mqtt": "^5.10.4",
"nprogress": "^0.2.0",
"ol": "^10.4.0",
"pinia": "^3.0.1",
@ -74,7 +74,7 @@
"vue-router": "^4.5.0",
"vue-signature-pad": "^3.0.2",
"vue3-tree-org": "^4.2.2",
"vxe-pc-ui": "^4.3.95",
"vxe-pc-ui": "^4.3.98",
"vxe-table": "^4.10.0",
"vxe-table-plugin-element": "^4.0.4",
"vxe-table-plugin-export-xlsx": "^4.0.7",

View File

@ -39,8 +39,8 @@
<vxe-switch v-model="row.statistical" open-label="是" close-label="否" :openValue="true" :closeValue="false"></vxe-switch>
</template>
<template #isGroupBy="{ row }">
<vxe-switch v-model="row.isGroupBy" open-label="是" close-label="否" :openValue="true" :closeValue="false"></vxe-switch>
</template>
<vxe-switch v-model="row.isGroupBy" open-label="是" close-label="否" :openValue="true" :closeValue="false"></vxe-switch>
</template>
<template #queryWhether="{ row }">
<vxe-switch v-model="row.queryWhether" open-label="是" close-label="否" :openValue="true" :closeValue="false"></vxe-switch>
</template>