diff --git a/OpenAuth.App/BuilderTable/BuilderTableApp.cs b/OpenAuth.App/BuilderTable/BuilderTableApp.cs index 3ff5203b..e5a92cdd 100644 --- a/OpenAuth.App/BuilderTable/BuilderTableApp.cs +++ b/OpenAuth.App/BuilderTable/BuilderTableApp.cs @@ -100,7 +100,7 @@ namespace OpenAuth.App return result; } - public string Add(AddOrUpdateBuilderTableReq req) + public void Check(AddOrUpdateBuilderTableReq req) { if (string.IsNullOrEmpty(req.TableName)) { @@ -112,11 +112,18 @@ namespace OpenAuth.App throw new Exception("模块名称不能为空"); } - if (string.IsNullOrEmpty(req.Namespace)) + if(!string.IsNullOrEmpty(req.ParentTableId)) { - throw new Exception("命名空间不能为空"); + if(string.IsNullOrEmpty(req.ForeignKey)) + { + throw new Exception("当前表为子表时,外键不能为空"); + } } + } + public string Add(AddOrUpdateBuilderTableReq req) + { + Check(req); var obj = AddTableAndColumns(req.MapTo()); UnitWork.Save(); @@ -176,6 +183,7 @@ namespace OpenAuth.App public void Update(AddOrUpdateBuilderTableReq obj) { + Check(obj); var user = _auth.GetCurrentUser().User; UnitWork.Update(u => u.Id == obj.Id, u => new BuilderTable {