1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using SqlSugar;
- using SqlSugar.DistributedSystem.Snowflake;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Wms.Screen.SqlSugar
- {
- public class BaseEntityModel
- {
- }
- public class BaseModel: BaseEntityModel
- {
- public BaseModel() { }
- [SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
- public virtual long Id { get; set; } = IdFactory.NewId();
- [SugarColumn(ColumnName = "Memo", Length = 500, IsNullable = true, ColumnDataType = "nvarchar", DefaultValue = "")]
- public virtual string Memo { get; set; }
- [SugarColumn(ColumnName = "AddWho", Length = 50, ColumnDataType = "nvarchar", DefaultValue = "", IsNullable = false)]
- public virtual string AddWho { get; set; } = "";
- [SugarColumn(ColumnName = "EditWho", Length = 50, ColumnDataType = "nvarchar", DefaultValue = "", IsNullable = false)]
- public virtual string EditWho { get; set; } = "";
- [SugarColumn(ColumnName = "AddTime", DefaultValue = "1900-1-1", IsNullable = false)]
- public virtual DateTime AddTime { get; set; } = DateTime.Now;
- [SugarColumn(ColumnName = "EditTime", DefaultValue = "1900-1-1", IsNullable = false)]
- public virtual DateTime EditTime { get; set; } = DateTime.Now;
- }
- public static class IdFactory
- {
- private static readonly object locker = new object();
- private static IdWorker _idworker;
- public static IdWorker GetInstance()
- {
- if (_idworker == null)
- {
- lock (locker)
- {
- if (_idworker == null)
- {
- _idworker = new IdWorker(1, 1);
- }
- }
- }
- return _idworker;
- }
- public static long NewId()
- {
- return GetInstance().NextId();
- }
- }
-
- }
|