From 9dc2c3c83fcb94bf64225bc778d03fca25f55c6a Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Mon, 15 Apr 2024 19:29:59 +0800 Subject: [PATCH] DbSql --- Tiobon.Core.Common/DB/DbSql/DbInsert.cs | 38 ++++++++------------ Tiobon.Core.Common/DB/DbSql/DbSelect.cs | 6 +--- Tiobon.Core.Common/DB/DbSql/DbUpdate.cs | 12 +++---- Tiobon.Core.Common/Tiobon.Core.Common.csproj | 4 --- 4 files changed, 19 insertions(+), 41 deletions(-) diff --git a/Tiobon.Core.Common/DB/DbSql/DbInsert.cs b/Tiobon.Core.Common/DB/DbSql/DbInsert.cs index fe2bb0b0..a48593a6 100644 --- a/Tiobon.Core.Common/DB/DbSql/DbInsert.cs +++ b/Tiobon.Core.Common/DB/DbSql/DbInsert.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Text; -using EU.Core.UserManager; -using EU.Core.Utilities; -using Microsoft.AspNetCore.Mvc.Core; +using SqlSugar; +using Tiobon.Core.Common.UserManager; -namespace EU.Core +namespace Tiobon.Core.Common { /// /// Sql插入类 @@ -15,12 +11,12 @@ namespace EU.Core #region 变量定义 private string sql; private string createProgram; - private string rowId; + private long rowId; /// /// 如果使用线程,此处可以指定插入用户代码,否则CREATED_BY为空 /// public string CreatedBy { get; set; } - public string RowId + public long RowId { get { return rowId; } set { rowId = value; } @@ -81,11 +77,8 @@ namespace EU.Core #endregion #region Values - public void Values(string fieldName, string value) + public void Values(string fieldName, long value) { - if (string.IsNullOrEmpty(value)) return; - value = value.Replace("'", "''"); - value = value.Trim(); string s = "N'{0}'"; s = string.Format(s, value); @@ -210,7 +203,7 @@ namespace EU.Core { if (isInitRowId == true) { - rowId = StringHelper.Id; + rowId = SnowFlakeSingle.Instance.NextId(); Values("ID", rowId); } if (isInitDefaultValue == true) @@ -227,11 +220,11 @@ namespace EU.Core { value = value.Trim(); } - if (DBHelper.MySql) - { - fieldName = fieldName.Replace("[", "`"); - fieldName = fieldName.Replace("]", "`"); - } + //if (DBHelper.MySql) + //{ + // fieldName = fieldName.Replace("[", "`"); + // fieldName = fieldName.Replace("]", "`"); + //} sql = sql.Replace("{", "{{"); sql = sql.Replace("}", "}}"); int n = sql.IndexOf("() VALUES"); @@ -269,20 +262,17 @@ namespace EU.Core //} //create_by - Guid? createBy = UserContext.Current.User_Id; - if (createBy != Guid.Empty) + var createBy = UserContext.Current.User_Id; Values("CreatedBy", createBy); //create_date DateTime createDate = DateTime.Now; Values("CreatedTime", createDate); - Values("GroupId", UserContext.Current.GroupId); - Values("CompanyId", UserContext.Current.CompanyId); //create_program //Values("CREATED_PROGRAM", createProgram); //tag - Values("Tag", 1); + //Values("Tag", 1); //active_flag //Values("DELETE_FLAG", "N"); } diff --git a/Tiobon.Core.Common/DB/DbSql/DbSelect.cs b/Tiobon.Core.Common/DB/DbSql/DbSelect.cs index d69efb34..3d430ecc 100644 --- a/Tiobon.Core.Common/DB/DbSql/DbSelect.cs +++ b/Tiobon.Core.Common/DB/DbSql/DbSelect.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace EU.Core +namespace Tiobon.Core.Common { public class DbSelect { diff --git a/Tiobon.Core.Common/DB/DbSql/DbUpdate.cs b/Tiobon.Core.Common/DB/DbSql/DbUpdate.cs index 0e02be8c..1b620f1f 100644 --- a/Tiobon.Core.Common/DB/DbSql/DbUpdate.cs +++ b/Tiobon.Core.Common/DB/DbSql/DbUpdate.cs @@ -1,9 +1,6 @@ -using EU.Core.UserManager; -using System; -using System.Collections.Generic; -using System.Text; +using Tiobon.Core.Common.UserManager; -namespace EU.Core +namespace Tiobon.Core.Common { public class DbUpdate { @@ -452,9 +449,8 @@ namespace EU.Core // Set("LAST_UPD_BY", lastUpdBy); //} - Guid? lastUpdBy = UserContext.Current.User_Id; - if (lastUpdBy != Guid.Empty) - Set("UpdateBy", lastUpdBy); + var lastUpdBy = UserContext.Current.User_Id; + Set("UpdateBy", lastUpdBy); if (tempSql.IndexOf("[LAST_UPD_DATE]") == -1) { diff --git a/Tiobon.Core.Common/Tiobon.Core.Common.csproj b/Tiobon.Core.Common/Tiobon.Core.Common.csproj index c5bbb911..2d619448 100644 --- a/Tiobon.Core.Common/Tiobon.Core.Common.csproj +++ b/Tiobon.Core.Common/Tiobon.Core.Common.csproj @@ -9,9 +9,6 @@ - - - @@ -50,7 +47,6 @@ -