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 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
{
/// <summary>
/// Sql插入类
@ -15,12 +11,12 @@ namespace EU.Core
#region 变量定义
private string sql;
private string createProgram;
private string rowId;
private long rowId;
/// <summary>
/// 如果使用线程,此处可以指定插入用户代码,否则CREATED_BY为空
/// </summary>
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");
}

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

@ -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)
{

@ -9,9 +9,6 @@
</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\LogHelper.cs" />
</ItemGroup>
@ -50,7 +47,6 @@
<ItemGroup>
<Folder Include="Core\" />
<Folder Include="DB\DbSql\" />
</ItemGroup>
</Project>

Loading…
Cancel
Save