From be7cd177d1f295c0e11c77256338d53b69e352c2 Mon Sep 17 00:00:00 2001 From: zuohuaijun Date: Sun, 28 Sep 2025 11:59:46 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=8E1=E3=80=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=9F=A5=E8=AF=A2=20=20=202?= =?UTF-8?q?=E3=80=81=E5=8D=87=E7=BA=A7=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin.NET.Core/Admin.NET.Core.csproj | 14 +- .../Attribute/RequiredIFAttribute.cs | 5 +- .../DataBase/Dto/CreateSeedDataInput.cs | 96 +- .../Service/DataBase/Dto/GenerateSQLInput.cs | 36 +- .../Service/DataBase/GenerateSQL.cs | 275 ++++++ .../Service/DataBase/SysDatabaseService.cs | 54 +- .../Admin.NET.Test/Admin.NET.Test.csproj | 4 +- Admin.NET/Admin.NET.sln | 2 +- Web/package.json | 16 +- .../system/models/generate-sqlinput.ts | 25 +- Web/src/api-services/system/models/index.ts | 8 +- .../system/models/join-config-table-column.ts | 34 + .../api-services/system/models/join-config.ts | 47 + .../models/{orders-sql.ts => order-config.ts} | 10 +- .../{columns-sql.ts => select-config.ts} | 8 +- .../{conditions-sql.ts => where-config.ts} | 24 +- .../views/system/reportCustomQuery/index.vue | 839 ++++++++++++------ 17 files changed, 1090 insertions(+), 407 deletions(-) create mode 100644 Admin.NET/Admin.NET.Core/Service/DataBase/GenerateSQL.cs create mode 100644 Web/src/api-services/system/models/join-config-table-column.ts create mode 100644 Web/src/api-services/system/models/join-config.ts rename Web/src/api-services/system/models/{orders-sql.ts => order-config.ts} (86%) rename Web/src/api-services/system/models/{columns-sql.ts => select-config.ts} (88%) rename Web/src/api-services/system/models/{conditions-sql.ts => where-config.ts} (73%) diff --git a/Admin.NET/Admin.NET.Core/Admin.NET.Core.csproj b/Admin.NET/Admin.NET.Core/Admin.NET.Core.csproj index 11f59527..85636837 100644 --- a/Admin.NET/Admin.NET.Core/Admin.NET.Core.csproj +++ b/Admin.NET/Admin.NET.Core/Admin.NET.Core.csproj @@ -21,16 +21,16 @@ - + - - - - + + + + @@ -51,9 +51,9 @@ - + - + diff --git a/Admin.NET/Admin.NET.Core/Attribute/RequiredIFAttribute.cs b/Admin.NET/Admin.NET.Core/Attribute/RequiredIFAttribute.cs index a71b7076..23d1eaca 100644 --- a/Admin.NET/Admin.NET.Core/Attribute/RequiredIFAttribute.cs +++ b/Admin.NET/Admin.NET.Core/Attribute/RequiredIFAttribute.cs @@ -78,8 +78,9 @@ public sealed class RequiredIFAttribute( /// /// 判断是否需要进行验证 /// - /// 依赖属性的值 - /// 是否需要验证 + /// + /// + /// private bool ShouldValidate(object targetValue, DictAttribute dictAttr) { switch (Comparison) diff --git a/Admin.NET/Admin.NET.Core/Service/DataBase/Dto/CreateSeedDataInput.cs b/Admin.NET/Admin.NET.Core/Service/DataBase/Dto/CreateSeedDataInput.cs index d65ed3b7..ec535f81 100644 --- a/Admin.NET/Admin.NET.Core/Service/DataBase/Dto/CreateSeedDataInput.cs +++ b/Admin.NET/Admin.NET.Core/Service/DataBase/Dto/CreateSeedDataInput.cs @@ -1,49 +1,49 @@ -// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 -// -// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 -// -// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! - -namespace Admin.NET.Core.Service; - -public class CreateSeedDataInput -{ - /// - /// 库标识 - /// - public string ConfigId { get; set; } - - /// - /// 表名 - /// - public string TableName { get; set; } - - /// - /// 实体名称 - /// - public string EntityName { get; set; } - - /// - /// 种子名称 - /// - public string SeedDataName { get; set; } - - /// - /// 导出位置 - /// - public string Position { get; set; } - - /// - /// 后缀 - /// - public string Suffix { get; set; } - - /// - /// 过滤已有数据 - /// - /// - /// 如果数据在其它不同名的已有的种子类型的数据中出现过,就不生成这个数据。 - /// 主要用于生成菜单功能,菜单功能往往与子项目绑定,如果生成完整数据就会导致菜单项多处理重复。 - /// - public bool FilterExistingData { get; set; } +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +namespace Admin.NET.Core.Service; + +public class CreateSeedDataInput +{ + /// + /// 库标识 + /// + public string ConfigId { get; set; } + + /// + /// 表名 + /// + public string TableName { get; set; } + + /// + /// 实体名称 + /// + public string EntityName { get; set; } + + /// + /// 种子名称 + /// + public string SeedDataName { get; set; } + + /// + /// 导出位置 + /// + public string Position { get; set; } + + /// + /// 后缀 + /// + public string Suffix { get; set; } + + /// + /// 过滤已有数据 + /// + /// + /// 如果数据在其它不同名的已有的种子类型的数据中出现过,就不生成这个数据。 + /// 主要用于生成菜单功能,菜单功能往往与子项目绑定,如果生成完整数据就会导致菜单项多处理重复。 + /// + public bool FilterExistingData { get; set; } } \ No newline at end of file diff --git a/Admin.NET/Admin.NET.Core/Service/DataBase/Dto/GenerateSQLInput.cs b/Admin.NET/Admin.NET.Core/Service/DataBase/Dto/GenerateSQLInput.cs index e17737fb..0b4c507c 100644 --- a/Admin.NET/Admin.NET.Core/Service/DataBase/Dto/GenerateSQLInput.cs +++ b/Admin.NET/Admin.NET.Core/Service/DataBase/Dto/GenerateSQLInput.cs @@ -8,21 +8,41 @@ namespace Admin.NET.Core.Service; public class GenerateSQLInput { - public List Columns { get; set; } + public List SelectConfigs { get; set; } - public List Conditions { get; set; } + public List JoinConfigs { get; set; } - public List Orders { get; set; } + public List WhereConfigs { get; set; } + + public List OrderConfigs { get; set; } } -public class ColumnsSQL +public class SelectConfig { public string Table { get; set; } public string Column { get; set; } } -public class ConditionsSQL +public class JoinConfig +{ + public string JoinType { get; set; } + + public string LeftTable { get; set; } + + public string RightTable { get; set; } + + public List TableColumns { get; set; } +} + +public class JoinConfig_TableColumn +{ + public string LeftTableColumn { get; set; } + + public string RightTableColumn { get; set; } +} + +public class WhereConfig { public string Table { get; set; } @@ -31,9 +51,13 @@ public class ConditionsSQL public string Operator { get; set; } public string Value { get; set; } + + public string DataType { get; set; } + + public string JoinType { get; set; } } -public class OrdersSQL +public class OrderConfig { public string Table { get; set; } diff --git a/Admin.NET/Admin.NET.Core/Service/DataBase/GenerateSQL.cs b/Admin.NET/Admin.NET.Core/Service/DataBase/GenerateSQL.cs new file mode 100644 index 00000000..9ab44816 --- /dev/null +++ b/Admin.NET/Admin.NET.Core/Service/DataBase/GenerateSQL.cs @@ -0,0 +1,275 @@ +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +namespace Admin.NET.Core.Service; + +public static class BuildSQL +{ + public static string Build(GenerateSQLInput config) + { + if (config.SelectConfigs == null || !config.SelectConfigs.Any()) + throw new ArgumentException("至少需要一个选择配置"); + + StringBuilder sql = new StringBuilder(); + + // SELECT clause + sql.Append("SELECT "); + sql.Append(string.Join(", ", config.SelectConfigs.Select(sc => + $"{sc.Table}.{sc.Column}"))); + sql.AppendLine(); + + // 确定主表(出现频率最高的表) + var mainTable = DetermineMainTable(config); + sql.AppendLine($"FROM {mainTable}"); + + // 收集所有涉及的表 + var allTables = CollectAllTables(config); + var joinedTables = new HashSet(StringComparer.OrdinalIgnoreCase) { mainTable }; + + // 处理JOIN关系 - 优化后的逻辑 + ProcessJoins(sql, config.JoinConfigs, joinedTables, allTables); + + // 添加剩余未连接的表(使用CROSS JOIN) + AddRemainingTables(sql, allTables, joinedTables); + + // WHERE子句 + ProcessWhereClause(sql, config.WhereConfigs); + + // ORDER BY子句 + ProcessOrderByClause(sql, config.OrderConfigs); + + return sql.ToString(); + } + + private static string DetermineMainTable(GenerateSQLInput config) + { + // 统计所有表出现的频率 + var tableFrequency = new Dictionary(StringComparer.OrdinalIgnoreCase); + + // 统计SELECT中的表 + foreach (var sc in config.SelectConfigs) + { + if (tableFrequency.ContainsKey(sc.Table)) + tableFrequency[sc.Table]++; + else + tableFrequency[sc.Table] = 1; + } + + // 统计JOIN中的表 + foreach (var jc in config.JoinConfigs) + { + if (tableFrequency.ContainsKey(jc.LeftTable)) + tableFrequency[jc.LeftTable]++; + else + tableFrequency[jc.LeftTable] = 1; + + if (tableFrequency.ContainsKey(jc.RightTable)) + tableFrequency[jc.RightTable]++; + else + tableFrequency[jc.RightTable] = 1; + } + + // 统计WHERE中的表 + foreach (var wc in config.WhereConfigs) + { + if (tableFrequency.ContainsKey(wc.Table)) + tableFrequency[wc.Table]++; + else + tableFrequency[wc.Table] = 1; + } + + // 统计ORDER BY中的表 + foreach (var oc in config.OrderConfigs) + { + if (tableFrequency.ContainsKey(oc.Table)) + tableFrequency[oc.Table]++; + else + tableFrequency[oc.Table] = 1; + } + + // 选择出现频率最高的表作为主表 + return tableFrequency.OrderByDescending(kv => kv.Value) + .ThenBy(kv => kv.Key) + .FirstOrDefault().Key; + } + + private static HashSet CollectAllTables(GenerateSQLInput config) + { + var allTables = new HashSet(StringComparer.OrdinalIgnoreCase); + + config.SelectConfigs?.ForEach(sc => allTables.Add(sc.Table)); + config.JoinConfigs?.ForEach(jc => + { + allTables.Add(jc.LeftTable); + allTables.Add(jc.RightTable); + }); + config.WhereConfigs?.ForEach(wc => allTables.Add(wc.Table)); + config.OrderConfigs?.ForEach(oc => allTables.Add(oc.Table)); + + return allTables; + } + + private static void ProcessJoins(StringBuilder sql, List joinConfigs, + HashSet joinedTables, HashSet allTables) + { + if (joinConfigs == null) return; + + // 使用队列处理所有JOIN关系 + var joinQueue = new Queue(joinConfigs); + var processedJoins = new HashSet(); + bool progressMade; + + do + { + progressMade = false; + var currentQueue = new Queue(joinQueue); + joinQueue.Clear(); + + while (currentQueue.Count > 0) + { + var join = currentQueue.Dequeue(); + + // 如果右表已经连接,跳过 + if (joinedTables.Contains(join.RightTable)) + { + processedJoins.Add(join); + continue; + } + + // 如果左表已连接,可以处理这个JOIN + if (joinedTables.Contains(join.LeftTable)) + { + // 构建ON条件 + var onConditions = join.TableColumns.Select(tc => + $"{join.LeftTable}.{tc.LeftTableColumn} = " + + $"{join.RightTable}.{tc.RightTableColumn}"); + + sql.AppendLine($"{join.JoinType} {join.RightTable} ON {string.Join(" AND ", onConditions)}"); + joinedTables.Add(join.RightTable); + processedJoins.Add(join); + progressMade = true; + } + else + { + // 左表未连接,放回队列稍后处理 + joinQueue.Enqueue(join); + } + } + + // 如果还有未处理的JOIN但队列未变化,尝试添加缺失的表 + if (!progressMade && joinQueue.Count > 0) + { + var nextJoin = joinQueue.Peek(); + + // 如果左表不在已连接表中,尝试添加它 + if (!joinedTables.Contains(nextJoin.LeftTable) && allTables.Contains(nextJoin.LeftTable)) + { + sql.AppendLine($", {nextJoin.LeftTable}"); + joinedTables.Add(nextJoin.LeftTable); + progressMade = true; + } + } + } + while (progressMade && joinQueue.Count > 0); + + // 处理剩余无法连接的JOIN + foreach (var join in joinQueue) + { + // 如果右表已经连接,跳过 + if (joinedTables.Contains(join.RightTable)) continue; + + // 尝试添加左表 + if (!joinedTables.Contains(join.LeftTable)) + { + sql.AppendLine($", {join.LeftTable}"); + joinedTables.Add(join.LeftTable); + } + + // 构建ON条件 + var onConditions = join.TableColumns.Select(tc => + $"{join.LeftTable}.{tc.LeftTableColumn} = " + + $"{join.RightTable}.{tc.RightTableColumn}"); + + sql.AppendLine($"{join.JoinType} {join.RightTable} ON {string.Join(" AND ", onConditions)}"); + joinedTables.Add(join.RightTable); + } + } + + private static void AddRemainingTables(StringBuilder sql, HashSet allTables, HashSet joinedTables) + { + var remainingTables = allTables.Except(joinedTables, StringComparer.OrdinalIgnoreCase).ToList(); + if (!remainingTables.Any()) return; + + foreach (var table in remainingTables) + { + sql.AppendLine($", {table}"); + joinedTables.Add(table); + } + } + + private static void ProcessWhereClause(StringBuilder sql, List whereConfigs) + { + if (whereConfigs == null || !whereConfigs.Any()) return; + + sql.Append("WHERE "); + foreach (var where in whereConfigs) + { + string formattedValue = FormatValue(where.Value, where.DataType, where.Operator); + sql.Append($"{where.Table}.{where.Column} " + $"{where.Operator} {formattedValue} {where.JoinType} "); + } + + // 移除最后一个逻辑运算符 + sql.Length -= 4; + sql.AppendLine(); + } + + private static void ProcessOrderByClause(StringBuilder sql, List orderConfigs) + { + if (orderConfigs == null || !orderConfigs.Any()) return; + + sql.Append("ORDER BY "); + sql.Append(string.Join(", ", orderConfigs.OrderBy(oc => oc.Sort).Select(oc => $"{oc.Table}.{oc.Column}"))); + } + + /// + /// WHERE 数值格式化 + /// + /// + /// + /// + /// + private static string FormatValue(object value, string dataType, string operatorType) + { + if (value == null) return "NULL"; + + string valueStr = value.ToString(); + if (string.IsNullOrWhiteSpace(valueStr)) return "NULL"; + + // 根据数据类型和操作符格式化值 + if (dataType?.ToLower().Contains("varchar") == true || + dataType?.ToLower().Contains("text") == true || + dataType?.ToLower().Contains("bool") == true || + dataType?.ToLower().Contains("datetime") == true || + dataType?.ToLower().Contains("timestamp") == true || + value is string) + { + // 对于LIKE操作符,添加通配符 + if (operatorType?.ToUpper() == "LIKE") + { + return $"'%{valueStr}%'"; + } + else + { + return $"'{valueStr}'"; + } + } + else + { + // 数字类型直接返回 + return valueStr; + } + } +} \ No newline at end of file diff --git a/Admin.NET/Admin.NET.Core/Service/DataBase/SysDatabaseService.cs b/Admin.NET/Admin.NET.Core/Service/DataBase/SysDatabaseService.cs index c5cfe322..db882b3d 100644 --- a/Admin.NET/Admin.NET.Core/Service/DataBase/SysDatabaseService.cs +++ b/Admin.NET/Admin.NET.Core/Service/DataBase/SysDatabaseService.cs @@ -631,54 +631,7 @@ public class SysDatabaseService : IDynamicApiController, ITransient [DisplayName("生成SQL语句")] public async Task GenerateSQL(GenerateSQLInput input) { - if (input.Columns == null || input.Columns.Count <= 0) throw Oops.Oh("至少需要设置一个列"); - - // 收集所有表名(从columns、conditions、orders中) - var tableNames = new HashSet(); - foreach (var col in input.Columns) - tableNames.Add(col.Table); - foreach (var cond in input.Conditions) - tableNames.Add(cond.Table); - foreach (var ord in input.Orders) - tableNames.Add(ord.Table); - if (tableNames == null || tableNames.Count == 0) - throw Oops.Oh("至少需要一个表"); - - // 构建 SELECT 子句 - var selectItems = input.Columns.Select(u => $"{u.Table}.{u.Column}"); - var selectString = "SELECT " + string.Join(", ", selectItems); - - // 构建 FROM 子句 - var fromString = "FROM " + string.Join(", ", tableNames); - - // 组合SQL语句 - var sql = new StringBuilder(); - sql.Append(selectString); - sql.Append(" "); - sql.Append(fromString); - if (input.Conditions != null && input.Conditions.Count > 0) - { - // 构建WHERE子句 - var whereConditions = input.Conditions.Where(u => !string.IsNullOrWhiteSpace(u.Table) && !string.IsNullOrWhiteSpace(u.Column)).Select(u => - { - var valueStr = u.Value is string ? $"'{u.Value}'" : u.Value.ToString(); // 处理值:如果是字符串则需要加单引号 - return $"{u.Table}.{u.Column} {u.Operator} {valueStr}"; - }); - var whereString = "WHERE " + string.Join(" AND ", whereConditions); - - sql.Append(" "); - sql.Append(whereString); - } - if (input.Orders != null && input.Orders.Count > 0) - { - // 构建 ORDER BY 子句 - var orderItems = input.Orders.OrderBy(u => u.Sort).Where(u => !string.IsNullOrWhiteSpace(u.Table) && !string.IsNullOrWhiteSpace(u.Column)).Select(u => $"{u.Table}.{u.Column} ASC"); // 按照sort值从小到大排序,确定列的先后顺序 - var orderByString = "ORDER BY " + string.Join(", ", orderItems); - - sql.Append(" "); - sql.Append(orderByString); - } - return await Task.FromResult(sql.ToString()); + return await Task.FromResult(BuildSQL.Build(input)); } /// @@ -690,7 +643,10 @@ public class SysDatabaseService : IDynamicApiController, ITransient public async Task ExecuteSQL(GenerateSQLInput input) { var sql = await GenerateSQL(input); - var dt = _db.Ado.GetDataTable(sql); + if (Regex.IsMatch(sql, @"\b(delete|update)\b", RegexOptions.IgnoreCase)) + throw Oops.Oh("非法SQL语句,已停止执行"); + + var dt = await _db.Ado.GetDataTableAsync(sql); return dt; } } \ No newline at end of file diff --git a/Admin.NET/Admin.NET.Test/Admin.NET.Test.csproj b/Admin.NET/Admin.NET.Test/Admin.NET.Test.csproj index 75b31960..3752e30b 100644 --- a/Admin.NET/Admin.NET.Test/Admin.NET.Test.csproj +++ b/Admin.NET/Admin.NET.Test/Admin.NET.Test.csproj @@ -14,8 +14,8 @@ - - + + compile diff --git a/Admin.NET/Admin.NET.sln b/Admin.NET/Admin.NET.sln index a7cc8391..9737a138 100644 --- a/Admin.NET/Admin.NET.sln +++ b/Admin.NET/Admin.NET.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.14.36511.14 d17.14 +VisualStudioVersion = 17.14.36511.14 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Admin.NET.Application", "Admin.NET.Application\Admin.NET.Application.csproj", "{C3F5AEC5-ACEE-4109-94E3-3F981DC18268}" EndProject diff --git a/Web/package.json b/Web/package.json index 8de4972e..5e482295 100644 --- a/Web/package.json +++ b/Web/package.json @@ -2,7 +2,7 @@ "name": "admin.net.pro", "type": "module", "version": "2.4.33", - "lastBuildTime": "2025.09.23", + "lastBuildTime": "2025.09.28", "description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架", "author": "zuohuaijun", "license": "MIT", @@ -21,7 +21,7 @@ "dependencies": { "@element-plus/icons-vue": "^2.3.2", "@logicflow/core": "^2.1.2", - "@logicflow/extension": "^2.1.3", + "@logicflow/extension": "^2.1.4", "@microsoft/signalr": "^9.0.6", "@vue-office/docx": "^1.6.3", "@vue-office/excel": "^1.7.14", @@ -39,7 +39,7 @@ "cropperjs": "^1.6.2", "crypto-js": "^4.2.0", "echarts": "^6.0.0", - "element-plus": "^2.11.3", + "element-plus": "^2.11.4", "exceljs": "^4.4.0", "flag-icons": "^7.5.0", "franc": "^6.2.0", @@ -69,7 +69,7 @@ "uuid": "^13.0.0", "vcrontab-3": "^3.3.22", "vform3-builds": "^3.0.10", - "vue": "^3.5.21", + "vue": "^3.5.22", "vue-clipboard3": "^2.0.0", "vue-demi": "0.14.10", "vue-draggable-plus": "^0.6.0", @@ -81,8 +81,8 @@ "vue-router": "^4.5.1", "vue-signature-pad": "^3.0.2", "vue3-tree-org": "^4.2.2", - "vxe-pc-ui": "^4.9.34", - "vxe-table": "^4.16.18", + "vxe-pc-ui": "^4.9.38", + "vxe-table": "^4.16.20", "xe-utils": "^3.7.9", "xlsx-js-style": "^1.2.0" }, @@ -97,7 +97,7 @@ "@typescript-eslint/parser": "^8.44.1", "@vitejs/plugin-vue": "^6.0.1", "@vitejs/plugin-vue-jsx": "^5.1.1", - "@vue/compiler-sfc": "^3.5.21", + "@vue/compiler-sfc": "^3.5.22", "cli-progress": "^3.12.0", "code-inspector-plugin": "^1.2.10", "colors": "^1.4.0", @@ -108,7 +108,7 @@ "less": "^4.4.1", "prettier": "^3.6.2", "rollup-plugin-visualizer": "^6.0.3", - "sass": "^1.93.1", + "sass": "^1.93.2", "terser": "^5.44.0", "typescript": "^5.9.2", "vite": "^7.1.7", diff --git a/Web/src/api-services/system/models/generate-sqlinput.ts b/Web/src/api-services/system/models/generate-sqlinput.ts index 0fb63923..61993b18 100644 --- a/Web/src/api-services/system/models/generate-sqlinput.ts +++ b/Web/src/api-services/system/models/generate-sqlinput.ts @@ -12,9 +12,10 @@ * Do not edit the class manually. */ -import { ColumnsSQL } from './columns-sql'; -import { ConditionsSQL } from './conditions-sql'; -import { OrdersSQL } from './orders-sql'; +import { JoinConfig } from './join-config'; +import { OrderConfig } from './order-config'; +import { SelectConfig } from './select-config'; +import { WhereConfig } from './where-config'; /** * * @@ -24,20 +25,26 @@ import { OrdersSQL } from './orders-sql'; export interface GenerateSQLInput { /** - * @type {Array} + * @type {Array} * @memberof GenerateSQLInput */ - columns?: Array | null; + selectConfigs?: Array | null; /** - * @type {Array} + * @type {Array} * @memberof GenerateSQLInput */ - conditions?: Array | null; + joinConfigs?: Array | null; /** - * @type {Array} + * @type {Array} * @memberof GenerateSQLInput */ - orders?: Array | null; + whereConfigs?: Array | null; + + /** + * @type {Array} + * @memberof GenerateSQLInput + */ + orderConfigs?: Array | null; } diff --git a/Web/src/api-services/system/models/index.ts b/Web/src/api-services/system/models/index.ts index 6c27238f..527fd0c2 100644 --- a/Web/src/api-services/system/models/index.ts +++ b/Web/src/api-services/system/models/index.ts @@ -188,9 +188,7 @@ export * from './code-gen-scene-enum'; export * from './column-custom-output'; export * from './column-output'; export * from './column-relation'; -export * from './columns-sql'; export * from './compare-info'; -export * from './conditions-sql'; export * from './const-output'; export * from './constructor-info'; export * from './copy-role-input'; @@ -308,6 +306,8 @@ export * from './job-create-type-enum'; export * from './job-detail-input'; export * from './job-detail-output'; export * from './job-trigger-input'; +export * from './join-config'; +export * from './join-config-table-column'; export * from './key-value-pair-string-string'; export * from './llmmodel-input'; export * from './layout-kind'; @@ -355,7 +355,7 @@ export * from './oauth-user-output'; export * from './online-user'; export * from './open-access-output'; export * from './order-by-type'; -export * from './orders-sql'; +export * from './order-config'; export * from './page-code-gen-input'; export * from './page-config-input'; export * from './page-dict-data-input'; @@ -427,6 +427,7 @@ export * from './schema-serialization-mode'; export * from './search'; export * from './security-rule-set'; export * from './seed-type'; +export * from './select-config'; export * from './select-list-group'; export * from './select-list-item'; export * from './send-subscribe-message-input'; @@ -579,6 +580,7 @@ export * from './wechat-pay-para-input'; export * from './wechat-pay-para-output'; export * from './wechat-pay-transaction-input'; export * from './wechat-user-login'; +export * from './where-config'; export * from './wx-open-id-login-input'; export * from './wx-open-id-output'; export * from './wx-phone-output'; diff --git a/Web/src/api-services/system/models/join-config-table-column.ts b/Web/src/api-services/system/models/join-config-table-column.ts new file mode 100644 index 00000000..964732f6 --- /dev/null +++ b/Web/src/api-services/system/models/join-config-table-column.ts @@ -0,0 +1,34 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Admin.NET 通用权限开发平台 + * 让 .NET 开发更简单、更通用、更流行。整合最新技术,模块插件式开发,前后端分离,开箱即用。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + /** + * + * + * @export + * @interface JoinConfigTableColumn + */ +export interface JoinConfigTableColumn { + + /** + * @type {string} + * @memberof JoinConfigTableColumn + */ + leftTableColumn?: string | null; + + /** + * @type {string} + * @memberof JoinConfigTableColumn + */ + rightTableColumn?: string | null; +} diff --git a/Web/src/api-services/system/models/join-config.ts b/Web/src/api-services/system/models/join-config.ts new file mode 100644 index 00000000..ca9c36e5 --- /dev/null +++ b/Web/src/api-services/system/models/join-config.ts @@ -0,0 +1,47 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Admin.NET 通用权限开发平台 + * 让 .NET 开发更简单、更通用、更流行。整合最新技术,模块插件式开发,前后端分离,开箱即用。
👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import { JoinConfigTableColumn } from './join-config-table-column'; + /** + * + * + * @export + * @interface JoinConfig + */ +export interface JoinConfig { + + /** + * @type {string} + * @memberof JoinConfig + */ + joinType?: string | null; + + /** + * @type {string} + * @memberof JoinConfig + */ + leftTable?: string | null; + + /** + * @type {string} + * @memberof JoinConfig + */ + rightTable?: string | null; + + /** + * @type {Array} + * @memberof JoinConfig + */ + tableColumns?: Array | null; +} diff --git a/Web/src/api-services/system/models/orders-sql.ts b/Web/src/api-services/system/models/order-config.ts similarity index 86% rename from Web/src/api-services/system/models/orders-sql.ts rename to Web/src/api-services/system/models/order-config.ts index b6288f06..34055dfa 100644 --- a/Web/src/api-services/system/models/orders-sql.ts +++ b/Web/src/api-services/system/models/order-config.ts @@ -16,25 +16,25 @@ * * * @export - * @interface OrdersSQL + * @interface OrderConfig */ -export interface OrdersSQL { +export interface OrderConfig { /** * @type {string} - * @memberof OrdersSQL + * @memberof OrderConfig */ table?: string | null; /** * @type {string} - * @memberof OrdersSQL + * @memberof OrderConfig */ column?: string | null; /** * @type {number} - * @memberof OrdersSQL + * @memberof OrderConfig */ sort?: number; } diff --git a/Web/src/api-services/system/models/columns-sql.ts b/Web/src/api-services/system/models/select-config.ts similarity index 88% rename from Web/src/api-services/system/models/columns-sql.ts rename to Web/src/api-services/system/models/select-config.ts index 846a95ed..19dd5b53 100644 --- a/Web/src/api-services/system/models/columns-sql.ts +++ b/Web/src/api-services/system/models/select-config.ts @@ -16,19 +16,19 @@ * * * @export - * @interface ColumnsSQL + * @interface SelectConfig */ -export interface ColumnsSQL { +export interface SelectConfig { /** * @type {string} - * @memberof ColumnsSQL + * @memberof SelectConfig */ table?: string | null; /** * @type {string} - * @memberof ColumnsSQL + * @memberof SelectConfig */ column?: string | null; } diff --git a/Web/src/api-services/system/models/conditions-sql.ts b/Web/src/api-services/system/models/where-config.ts similarity index 73% rename from Web/src/api-services/system/models/conditions-sql.ts rename to Web/src/api-services/system/models/where-config.ts index f7657cb6..720c44ac 100644 --- a/Web/src/api-services/system/models/conditions-sql.ts +++ b/Web/src/api-services/system/models/where-config.ts @@ -16,31 +16,43 @@ * * * @export - * @interface ConditionsSQL + * @interface WhereConfig */ -export interface ConditionsSQL { +export interface WhereConfig { /** * @type {string} - * @memberof ConditionsSQL + * @memberof WhereConfig */ table?: string | null; /** * @type {string} - * @memberof ConditionsSQL + * @memberof WhereConfig */ column?: string | null; /** * @type {string} - * @memberof ConditionsSQL + * @memberof WhereConfig */ operator?: string | null; /** * @type {string} - * @memberof ConditionsSQL + * @memberof WhereConfig */ value?: string | null; + + /** + * @type {string} + * @memberof WhereConfig + */ + dataType?: string | null; + + /** + * @type {string} + * @memberof WhereConfig + */ + joinType?: string | null; } diff --git a/Web/src/views/system/reportCustomQuery/index.vue b/Web/src/views/system/reportCustomQuery/index.vue index ff8ab446..f1226827 100644 --- a/Web/src/views/system/reportCustomQuery/index.vue +++ b/Web/src/views/system/reportCustomQuery/index.vue @@ -1,182 +1,351 @@