From 5514bdc25e25bd4a4954740ea9baef112796c8ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E9=B9=B0?= Date: Wed, 1 Oct 2025 11:00:02 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20PostgreSQL=20=E5=B9=B6?= =?UTF-8?q?=E5=90=AF=E7=94=A8=20=E9=A9=BC=E5=B3=B0=E8=BD=AC=E4=B8=8B?= =?UTF-8?q?=E5=88=92=E7=BA=BF=20=E6=97=B6=EF=BC=8C=E6=8A=A5=E6=9F=90?= =?UTF-8?q?=E4=BA=9B=E5=AD=97=E6=AE=B5=E4=B8=8D=E5=AD=98=E5=9C=A8=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin.NET.Core/Service/APIJSON/SelectTable.cs | 9 +++++++-- .../Service/Config/SysTenantConfigService.cs | 10 ++++++++-- .../Service/Config/SysUserConfigService.cs | 10 ++++++++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Admin.NET/Admin.NET.Core/Service/APIJSON/SelectTable.cs b/Admin.NET/Admin.NET.Core/Service/APIJSON/SelectTable.cs index 9b6f0ecd8..8b83cb9de 100644 --- a/Admin.NET/Admin.NET.Core/Service/APIJSON/SelectTable.cs +++ b/Admin.NET/Admin.NET.Core/Service/APIJSON/SelectTable.cs @@ -473,12 +473,17 @@ public class SelectTable : ISingleton // 判断列表是否有权限 sum(1)、sum(*)、Count(1)这样的值直接有效 if (colName == "*" || int.TryParse(colName, out int colNumber) || (IsCol(subtable, colName) && _identitySvc.ColIsRole(colName, selectrole.Split(',')))) { + // 字段名加引号,防止和SQL关键字冲突(mysql为反引号) + string qm = "\""; + if (tb.Context.CurrentConnectionConfig.DbType is SqlSugar.DbType.MySql) + qm = "`"; + if (ziduan.Length > 1) { if (ziduan[1].Length > 20) throw new Exception("别名不能超过20个字符"); - str.Append(ziduan[0] + " as `" + ReplaceSQLChar(ziduan[1]) + "`,"); + str.Append(ziduan[0] + " as " + qm + ReplaceSQLChar(ziduan[1]) + qm + ","); } // 不对函数加``,解决sum(*)、Count(1)等不能使用的问题 else if (ziduan[0].Contains('(')) @@ -486,7 +491,7 @@ public class SelectTable : ISingleton str.Append(ziduan[0] + ","); } else - str.Append("`" + ziduan[0] + "`" + ","); + str.Append(qm + ziduan[0] + qm + ","); } } if (string.IsNullOrEmpty(str.ToString())) diff --git a/Admin.NET/Admin.NET.Core/Service/Config/SysTenantConfigService.cs b/Admin.NET/Admin.NET.Core/Service/Config/SysTenantConfigService.cs index 7aca210f3..b92e4efbd 100644 --- a/Admin.NET/Admin.NET.Core/Service/Config/SysTenantConfigService.cs +++ b/Admin.NET/Admin.NET.Core/Service/Config/SysTenantConfigService.cs @@ -27,8 +27,14 @@ public class SysTenantConfigService : IDynamicApiController, ITransient _sysCacheService = sysCacheService; _sysConfigRep = sysConfigRep; _sysConfigDataRep = sysConfigDataRep; - VSysConfig = _sysConfigRep.AsQueryable().InnerJoin(_sysConfigDataRep.AsQueryable().WhereIF(!_userManager.SuperAdmin, cv => cv.TenantId == _userManager.TenantId), - (c, cv) => c.Id == cv.ConfigId).Select().MergeTable(); + VSysConfig = _sysConfigRep.AsQueryable() + .InnerJoin( + _sysConfigDataRep.AsQueryable().WhereIF(!_userManager.SuperAdmin, cv => cv.TenantId == _userManager.TenantId), + (c, cv) => c.Id == cv.ConfigId + ) + //.Select().MergeTable(); + // 解决PostgreSQL下并启用驼峰转下划线时,报字段不存在,SqlSugar在Select后生成的sql, as后没转下划线导致. + .SelectMergeTable((c, cv) => new SysConfig { Id = c.Id.SelectAll(), Value = cv.Value }); } /// diff --git a/Admin.NET/Admin.NET.Core/Service/Config/SysUserConfigService.cs b/Admin.NET/Admin.NET.Core/Service/Config/SysUserConfigService.cs index 259650ab1..897f31be9 100644 --- a/Admin.NET/Admin.NET.Core/Service/Config/SysUserConfigService.cs +++ b/Admin.NET/Admin.NET.Core/Service/Config/SysUserConfigService.cs @@ -27,8 +27,14 @@ public class SysUserConfigService : IDynamicApiController, ITransient _sysCacheService = sysCacheService; _sysConfigRep = sysConfigRep; _sysConfigDataRep = sysConfigDataRep; - VSysConfig = _sysConfigRep.AsQueryable().LeftJoin(_sysConfigDataRep.AsQueryable().WhereIF(_userManager.SuperAdmin, cv => cv.UserId == _userManager.UserId), - (c, cv) => c.Id == cv.ConfigId).Select().MergeTable(); + VSysConfig = _sysConfigRep.AsQueryable() + .LeftJoin( + _sysConfigDataRep.AsQueryable().WhereIF(_userManager.SuperAdmin, cv => cv.UserId == _userManager.UserId), + (c, cv) => c.Id == cv.ConfigId + ) + //.Select().MergeTable(); + // 解决PostgreSQL下并启用驼峰转下划线时,报字段不存在,SqlSugar在Select后生成的sql, as后没转下划线导致. + .SelectMergeTable((c, cv) => new SysConfig { Id = c.Id.SelectAll(), Value = cv.Value }); } /// -- Gitee From 86241b72f27a71ec0274d1c8e5d2954c6ec8fcf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E9=B9=B0?= Date: Thu, 2 Oct 2025 11:01:27 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=A0=B7=E5=BC=8F=E7=BB=86=E8=8A=82=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../codeGen/component/editCodeGenDialog.vue | 59 ++++++++++++------- .../codeGen/component/genConfigDialog.vue | 10 +++- .../codeGen/component/previewDialog.vue | 12 +++- Web/src/views/system/database/index.vue | 2 +- 4 files changed, 55 insertions(+), 28 deletions(-) diff --git a/Web/src/views/system/codeGen/component/editCodeGenDialog.vue b/Web/src/views/system/codeGen/component/editCodeGenDialog.vue index aab6ed6d9..e8ffb446f 100644 --- a/Web/src/views/system/codeGen/component/editCodeGenDialog.vue +++ b/Web/src/views/system/codeGen/component/editCodeGenDialog.vue @@ -117,12 +117,12 @@ - + - + @@ -136,29 +136,24 @@
数据唯一性配置
- 增加配置 + 增加配置 保证字段值的唯一性,排除null值 - + @@ -299,4 +294,24 @@ defineExpose({ openDialog }); :deep(.el-dialog__body) { min-height: 450px; } + +.unique-box { + display: grid; + gap: 20px; +} +.unique-line { + display: flex; + gap: 20px; + + .el-form-item { + margin-bottom: 0; + flex: 1; + } + + .delete-btn { + align-self: center; + width: 24px; + margin-left: -10px; + } +} diff --git a/Web/src/views/system/codeGen/component/genConfigDialog.vue b/Web/src/views/system/codeGen/component/genConfigDialog.vue index 701b229c8..fe6bf5c64 100644 --- a/Web/src/views/system/codeGen/component/genConfigDialog.vue +++ b/Web/src/views/system/codeGen/component/genConfigDialog.vue @@ -7,7 +7,7 @@ 生成配置 - + @@ -40,7 +40,7 @@ - + @@ -182,9 +182,13 @@ const submit = async () => { // 导出对象 defineExpose({ openDialog }); - diff --git a/Web/src/views/system/codeGen/component/previewDialog.vue b/Web/src/views/system/codeGen/component/previewDialog.vue index f9ea56e62..6b6802eb0 100644 --- a/Web/src/views/system/codeGen/component/previewDialog.vue +++ b/Web/src/views/system/codeGen/component/previewDialog.vue @@ -17,7 +17,7 @@ -
+