From 5e6445cbc9f53b66c30a983d5126585a61f743b9 Mon Sep 17 00:00:00 2001 From: yubao Date: Mon, 11 Dec 2017 00:27:24 +0800 Subject: [PATCH] ru --- OpenAuth.App/RevelanceManagerApp.cs | 21 +++++++++------------ OpenAuth.App/UserManagerApp.cs | 6 +++--- OpenAuth.Mvc/OpenAuth.Mvc.csproj | 1 - OpenAuth.Mvc/js/orgs.js | 7 +++++-- OpenAuth.Mvc/js/users.js | 9 ++++++--- OpenAuth.UnitTest/TestUser.cs | 2 +- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/OpenAuth.App/RevelanceManagerApp.cs b/OpenAuth.App/RevelanceManagerApp.cs index 6262ab2b..c6da4c2f 100644 --- a/OpenAuth.App/RevelanceManagerApp.cs +++ b/OpenAuth.App/RevelanceManagerApp.cs @@ -2,15 +2,12 @@ using System.Collections.Generic; using System.Linq; using OpenAuth.Repository.Domain; -using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class RevelanceManagerApp + public class RevelanceManagerApp :BaseApp { - public IUnitWork _unitWork { get; set; } - /// /// 添加关联 /// 比如给用户分配资源,那么firstId就是用户ID,secIds就是资源ID列表 @@ -24,7 +21,7 @@ namespace OpenAuth.App public void Assign(string key, ILookup idMaps) { DeleteBy(key, idMaps); - _unitWork.BatchAdd((from sameVals in idMaps + UnitWork.BatchAdd((from sameVals in idMaps from value in sameVals select new Relevance { @@ -33,7 +30,7 @@ namespace OpenAuth.App SecondId = value, OperateTime = DateTime.Now }).ToArray()); - _unitWork.Save(); + UnitWork.Save(); } @@ -49,7 +46,7 @@ namespace OpenAuth.App { foreach (var value in sameVals) { - _unitWork.Delete(u => u.Key == key && u.FirstId == sameVals.Key && u.SecondId == value); + Repository.Delete(u => u.Key == key && u.FirstId == sameVals.Key && u.SecondId == value); } } } @@ -67,7 +64,7 @@ namespace OpenAuth.App public void DeleteBy(string key, params string[] firstIds) { - _unitWork.Delete(u => firstIds.Contains(u.FirstId) && u.Key == key); + Repository.Delete(u => firstIds.Contains(u.FirstId) && u.Key == key); } /// @@ -78,7 +75,7 @@ namespace OpenAuth.App public void AddRelevance(string key, ILookup idMaps) { DeleteBy(key, idMaps); - _unitWork.BatchAdd((from sameVals in idMaps + UnitWork.BatchAdd((from sameVals in idMaps from value in sameVals select new Relevance { @@ -87,7 +84,7 @@ namespace OpenAuth.App SecondId = value, OperateTime = DateTime.Now }).ToArray()); - _unitWork.Save(); + UnitWork.Save(); } /// @@ -101,12 +98,12 @@ namespace OpenAuth.App { if (returnSecondIds) { - return _unitWork.Find(u => u.Key == key + return Repository.Find(u => u.Key == key && ids.Contains(u.FirstId)).Select(u => u.SecondId).ToList(); } else { - return _unitWork.Find(u => u.Key == key + return Repository.Find(u => u.Key == key && ids.Contains(u.SecondId)).Select(u => u.FirstId).ToList(); } } diff --git a/OpenAuth.App/UserManagerApp.cs b/OpenAuth.App/UserManagerApp.cs index 7cd5d65a..e34c6fd4 100644 --- a/OpenAuth.App/UserManagerApp.cs +++ b/OpenAuth.App/UserManagerApp.cs @@ -26,8 +26,8 @@ namespace OpenAuth.App int records = 0; if (string.IsNullOrEmpty(request.orgId)) { - users = UnitWork.Find(null).OrderBy(u => u.Id).Skip((request.page - 1) * request.limit).Take(request.limit); - records = UnitWork.GetCount(); + users = Repository.Find(null).OrderBy(u => u.Id).Skip((request.page - 1) * request.limit).Take(request.limit); + records = Repository.GetCount(); } else { @@ -37,7 +37,7 @@ namespace OpenAuth.App .OrderBy(u => u.Name) .Skip((request.page - 1) * request.limit) .Take(request.limit); - records = UnitWork.GetCount(); + records = Repository.GetCount(u => userIds.Contains(u.Id)); } var userviews = new List(); diff --git a/OpenAuth.Mvc/OpenAuth.Mvc.csproj b/OpenAuth.Mvc/OpenAuth.Mvc.csproj index a8d1a7c4..108bec6b 100644 --- a/OpenAuth.Mvc/OpenAuth.Mvc.csproj +++ b/OpenAuth.Mvc/OpenAuth.Mvc.csproj @@ -357,7 +357,6 @@ - diff --git a/OpenAuth.Mvc/js/orgs.js b/OpenAuth.Mvc/js/orgs.js index 64ca4678..f58c0597 100644 --- a/OpenAuth.Mvc/js/orgs.js +++ b/OpenAuth.Mvc/js/orgs.js @@ -46,8 +46,11 @@ layui.config({ }; var load = function () { $.getJSON(url, function (json) { - zTreeObj = $.fn.zTree.init($("#tree"), setting, json); - mainList({ orgId: json[0].Id }); + zTreeObj = $.fn.zTree.init($("#tree"), setting); + var newNode = { Name: "根节点", Id: null, ParentId: "" }; + json.push(newNode); + zTreeObj.addNodes(null, json); + mainList({ orgId: "" }); zTreeObj.expandAll(true); }); }; diff --git a/OpenAuth.Mvc/js/users.js b/OpenAuth.Mvc/js/users.js index 5045e098..45e4cc45 100644 --- a/OpenAuth.Mvc/js/users.js +++ b/OpenAuth.Mvc/js/users.js @@ -35,7 +35,7 @@ layui.config({ enable: true, idKey: 'Id', pIdKey: 'ParentId', - rootPId: 'null' + rootPId: "" } }, callback: { @@ -46,8 +46,11 @@ layui.config({ }; var load = function () { $.getJSON(url, function (json) { - zTreeObj = $.fn.zTree.init($("#tree"), setting, json); - mainList({ orgId: json[0].Id }); + zTreeObj = $.fn.zTree.init($("#tree"), setting); + var newNode = { Name: "根节点", Id: null,ParentId:"" }; + json.push(newNode); + zTreeObj.addNodes(null, json); + mainList({ orgId: "" }); zTreeObj.expandAll(true); }); }; diff --git a/OpenAuth.UnitTest/TestUser.cs b/OpenAuth.UnitTest/TestUser.cs index 52e965be..e4e70ddd 100644 --- a/OpenAuth.UnitTest/TestUser.cs +++ b/OpenAuth.UnitTest/TestUser.cs @@ -48,7 +48,7 @@ namespace OpenAuth.UnitTest { var request = new QueryUserListReq { - orgId = "543a9fcf-4770-4fd9-865f-030e562be238", + orgId = "", page = 1, limit = 30 };