From 127d86616f95dd691de787d024eb08fba3b59da4 Mon Sep 17 00:00:00 2001 From: yubaolee Date: Sat, 13 Mar 2021 23:45:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=E4=B8=BB=E9=94=AE?= =?UTF-8?q?=E7=9A=84=E6=94=AF=E6=8C=81=EF=BC=9B=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E4=B8=9A=E5=8A=A1=E7=B1=BB=E7=BB=93=E6=9E=84?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/AppManager.cs | 2 +- .../AuthStrategies/NormalAuthStrategy.cs | 2 +- .../AuthStrategies/SystemAuthStrategy.cs | 2 +- OpenAuth.App/Base/BaseApp.cs | 23 +----- OpenAuth.App/Base/BaseIntAutoGenApp.cs | 41 ++++++++++ OpenAuth.App/Base/BaseLongApp.cs | 82 +------------------ OpenAuth.App/Base/BaseStringApp.cs | 54 ++++++++++++ OpenAuth.App/Base/BaseTreeApp.cs | 2 +- OpenAuth.App/BuilderTableApp.cs | 2 +- OpenAuth.App/BuilderTableColumnApp.cs | 2 +- OpenAuth.App/CategoryApp.cs | 2 +- OpenAuth.App/CategoryTypeApp.cs | 2 +- OpenAuth.App/DataPrivilegeRuleApp.cs | 2 +- OpenAuth.App/FileApp.cs | 2 +- OpenAuth.App/FlowInstanceApp.cs | 2 +- OpenAuth.App/FlowSchemeApp.cs | 2 +- OpenAuth.App/FormApp.cs | 2 +- OpenAuth.App/FrmLeaveReqApp.cs | 2 +- OpenAuth.App/OpenJobApp.cs | 2 +- OpenAuth.App/ResourceApp.cs | 2 +- OpenAuth.App/RevelanceManagerApp.cs | 2 +- OpenAuth.App/RoleApp.cs | 2 +- OpenAuth.App/SysLogApp.cs | 2 +- OpenAuth.App/SysMessageApp.cs | 2 +- OpenAuth.App/UserManagerApp.cs | 2 +- OpenAuth.App/WmsInboundOrderDtblApp.cs | 2 +- OpenAuth.App/WmsInboundOrderTblApp.cs | 2 +- OpenAuth.Repository/Core/IntAutoGenEntity.cs | 26 ++++++ 28 files changed, 150 insertions(+), 122 deletions(-) create mode 100644 OpenAuth.App/Base/BaseIntAutoGenApp.cs create mode 100644 OpenAuth.App/Base/BaseStringApp.cs create mode 100644 OpenAuth.Repository/Core/IntAutoGenEntity.cs diff --git a/OpenAuth.App/AppManager.cs b/OpenAuth.App/AppManager.cs index 506183d6..083abbd4 100644 --- a/OpenAuth.App/AppManager.cs +++ b/OpenAuth.App/AppManager.cs @@ -13,7 +13,7 @@ namespace OpenAuth.App /// /// 分类管理 /// - public class AppManager : BaseApp + public class AppManager : BaseStringApp { public void Add(Application Application) { diff --git a/OpenAuth.App/AuthStrategies/NormalAuthStrategy.cs b/OpenAuth.App/AuthStrategies/NormalAuthStrategy.cs index 05aae88f..f0ef8abe 100644 --- a/OpenAuth.App/AuthStrategies/NormalAuthStrategy.cs +++ b/OpenAuth.App/AuthStrategies/NormalAuthStrategy.cs @@ -28,7 +28,7 @@ namespace OpenAuth.App /// /// 普通用户授权策略 /// - public class NormalAuthStrategy :BaseApp, IAuthStrategy + public class NormalAuthStrategy :BaseStringApp, IAuthStrategy { protected User _user; diff --git a/OpenAuth.App/AuthStrategies/SystemAuthStrategy.cs b/OpenAuth.App/AuthStrategies/SystemAuthStrategy.cs index 4f4dd06d..87d90d02 100644 --- a/OpenAuth.App/AuthStrategies/SystemAuthStrategy.cs +++ b/OpenAuth.App/AuthStrategies/SystemAuthStrategy.cs @@ -30,7 +30,7 @@ namespace OpenAuth.App /// 超级管理员权限 /// 超级管理员使用guid.empty为ID,可以根据需要修改 /// - public class SystemAuthStrategy : BaseApp, IAuthStrategy + public class SystemAuthStrategy : BaseStringApp, IAuthStrategy { protected User _user; private DbExtension _dbExtension; diff --git a/OpenAuth.App/Base/BaseApp.cs b/OpenAuth.App/Base/BaseApp.cs index 35c32765..97549e3b 100644 --- a/OpenAuth.App/Base/BaseApp.cs +++ b/OpenAuth.App/Base/BaseApp.cs @@ -9,12 +9,7 @@ using OpenAuth.Repository.Interface; namespace OpenAuth.App { - /// - /// 业务层基类,UnitWork用于事务操作,Repository用于普通的数据库操作 - /// 如用户管理:Class UserManagerApp:BaseApp - /// - /// - public class BaseApp where T : StringEntity where TDbContext: DbContext + public abstract class BaseApp where T : class where TDbContext: DbContext { /// /// 用于普通的数据库操作 @@ -70,21 +65,7 @@ namespace OpenAuth.App return UnitWork.Find(null).GenerateFilter(parametername, JsonHelper.Instance.Deserialize(rule.PrivilegeRules)); } - - /// - /// 按id批量删除 - /// - /// - public virtual void Delete(string[] ids) - { - Repository.Delete(u => ids.Contains(u.Id)); - } - - public T Get(string id) - { - return Repository.FirstOrDefault(u => u.Id == id); - } - + /// /// 计算实体更新的层级信息 /// diff --git a/OpenAuth.App/Base/BaseIntAutoGenApp.cs b/OpenAuth.App/Base/BaseIntAutoGenApp.cs new file mode 100644 index 00000000..88437679 --- /dev/null +++ b/OpenAuth.App/Base/BaseIntAutoGenApp.cs @@ -0,0 +1,41 @@ +using System; +using System.Linq; +using Infrastructure; +using Microsoft.EntityFrameworkCore; +using OpenAuth.App.Interface; +using OpenAuth.Repository.Core; +using OpenAuth.Repository.Domain; +using OpenAuth.Repository.Interface; + +namespace OpenAuth.App +{ + /// + /// 数据库Id为numberic且为数据库自动生成的业务类型 + /// 该场景通常为SqlServer的自动增长类型和Oracle自带的Sequence + /// 业务层基类,UnitWork用于事务操作,Repository用于普通的数据库操作 + /// + /// + public class BaseIntAutoGenApp :BaseApp where T : IntAutoGenEntity where TDbContext: DbContext + { + public BaseIntAutoGenApp(IUnitWork unitWork, IRepository repository, IAuth auth) : base(unitWork, repository, auth) + { + UnitWork = unitWork; + Repository = repository; + _auth = auth; + } + + /// + /// 按id批量删除 + /// + /// + public void Delete(int[] ids) + { + Repository.Delete(u => ids.Contains(u.Id)); + } + + public T Get(int id) + { + return Repository.FirstOrDefault(u => u.Id == id); + } + } +} \ No newline at end of file diff --git a/OpenAuth.App/Base/BaseLongApp.cs b/OpenAuth.App/Base/BaseLongApp.cs index 5ca20d03..48ca2af9 100644 --- a/OpenAuth.App/Base/BaseLongApp.cs +++ b/OpenAuth.App/Base/BaseLongApp.cs @@ -12,10 +12,9 @@ namespace OpenAuth.App /// /// ⭐⭐数据库Id为numberic类型的数据表相关业务使用该基类⭐⭐ /// 业务层基类,UnitWork用于事务操作,Repository用于普通的数据库操作 - /// 如用户管理:Class UserManagerApp:BaseApp /// /// - public class BaseLongApp where T : LongEntity where TDbContext: DbContext + public class BaseLongApp :BaseApp where T : LongEntity where TDbContext: DbContext { /// /// 用于普通的数据库操作 @@ -30,53 +29,19 @@ namespace OpenAuth.App protected IAuth _auth; - public BaseLongApp(IUnitWork unitWork, IRepository repository, IAuth auth) + public BaseLongApp(IUnitWork unitWork, IRepository repository, IAuth auth) : base(unitWork, repository,auth) { UnitWork = unitWork; Repository = repository; _auth = auth; } - - /// - /// 获取当前登录用户的数据访问权限 - /// - /// linq表达式参数的名称,如u=>u.name中的"u" - /// - protected IQueryable GetDataPrivilege(string parametername) - { - var loginUser = _auth.GetCurrentUser(); - if (loginUser.User.Account == Define.SYSTEM_USERNAME) return UnitWork.Find(null); //超级管理员特权 - - var moduleName = typeof(T).Name; - var rule = UnitWork.FirstOrDefault(u => u.SourceCode == moduleName); - if (rule == null) return UnitWork.Find(null); //没有设置数据规则,那么视为该资源允许被任何主体查看 - if (rule.PrivilegeRules.Contains(Define.DATAPRIVILEGE_LOGINUSER) || - rule.PrivilegeRules.Contains(Define.DATAPRIVILEGE_LOGINROLE)|| - rule.PrivilegeRules.Contains(Define.DATAPRIVILEGE_LOGINORG)) - { - - //即把{loginUser} =='xxxxxxx'换为 loginUser.User.Id =='xxxxxxx',从而把当前登录的用户名与当时设计规则时选定的用户id对比 - rule.PrivilegeRules = rule.PrivilegeRules.Replace(Define.DATAPRIVILEGE_LOGINUSER, loginUser.User.Id); - - var roles = loginUser.Roles.Select(u => u.Id).ToList(); - roles.Sort(); //按字母排序,这样可以进行like操作 - rule.PrivilegeRules = rule.PrivilegeRules.Replace(Define.DATAPRIVILEGE_LOGINROLE, - string.Join(',',roles)); - - var orgs = loginUser.Orgs.Select(u => u.Id).ToList(); - orgs.Sort(); - rule.PrivilegeRules = rule.PrivilegeRules.Replace(Define.DATAPRIVILEGE_LOGINORG, - string.Join(',',orgs)); - } - return UnitWork.Find(null).GenerateFilter(parametername, - JsonHelper.Instance.Deserialize(rule.PrivilegeRules)); - } + /// /// 按id批量删除 /// /// - public virtual void Delete(long[] ids) + public void Delete(long[] ids) { Repository.Delete(u => ids.Contains(u.Id)); } @@ -85,44 +50,5 @@ namespace OpenAuth.App { return Repository.FirstOrDefault(u => u.Id == id); } - - /// - /// 计算实体更新的层级信息 - /// - /// U必须是一个继承TreeEntity的结构 - /// - public void CaculateCascade(U entity) where U : TreeEntity - { - if (entity.ParentId == "") entity.ParentId = null; - string cascadeId; - int currentCascadeId = 1; //当前结点的级联节点最后一位 - var sameLevels = UnitWork.Find(o => o.ParentId == entity.ParentId && o.Id != entity.Id); - foreach (var obj in sameLevels) - { - int objCascadeId = int.Parse(obj.CascadeId.TrimEnd('.').Split('.').Last()); - if (currentCascadeId <= objCascadeId) currentCascadeId = objCascadeId + 1; - } - - if (!string.IsNullOrEmpty(entity.ParentId)) - { - var parentOrg = UnitWork.FirstOrDefault(o => o.Id == entity.ParentId); - if (parentOrg != null) - { - cascadeId = parentOrg.CascadeId + currentCascadeId + "."; - entity.ParentName = parentOrg.Name; - } - else - { - throw new Exception("未能找到该组织的父节点信息"); - } - } - else - { - cascadeId = ".0." + currentCascadeId + "."; - entity.ParentName = "根节点"; - } - - entity.CascadeId = cascadeId; - } } } \ No newline at end of file diff --git a/OpenAuth.App/Base/BaseStringApp.cs b/OpenAuth.App/Base/BaseStringApp.cs new file mode 100644 index 00000000..b3e4c668 --- /dev/null +++ b/OpenAuth.App/Base/BaseStringApp.cs @@ -0,0 +1,54 @@ +using System; +using System.Linq; +using Infrastructure; +using Microsoft.EntityFrameworkCore; +using OpenAuth.App.Interface; +using OpenAuth.Repository.Core; +using OpenAuth.Repository.Domain; +using OpenAuth.Repository.Interface; + +namespace OpenAuth.App +{ + /// + /// 业务层基类,UnitWork用于事务操作,Repository用于普通的数据库操作 + /// 如用户管理:Class UserManagerApp:BaseApp + /// + /// + public class BaseStringApp :BaseApp where T : StringEntity where TDbContext: DbContext + { + /// + /// 用于普通的数据库操作 + /// + protected IRepository Repository; + + /// + /// 用于事务操作 + /// 使用详见:http://doc.openauth.me/core/unitwork.html + /// + protected IUnitWork UnitWork; + + protected IAuth _auth; + + public BaseStringApp(IUnitWork unitWork, IRepository repository, IAuth auth) : base(unitWork, repository, auth) + { + UnitWork = unitWork; + Repository = repository; + _auth = auth; + } + + /// + /// 按id批量删除 + /// + /// + public virtual void Delete(string[] ids) + { + Repository.Delete(u => ids.Contains(u.Id)); + } + + public T Get(string id) + { + return Repository.FirstOrDefault(u => u.Id == id); + } + + } +} \ No newline at end of file diff --git a/OpenAuth.App/Base/BaseTreeApp.cs b/OpenAuth.App/Base/BaseTreeApp.cs index 099b3c89..7d75aa61 100644 --- a/OpenAuth.App/Base/BaseTreeApp.cs +++ b/OpenAuth.App/Base/BaseTreeApp.cs @@ -10,7 +10,7 @@ namespace OpenAuth.App /// 树状结构处理 /// /// - public class BaseTreeApp :BaseApp where T : TreeEntity where TDbContext :DbContext + public class BaseTreeApp :BaseStringApp where T : TreeEntity where TDbContext :DbContext { diff --git a/OpenAuth.App/BuilderTableApp.cs b/OpenAuth.App/BuilderTableApp.cs index de1c8b7f..ca0bef82 100644 --- a/OpenAuth.App/BuilderTableApp.cs +++ b/OpenAuth.App/BuilderTableApp.cs @@ -24,7 +24,7 @@ using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class BuilderTableApp : BaseApp + public class BuilderTableApp : BaseStringApp { private BuilderTableColumnApp _builderTableColumnApp; private CategoryApp _categoryApp; diff --git a/OpenAuth.App/BuilderTableColumnApp.cs b/OpenAuth.App/BuilderTableColumnApp.cs index 3dce69ac..4b4839ed 100644 --- a/OpenAuth.App/BuilderTableColumnApp.cs +++ b/OpenAuth.App/BuilderTableColumnApp.cs @@ -13,7 +13,7 @@ using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class BuilderTableColumnApp : BaseApp + public class BuilderTableColumnApp : BaseStringApp { public BuilderTableColumnApp(IUnitWork unitWork, IRepository repository, IAuth auth) : base(unitWork, repository,auth) diff --git a/OpenAuth.App/CategoryApp.cs b/OpenAuth.App/CategoryApp.cs index cd8bb5e1..382cdbde 100644 --- a/OpenAuth.App/CategoryApp.cs +++ b/OpenAuth.App/CategoryApp.cs @@ -13,7 +13,7 @@ using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class CategoryApp : BaseApp + public class CategoryApp : BaseStringApp { /// /// 加载列表 diff --git a/OpenAuth.App/CategoryTypeApp.cs b/OpenAuth.App/CategoryTypeApp.cs index 079a2084..851bc443 100644 --- a/OpenAuth.App/CategoryTypeApp.cs +++ b/OpenAuth.App/CategoryTypeApp.cs @@ -13,7 +13,7 @@ using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class CategoryTypeApp : BaseApp + public class CategoryTypeApp : BaseStringApp { private RevelanceManagerApp _revelanceApp; diff --git a/OpenAuth.App/DataPrivilegeRuleApp.cs b/OpenAuth.App/DataPrivilegeRuleApp.cs index 87544f5c..76d0d4c4 100644 --- a/OpenAuth.App/DataPrivilegeRuleApp.cs +++ b/OpenAuth.App/DataPrivilegeRuleApp.cs @@ -12,7 +12,7 @@ using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class DataPrivilegeRuleApp : BaseApp + public class DataPrivilegeRuleApp : BaseStringApp { private RevelanceManagerApp _revelanceApp; /// diff --git a/OpenAuth.App/FileApp.cs b/OpenAuth.App/FileApp.cs index 14b68273..cbe8db2b 100644 --- a/OpenAuth.App/FileApp.cs +++ b/OpenAuth.App/FileApp.cs @@ -21,7 +21,7 @@ namespace OpenAuth.App /// /// 文件管理 /// - public class FileApp : BaseApp + public class FileApp : BaseStringApp { private ILogger _logger; private string _filePath; diff --git a/OpenAuth.App/FlowInstanceApp.cs b/OpenAuth.App/FlowInstanceApp.cs index e3b3870e..36bf4b98 100644 --- a/OpenAuth.App/FlowInstanceApp.cs +++ b/OpenAuth.App/FlowInstanceApp.cs @@ -33,7 +33,7 @@ namespace OpenAuth.App /// /// 工作流实例表操作 /// - public class FlowInstanceApp : BaseApp + public class FlowInstanceApp : BaseStringApp { private RevelanceManagerApp _revelanceApp; private FlowSchemeApp _flowSchemeApp; diff --git a/OpenAuth.App/FlowSchemeApp.cs b/OpenAuth.App/FlowSchemeApp.cs index a2578ecc..a320e19f 100644 --- a/OpenAuth.App/FlowSchemeApp.cs +++ b/OpenAuth.App/FlowSchemeApp.cs @@ -10,7 +10,7 @@ using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class FlowSchemeApp :BaseApp + public class FlowSchemeApp :BaseStringApp { public void Add(FlowScheme flowScheme) { diff --git a/OpenAuth.App/FormApp.cs b/OpenAuth.App/FormApp.cs index 2b180a7a..e87ef975 100644 --- a/OpenAuth.App/FormApp.cs +++ b/OpenAuth.App/FormApp.cs @@ -13,7 +13,7 @@ using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class FormApp : BaseApp + public class FormApp : BaseStringApp { private IAuth _auth; private IOptions _appConfiguration; diff --git a/OpenAuth.App/FrmLeaveReqApp.cs b/OpenAuth.App/FrmLeaveReqApp.cs index fe2517b3..5ba45341 100644 --- a/OpenAuth.App/FrmLeaveReqApp.cs +++ b/OpenAuth.App/FrmLeaveReqApp.cs @@ -10,7 +10,7 @@ using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class FrmLeaveReqApp : BaseApp, ICustomerForm + public class FrmLeaveReqApp : BaseStringApp, ICustomerForm { private RevelanceManagerApp _revelanceApp; diff --git a/OpenAuth.App/OpenJobApp.cs b/OpenAuth.App/OpenJobApp.cs index a753750d..bdd2e61b 100644 --- a/OpenAuth.App/OpenJobApp.cs +++ b/OpenAuth.App/OpenJobApp.cs @@ -16,7 +16,7 @@ using Quartz; namespace OpenAuth.App { - public class OpenJobApp : BaseApp + public class OpenJobApp : BaseStringApp { private SysLogApp _sysLogApp; private IScheduler _scheduler; diff --git a/OpenAuth.App/ResourceApp.cs b/OpenAuth.App/ResourceApp.cs index 3e3c692b..b1118b87 100644 --- a/OpenAuth.App/ResourceApp.cs +++ b/OpenAuth.App/ResourceApp.cs @@ -15,7 +15,7 @@ namespace OpenAuth.App /// /// 分类管理 /// - public class ResourceApp:BaseApp + public class ResourceApp:BaseStringApp { private RevelanceManagerApp _revelanceApp; diff --git a/OpenAuth.App/RevelanceManagerApp.cs b/OpenAuth.App/RevelanceManagerApp.cs index 583ec784..eac1bbdc 100644 --- a/OpenAuth.App/RevelanceManagerApp.cs +++ b/OpenAuth.App/RevelanceManagerApp.cs @@ -11,7 +11,7 @@ using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class RevelanceManagerApp : BaseApp + public class RevelanceManagerApp : BaseStringApp { private readonly ILogger _logger; public RevelanceManagerApp(IUnitWork unitWork, IRepository repository, IAuth auth, ILogger logger) : base(unitWork, diff --git a/OpenAuth.App/RoleApp.cs b/OpenAuth.App/RoleApp.cs index 26e7eda1..ba575ca5 100644 --- a/OpenAuth.App/RoleApp.cs +++ b/OpenAuth.App/RoleApp.cs @@ -11,7 +11,7 @@ using OpenAuth.Repository; namespace OpenAuth.App { - public class RoleApp : BaseApp + public class RoleApp : BaseStringApp { private RevelanceManagerApp _revelanceApp; diff --git a/OpenAuth.App/SysLogApp.cs b/OpenAuth.App/SysLogApp.cs index bec00b89..cfe0431e 100644 --- a/OpenAuth.App/SysLogApp.cs +++ b/OpenAuth.App/SysLogApp.cs @@ -10,7 +10,7 @@ using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class SysLogApp : BaseApp + public class SysLogApp : BaseStringApp { /// diff --git a/OpenAuth.App/SysMessageApp.cs b/OpenAuth.App/SysMessageApp.cs index e96d7084..98bda001 100644 --- a/OpenAuth.App/SysMessageApp.cs +++ b/OpenAuth.App/SysMessageApp.cs @@ -11,7 +11,7 @@ using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class SysMessageApp : BaseApp + public class SysMessageApp : BaseStringApp { private RevelanceManagerApp _revelanceApp; diff --git a/OpenAuth.App/UserManagerApp.cs b/OpenAuth.App/UserManagerApp.cs index 2edda148..881c4095 100644 --- a/OpenAuth.App/UserManagerApp.cs +++ b/OpenAuth.App/UserManagerApp.cs @@ -15,7 +15,7 @@ using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class UserManagerApp : BaseApp + public class UserManagerApp : BaseStringApp { private RevelanceManagerApp _revelanceApp; private OrgManagerApp _orgManagerApp; diff --git a/OpenAuth.App/WmsInboundOrderDtblApp.cs b/OpenAuth.App/WmsInboundOrderDtblApp.cs index 57d075b3..80f8c8e2 100644 --- a/OpenAuth.App/WmsInboundOrderDtblApp.cs +++ b/OpenAuth.App/WmsInboundOrderDtblApp.cs @@ -12,7 +12,7 @@ using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class WmsInboundOrderDtblApp : BaseApp + public class WmsInboundOrderDtblApp : BaseStringApp { private RevelanceManagerApp _revelanceApp; private DbExtension _dbExtension; diff --git a/OpenAuth.App/WmsInboundOrderTblApp.cs b/OpenAuth.App/WmsInboundOrderTblApp.cs index 9b23ad70..88edc936 100644 --- a/OpenAuth.App/WmsInboundOrderTblApp.cs +++ b/OpenAuth.App/WmsInboundOrderTblApp.cs @@ -12,7 +12,7 @@ using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class WmsInboundOrderTblApp : BaseApp + public class WmsInboundOrderTblApp : BaseStringApp { private RevelanceManagerApp _revelanceApp; private WmsInboundOrderDtblApp _wmsInboundOrderDtblApp; diff --git a/OpenAuth.Repository/Core/IntAutoGenEntity.cs b/OpenAuth.Repository/Core/IntAutoGenEntity.cs new file mode 100644 index 00000000..b1d519e2 --- /dev/null +++ b/OpenAuth.Repository/Core/IntAutoGenEntity.cs @@ -0,0 +1,26 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace OpenAuth.Repository.Core +{ + /// + /// 数据库Id为numberic且为数据库自动生成的数据实体使用该基类,用法同Entity + /// 该场景通常为SqlServer的自动增长类型和Oracle自带的Sequence + /// + public class IntAutoGenEntity :BaseEntity + { + [Browsable(false)] + [Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int Id { get; set; } + public override bool KeyIsNull() + { + return Id == 0; + } + + public override void GenerateDefaultKeyVal() + { + //主键自动增长类型,可以不用该方法生成主键,设置该方法为空方法即可 + } + } +} \ No newline at end of file