master
xiaochanghai 1 year ago
parent 05a3e0a264
commit 9dc2c3c83f
  1. 38
      Tiobon.Core.Common/DB/DbSql/DbInsert.cs
  2. 6
      Tiobon.Core.Common/DB/DbSql/DbSelect.cs
  3. 12
      Tiobon.Core.Common/DB/DbSql/DbUpdate.cs
  4. 4
      Tiobon.Core.Common/Tiobon.Core.Common.csproj

@ -1,11 +1,7 @@
using System; using SqlSugar;
using System.Collections.Generic; using Tiobon.Core.Common.UserManager;
using System.Text;
using EU.Core.UserManager;
using EU.Core.Utilities;
using Microsoft.AspNetCore.Mvc.Core;
namespace EU.Core namespace Tiobon.Core.Common
{ {
/// <summary> /// <summary>
/// Sql插入类 /// Sql插入类
@ -15,12 +11,12 @@ namespace EU.Core
#region 变量定义 #region 变量定义
private string sql; private string sql;
private string createProgram; private string createProgram;
private string rowId; private long rowId;
/// <summary> /// <summary>
/// 如果使用线程,此处可以指定插入用户代码,否则CREATED_BY为空 /// 如果使用线程,此处可以指定插入用户代码,否则CREATED_BY为空
/// </summary> /// </summary>
public string CreatedBy { get; set; } public string CreatedBy { get; set; }
public string RowId public long RowId
{ {
get { return rowId; } get { return rowId; }
set { rowId = value; } set { rowId = value; }
@ -81,11 +77,8 @@ namespace EU.Core
#endregion #endregion
#region Values #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}'"; string s = "N'{0}'";
s = string.Format(s, value); s = string.Format(s, value);
@ -210,7 +203,7 @@ namespace EU.Core
{ {
if (isInitRowId == true) if (isInitRowId == true)
{ {
rowId = StringHelper.Id; rowId = SnowFlakeSingle.Instance.NextId();
Values("ID", rowId); Values("ID", rowId);
} }
if (isInitDefaultValue == true) if (isInitDefaultValue == true)
@ -227,11 +220,11 @@ namespace EU.Core
{ {
value = value.Trim(); value = value.Trim();
} }
if (DBHelper.MySql) //if (DBHelper.MySql)
{ //{
fieldName = fieldName.Replace("[", "`"); // fieldName = fieldName.Replace("[", "`");
fieldName = fieldName.Replace("]", "`"); // fieldName = fieldName.Replace("]", "`");
} //}
sql = sql.Replace("{", "{{"); sql = sql.Replace("{", "{{");
sql = sql.Replace("}", "}}"); sql = sql.Replace("}", "}}");
int n = sql.IndexOf("() VALUES"); int n = sql.IndexOf("() VALUES");
@ -269,20 +262,17 @@ namespace EU.Core
//} //}
//create_by //create_by
Guid? createBy = UserContext.Current.User_Id; var createBy = UserContext.Current.User_Id;
if (createBy != Guid.Empty)
Values("CreatedBy", createBy); Values("CreatedBy", createBy);
//create_date //create_date
DateTime createDate = DateTime.Now; DateTime createDate = DateTime.Now;
Values("CreatedTime", createDate); Values("CreatedTime", createDate);
Values("GroupId", UserContext.Current.GroupId);
Values("CompanyId", UserContext.Current.CompanyId);
//create_program //create_program
//Values("CREATED_PROGRAM", createProgram); //Values("CREATED_PROGRAM", createProgram);
//tag //tag
Values("Tag", 1); //Values("Tag", 1);
//active_flag //active_flag
//Values("DELETE_FLAG", "N"); //Values("DELETE_FLAG", "N");
} }

@ -1,8 +1,4 @@
using System; namespace Tiobon.Core.Common
using System.Collections.Generic;
using System.Text;
namespace EU.Core
{ {
public class DbSelect public class DbSelect
{ {

@ -1,9 +1,6 @@
using EU.Core.UserManager; using Tiobon.Core.Common.UserManager;
using System;
using System.Collections.Generic;
using System.Text;
namespace EU.Core namespace Tiobon.Core.Common
{ {
public class DbUpdate public class DbUpdate
{ {
@ -452,9 +449,8 @@ namespace EU.Core
// Set("LAST_UPD_BY", lastUpdBy); // Set("LAST_UPD_BY", lastUpdBy);
//} //}
Guid? lastUpdBy = UserContext.Current.User_Id; var lastUpdBy = UserContext.Current.User_Id;
if (lastUpdBy != Guid.Empty) Set("UpdateBy", lastUpdBy);
Set("UpdateBy", lastUpdBy);
if (tempSql.IndexOf("[LAST_UPD_DATE]") == -1) if (tempSql.IndexOf("[LAST_UPD_DATE]") == -1)
{ {

@ -9,9 +9,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="DB\DbSql\DbInsert.cs" />
<Compile Remove="DB\DbSql\DbSelect.cs" />
<Compile Remove="DB\DbSql\DbUpdate.cs" />
<Compile Remove="LogHelper\ILoggerHelper.cs" /> <Compile Remove="LogHelper\ILoggerHelper.cs" />
<Compile Remove="LogHelper\LogHelper.cs" /> <Compile Remove="LogHelper\LogHelper.cs" />
</ItemGroup> </ItemGroup>
@ -50,7 +47,6 @@
<ItemGroup> <ItemGroup>
<Folder Include="Core\" /> <Folder Include="Core\" />
<Folder Include="DB\DbSql\" />
</ItemGroup> </ItemGroup>
</Project> </Project>

Loading…
Cancel
Save