diff --git a/Infrastructure/DynamicLinq.cs b/Infrastructure/DynamicLinq.cs index cb04c9fe..09f3ace4 100644 --- a/Infrastructure/DynamicLinq.cs +++ b/Infrastructure/DynamicLinq.cs @@ -87,11 +87,24 @@ namespace Infrastructure case ">=": filter = Expression.GreaterThanOrEqual(left, right); break; + case "!=": + filter = Expression.NotEqual(left, right); + break; case "like": filter = Expression.Call(left, typeof(string).GetMethod("Contains", new Type[] { typeof(string) }), Expression.Constant(filterObj.Value)); break; + case "not in": + var listExpression = Expression.Constant(filterObj.Value.Split(',').ToList()); //数组 + var method = typeof(List).GetMethod("Contains", new Type[] { typeof(string) }); //Contains语句 + filter = Expression.Not(Expression.Call(listExpression, method, left)); + break; + case "in": + var lExp = Expression.Constant(filterObj.Value.Split(',').ToList()); //数组 + var methodInfo = typeof(List).GetMethod("Contains", new Type[] { typeof(string) }); //Contains语句 + filter = Expression.Call(lExp, methodInfo, left); + break; } return filter; diff --git a/OpenAuth.App/OpenAuth.App.csproj b/OpenAuth.App/OpenAuth.App.csproj index 9785a8f7..2f68affc 100644 --- a/OpenAuth.App/OpenAuth.App.csproj +++ b/OpenAuth.App/OpenAuth.App.csproj @@ -48,6 +48,10 @@ + + {5FEAEC9A-4F1E-4EE7-B377-9DB1B0870DAC} + Infrastructure + {6108da8e-92a1-4abe-b9f5-26d64d55ca2c} OpenAuth.Domain diff --git a/OpenAuth.App/OrgManagerApp.cs b/OpenAuth.App/OrgManagerApp.cs index 45a24137..35d0454e 100644 --- a/OpenAuth.App/OrgManagerApp.cs +++ b/OpenAuth.App/OrgManagerApp.cs @@ -77,5 +77,10 @@ namespace OpenAuth.App { return _repository.Find(u => u.ParentId == orgId); } + + public void DelOrg(int Id) + { + _repository.Delete(u =>u.Id ==Id); + } } } diff --git a/OpenAuth.Domain/Interface/IRepository.cs b/OpenAuth.Domain/Interface/IRepository.cs index 17f882a6..f0543e58 100644 --- a/OpenAuth.Domain/Interface/IRepository.cs +++ b/OpenAuth.Domain/Interface/IRepository.cs @@ -35,6 +35,16 @@ namespace OpenAuth.Domain.Interface void Delete(T entity); + /// + /// 批量更新 + /// + void Update(Expression> exp, T entity); + + /// + /// 批量删除 + /// + void Delete(Expression> exp); + void Save(); } } \ No newline at end of file diff --git a/OpenAuth.Mvc/Controllers/OrgManagerController.cs b/OpenAuth.Mvc/Controllers/OrgManagerController.cs index 6a12e3f1..f4ec9440 100644 --- a/OpenAuth.Mvc/Controllers/OrgManagerController.cs +++ b/OpenAuth.Mvc/Controllers/OrgManagerController.cs @@ -35,6 +35,14 @@ namespace OpenAuth.Mvc.Controllers return JsonHelper.Instance.Serialize(_orgApp.LoadChildren(id)); } - + public void DelOrg(string json) + { + var delObj = JsonHelper.Instance.Deserialize(json); + foreach (var obj in delObj) + { + _orgApp.DelOrg(obj.Id); + } + + } } } \ No newline at end of file diff --git a/OpenAuth.Mvc/Views/OrgManager/Index.cshtml b/OpenAuth.Mvc/Views/OrgManager/Index.cshtml index ebb60a71..2d070765 100644 --- a/OpenAuth.Mvc/Views/OrgManager/Index.cshtml +++ b/OpenAuth.Mvc/Views/OrgManager/Index.cshtml @@ -36,54 +36,42 @@ $.getJSON("OrgManager/LoadOrg", function (json) { var zTreeObj = $.fn.zTree.init($("#orgTree"), setting, json); - - $('#test-datagrid-array').datagrid({ - gridTitle: '机构列表显示', - showToolbar: true, - toolbarItem: 'all', - columns: [ - { name: 'Name', width: '150', label: '机构名称' }, - { name: 'CreateTime', width: '120', label: '登记日期' } - ], - data: json, - hiddenFields: ['Id'], - editUrl: 'ajaxDone1.html', - delUrl: 'ajaxDone1.html', - editMode: 'dialog', - fullGrid: true, - showLinenumber: true, - showCheckboxcol: true, - paging: false, - filterMult: false, - showTfoot: true - }); + zTreeObj.expandAll(true); + loadDataGrid(json); }); }); + function loadDataGrid(data) { + + $('#test-datagrid-array').datagrid({ + gridTitle: '机构列表显示', + showToolbar: true, + toolbarItem: 'all', + columns: [ + { name: 'Name', width: '150', label: '机构名称' }, + { name: 'CreateTime', width: '120', label: '登记日期' } + ], + data: data, + hiddenFields: ['Id'], + editUrl: 'OrgManager/AddOrg', + delUrl: 'OrgManager/DelOrg', + editMode: 'dialog', + fullGrid: true, + showLinenumber: true, + showCheckboxcol: true, + paging: false, + filterMult: false, + showTfoot: true + }); + } + function zTreeOnClick(event, treeId, treeNode) { $.getJSON("OrgManager/LoadChildren", { id: treeNode.Id }, function (json) { - $('#test-datagrid-array').destroy(); - $('#test-datagrid-array').datagrid({ - gridTitle: '机构列表显示', - showToolbar: true, - toolbarItem: 'all', - columns: [ - { name: 'Name', width: '150', label: '机构名称' }, - { name: 'CreateTime', width: '120', label: '登记日期' } - ], - data: json, - hiddenFields: ['Id'], - editUrl: 'ajaxDone1.html', - delUrl: 'ajaxDone1.html', - editMode: 'dialog', - fullGrid: true, - showLinenumber: true, - showCheckboxcol: true, - paging: false, - filterMult: false, - showTfoot: true - }); + + $('#ztree-detail').empty().append('
'); + loadDataGrid(json); + }); } diff --git a/OpenAuth.Mvc/Web.config b/OpenAuth.Mvc/Web.config index 750dd0e9..28973d2e 100644 --- a/OpenAuth.Mvc/Web.config +++ b/OpenAuth.Mvc/Web.config @@ -8,7 +8,7 @@
-
+
@@ -18,20 +18,20 @@ - - - - - - + + + + + + - + - + @@ -78,6 +78,10 @@ + + + + diff --git a/OpenAuth.Repository/BaseRepository.cs b/OpenAuth.Repository/BaseRepository.cs index a28fba4c..f444c6e8 100644 --- a/OpenAuth.Repository/BaseRepository.cs +++ b/OpenAuth.Repository/BaseRepository.cs @@ -2,6 +2,7 @@ using System.Data.Entity.Migrations; using System.Linq; using System.Linq.Expressions; +using EntityFramework.Extensions; using OpenAuth.Domain.Interface; using OpenAuth.Repository.Models; using Infrastructure; @@ -70,6 +71,16 @@ namespace OpenAuth.Repository Save(); } + public void Update(Expression> exp, T entity) + { + Context.Set().Where(exp).Update(u => entity); + } + + public void Delete(Expression> exp) + { + Context.Set().Where(exp).Delete(); + } + public void Save() { Context.SaveChanges(); diff --git a/OpenAuth.Repository/OpenAuth.Repository.csproj b/OpenAuth.Repository/OpenAuth.Repository.csproj index 5ebb6d40..77199f44 100644 --- a/OpenAuth.Repository/OpenAuth.Repository.csproj +++ b/OpenAuth.Repository/OpenAuth.Repository.csproj @@ -36,6 +36,9 @@ ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll + + ..\packages\EntityFramework.Extended.6.1.0.168\lib\net45\EntityFramework.Extended.dll + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll diff --git a/OpenAuth.Repository/packages.config b/OpenAuth.Repository/packages.config index d39ff234..b75ba69e 100644 --- a/OpenAuth.Repository/packages.config +++ b/OpenAuth.Repository/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file