mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
可访问机构控制调整到UserSession
This commit is contained in:
parent
e49dcfd793
commit
8dcbae1517
@ -15,7 +15,7 @@ namespace OpenAuth.App
|
||||
|
||||
public IEnumerable<Category> Get(string type)
|
||||
{
|
||||
return UnitWork.Find<Category>(u => u.TypeId == type);
|
||||
return Repository.Find(u => u.TypeId == type);
|
||||
}
|
||||
|
||||
public void Add(Category category)
|
||||
@ -24,19 +24,12 @@ namespace OpenAuth.App
|
||||
{
|
||||
category.Id = Guid.NewGuid().ToString();
|
||||
}
|
||||
UnitWork.Add(category);
|
||||
UnitWork.Save();
|
||||
Repository.Add(category);
|
||||
}
|
||||
|
||||
public void Update(Category category)
|
||||
{
|
||||
UnitWork.Update<Category>(u =>u.Id,category);
|
||||
UnitWork.Save();
|
||||
}
|
||||
|
||||
public void Delete(string[] ids)
|
||||
{
|
||||
UnitWork.Delete<Category>(u => ids.Contains(u.Id));
|
||||
Repository.Update(u =>u.Id,category);
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,28 +95,5 @@ namespace OpenAuth.App
|
||||
return UnitWork.Find<Org>(u => moduleIds.Contains(u.Id)).ToList();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到部门的所有子部门
|
||||
/// <para>如果orgId为空,表示取得所有部门</para>
|
||||
/// </summary>
|
||||
public TableData LoadAllChildren(string orgId)
|
||||
{
|
||||
string cascadeId = ".0.";
|
||||
if (!string.IsNullOrEmpty(orgId))
|
||||
{
|
||||
var org = Repository.FindSingle(u => u.Id == orgId);
|
||||
if (org == null)
|
||||
throw new Exception("未能找到指定对象信息");
|
||||
cascadeId = org.CascadeId;
|
||||
}
|
||||
|
||||
var query = Repository.Find(u => u.CascadeId.Contains(cascadeId));
|
||||
return new TableData
|
||||
{
|
||||
data = query.ToList(),
|
||||
count = query.Count(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -70,17 +70,7 @@ namespace OpenAuth.Mvc.Controllers
|
||||
return JsonHelper.Instance.Serialize(Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载机构的全部下级机构
|
||||
/// </summary>
|
||||
/// <param name="orgId">机构ID</param>
|
||||
/// <returns></returns>
|
||||
public string LoadChildren(string orgId)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(OrgApp.LoadAllChildren(orgId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// 删除指定ID的组织
|
||||
/// <para>Id为逗号分开的字符串</para>
|
||||
/// </summary>
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.Response;
|
||||
using OpenAuth.App.SSO;
|
||||
@ -8,6 +8,7 @@ namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取登录用户的全部信息
|
||||
/// <para>所有和当前登录用户相关的操作都在这里</para>
|
||||
/// </summary>
|
||||
public class UserSessionController : BaseController
|
||||
{
|
||||
@ -28,21 +29,27 @@ namespace OpenAuth.Mvc.Controllers
|
||||
/// <returns></returns>
|
||||
public string GetModules(string pId)
|
||||
{
|
||||
var query = user.Modules;
|
||||
string cascadeId = ".0.";
|
||||
if (!string.IsNullOrEmpty(pId))
|
||||
{
|
||||
query = query.Where(u => u.ParentId == pId).ToList();
|
||||
var obj = user.Modules.SingleOrDefault(u => u.Id == pId);
|
||||
if (obj == null)
|
||||
throw new Exception("未能找到指定对象信息");
|
||||
cascadeId = obj.CascadeId;
|
||||
}
|
||||
var data = new TableData
|
||||
|
||||
var query = user.Modules.Where(u => u.CascadeId.Contains(cascadeId));
|
||||
|
||||
return JsonHelper.Instance.Serialize(new TableData
|
||||
{
|
||||
data = query,
|
||||
data = query.ToList(),
|
||||
count = query.Count(),
|
||||
};
|
||||
return JsonHelper.Instance.Serialize(data);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 普通的List
|
||||
/// 获取用户可访问的模块列表
|
||||
/// </summary>
|
||||
public string QueryModuleList()
|
||||
{
|
||||
@ -52,12 +59,38 @@ namespace OpenAuth.Mvc.Controllers
|
||||
|
||||
/// <summary>
|
||||
/// 获取登录用户可访问的所有部门
|
||||
/// <para>用于树状结构</para>
|
||||
/// </summary>
|
||||
public string GetOrgs()
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(user.Orgs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载机构的全部下级机构
|
||||
/// </summary>
|
||||
/// <param name="orgId">机构ID</param>
|
||||
/// <returns></returns>
|
||||
public string GetSubOrgs(string orgId)
|
||||
{
|
||||
string cascadeId = ".0.";
|
||||
if (!string.IsNullOrEmpty(orgId))
|
||||
{
|
||||
var org = user.Orgs.SingleOrDefault(u => u.Id == orgId);
|
||||
if (org == null)
|
||||
throw new Exception("未能找到指定对象信息");
|
||||
cascadeId = org.CascadeId;
|
||||
}
|
||||
|
||||
var query = user.Orgs.Where(u => u.CascadeId.Contains(cascadeId));
|
||||
|
||||
return JsonHelper.Instance.Serialize(new TableData
|
||||
{
|
||||
data = query.ToList(),
|
||||
count = query.Count(),
|
||||
});
|
||||
}
|
||||
|
||||
//获取当前页面菜单
|
||||
public string GetButtonns()
|
||||
{
|
||||
|
@ -46,8 +46,11 @@ layui.config({
|
||||
};
|
||||
var load = function () {
|
||||
$.getJSON(url, function (json) {
|
||||
zTreeObj = $.fn.zTree.init($("#tree"), setting, json);
|
||||
mainList({ typeId: json[0].Id });
|
||||
zTreeObj = $.fn.zTree.init($("#tree"), setting);
|
||||
var newNode = { Name: "根节点", Id: null, ParentId: "" };
|
||||
json.push(newNode);
|
||||
zTreeObj.addNodes(null, json);
|
||||
mainList({ typeId: "" });
|
||||
zTreeObj.expandAll(true);
|
||||
});
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ layui.config({
|
||||
$.extend(config, options);
|
||||
}
|
||||
table.reload('mainList', {
|
||||
url: '/OrgManager/LoadChildren',
|
||||
url: '/UserSession/GetSubOrgs',
|
||||
where: config
|
||||
});
|
||||
}
|
||||
|
@ -17,13 +17,6 @@ namespace OpenAuth.UnitTest
|
||||
_app = AutofacExt.GetFromFac<OrgManagerApp>();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LoadChildren()
|
||||
{
|
||||
var data= _app.LoadAllChildren("fb086c51-4b41-4aa7-b54f-fb79632aaaf9");
|
||||
Debug.WriteLine(JsonHelper.Instance.Serialize(data));
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void Add()
|
||||
|
@ -11,11 +11,9 @@
|
||||
|
||||
using System;
|
||||
using System.Web.Http;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Cache;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.App.SSO;
|
||||
using System.Web.Mvc;
|
||||
using OpenAuth.App.Response;
|
||||
|
||||
namespace OpenAuth.WebApi.Areas.SSO.Controllers
|
||||
|
Loading…
Reference in New Issue
Block a user