这是有史以来最艰难的一次提交,不生则死!

This commit is contained in:
yubao 2017-11-28 23:54:49 +08:00
parent 9c37623d7f
commit 6a3fa6fd3d
114 changed files with 779 additions and 2373 deletions

View File

@ -2,8 +2,32 @@
{
public class Response
{
public bool Status = true;
public string Message = "操作成功";
public dynamic Result;
/// <summary>
/// 操作消息【当Status不为 200时显示详细的错误信息】
/// </summary>
public string Message { get; set; }
/// <summary>
/// 操作状态码200为正常
/// </summary>
public int Code { get; set; }
public Response()
{
Code = 200;
}
}
/// <summary>
/// WEBAPI通用返回泛型基类
/// </summary>
/// <typeparam name="T"></typeparam>
public class Response<T> : Response
{
/// <summary>
/// 回传的结果
/// </summary>
public T Result { get; set; }
}
}

View File

@ -0,0 +1,28 @@
using OpenAuth.Domain.Interface;
namespace OpenAuth.Domain.Service
{
/// <summary>
/// 权限分配工厂,根据是否是开发者账号创建
/// </summary>
public class AuthoriseFactory
{
public IUnitWork _unitWork { get; set; }
public AuthoriseService Create(string loginuser)
{
if (loginuser == "System")
{
return new SystemAuthService();
}
else
{
return new AuthoriseService()
{
_unitWork = _unitWork,
User = _unitWork.FindSingle<User>(u =>u.Account == loginuser)
};
}
}
}
}

View File

@ -0,0 +1,131 @@
// ***********************************************************************
// Assembly : OpenAuth.Domain
// Author : yubaolee
// Created : 04-21-2016
//
// Last Modified By : yubaolee
// Last Modified On : 04-21-2016
// Contact : Microsoft
// File: AuthenService.cs
// ***********************************************************************
using OpenAuth.Domain.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenAuth.Domain.Service
{
/// <summary>
/// 领域服务
/// <para>用户授权服务</para>
/// </summary>
public class AuthoriseService
{
public IUnitWork _unitWork { get; set; }
protected User _user;
private List<string> _userRoleIds; //用户角色GUID
public List<Module> Modules
{
get { return GetModulesQuery().ToList(); }
}
public List<Role> Roles
{
get { return GetRolesQuery().ToList(); }
}
public List<ModuleElement> ModuleElements
{
get { return GetModuleElementsQuery().ToList(); }
}
public List<Resource> Resources
{
get { return GetResourcesQuery().ToList(); }
}
public List<Org> Orgs
{
get { return GetOrgsQuery().ToList(); }
}
public User User
{
get { return _user; }
set
{
_user = value;
_userRoleIds = _unitWork.Find<Relevance>(u => u.FirstId == _user.Id && u.Key == "UserRole").Select(u => u.SecondId).ToList();
}
}
public void Check(string userName, string password)
{
var _user = _unitWork.FindSingle<User>(u => u.Account == userName);
if (_user == null)
{
throw new Exception("用户帐号不存在");
}
_user.CheckPassword(password);
}
/// <summary>
/// 用户可访问的机构
/// </summary>
/// <returns>IQueryable&lt;Org&gt;.</returns>
public virtual IQueryable<Org> GetOrgsQuery()
{
var orgids = _unitWork.Find<Relevance>(
u =>
(u.FirstId == _user.Id && u.Key == "UserOrg") ||
(u.Key == "RoleOrg" && _userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId);
return _unitWork.Find<Org>(u => orgids.Contains(u.Id));
}
/// <summary>
/// 获取用户可访问的资源
/// </summary>
/// <returns>IQueryable&lt;Resource&gt;.</returns>
public virtual IQueryable<Resource> GetResourcesQuery()
{
var resourceIds = _unitWork.Find<Relevance>(
u =>
(u.FirstId == _user.Id && u.Key == "UserResource") ||
(u.Key == "RoleResource" && _userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId);
return _unitWork.Find<Resource>(u => resourceIds.Contains(u.Id));
}
/// <summary>
/// 模块菜单权限
/// </summary>
public virtual IQueryable<ModuleElement> GetModuleElementsQuery()
{
var elementIds = _unitWork.Find<Relevance>(
u =>
(u.FirstId == _user.Id && u.Key == "UserElement") ||
(u.Key == "RoleElement" && _userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId);
return _unitWork.Find<ModuleElement>(u => elementIds.Contains(u.Id));
}
/// <summary>
/// 得出最终用户拥有的模块
/// </summary>
public virtual IQueryable<Module> GetModulesQuery()
{
var moduleIds = _unitWork.Find<Relevance>(
u =>
(u.FirstId == _user.Id && u.Key == "UserModule") ||
(u.Key == "RoleModule" && _userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId);
return _unitWork.Find<Module>(u => moduleIds.Contains(u.Id)).OrderBy(u => u.SortNo);
}
//用户角色
public virtual IQueryable<Role> GetRolesQuery()
{
return _unitWork.Find<Role>(u => _userRoleIds.Contains(u.Id));
}
}
}

View File

@ -10,31 +10,17 @@ namespace OpenAuth.App
{
public class CategoryManagerApp
{
private ICategoryRepository _repository;
private IUnitWork _unitWork;
public IUnitWork _unitWork { get; set; }
public CategoryManagerApp(ICategoryRepository repository,
IUnitWork unitWork)
public CategoryManagerApp(IUnitWork unitWork)
{
_repository = repository;
_unitWork = unitWork;
}
public int GetCategoryCntInOrg(string orgId)
{
if (orgId == string.Empty)
{
return _repository.Find(null).Count();
}
else
{
return _repository.GetCategoryCntInOrgs(GetSubCategories(orgId));
}
}
public List<Category> LoadAll()
{
return _repository.Find(null).ToList();
return _unitWork.Find<Category>(null).ToList();
}
/// <summary>
@ -47,13 +33,13 @@ namespace OpenAuth.App
if (parentId == string.Empty)
{
categories = _unitWork.Find<Category>(pageindex, pagesize);
total = _repository.GetCount();
total = _unitWork.GetCount<Category>();
}
else
{
var ids = GetSubCategories(parentId);
categories = _unitWork.Find<Category>(pageindex, pagesize, "SortNo", u => ids.Contains(u.Id));
total = _repository.GetCategoryCntInOrgs(ids);
// total = _repository.GetCategoryCntInOrgs(ids);
}
var query = from c in categories
@ -72,9 +58,7 @@ namespace OpenAuth.App
return new GridData()
{
count = total,
total = (int)Math.Ceiling((double)total/pagesize),
data = query.ToList(),
page = pageindex
data = query.ToList()
};
}
@ -84,13 +68,13 @@ namespace OpenAuth.App
private string[] GetSubCategories(string orgId)
{
var category = Find(orgId);
var categories = _repository.Find(u => u.CascadeId.Contains(category.CascadeId)).Select(u => u.Id).ToArray();
var categories = _unitWork.Find<Category>(u => u.CascadeId.Contains(category.CascadeId)).Select(u => u.Id).ToArray();
return categories;
}
public Category Find(string id)
{
var category = _repository.FindSingle(u => u.Id == id);
var category = _unitWork.FindSingle<Category>(u => u.Id == id);
if (category == null) return new Category();
return category;
@ -98,7 +82,7 @@ namespace OpenAuth.App
public void Delete(string[] ids)
{
_repository.Delete(u =>ids.Contains(u.Id));
_unitWork.Delete<Category>(u =>ids.Contains(u.Id));
}
public void AddOrUpdate(Category model)
@ -109,23 +93,24 @@ namespace OpenAuth.App
if (category.Id == string.Empty)
{
_repository.Add(category);
_unitWork.Add(category);
}
else
{
//获取旧的的CascadeId
var CascadeId = _repository.FindSingle(o => o.Id == category.Id).CascadeId;
var CascadeId = _unitWork.FindSingle<Category>(o => o.Id == category.Id).CascadeId;
//根据CascadeId查询子分类
var categorys = _repository.Find(u => u.CascadeId.Contains(CascadeId) && u.Id != category.Id).OrderBy(u => u.CascadeId).ToList();
var categorys = _unitWork.Find<Category>(u => u.CascadeId.Contains(CascadeId) && u.Id != category.Id).OrderBy(u => u.CascadeId).ToList();
_repository.Update(category);
_unitWork.Update(category);
//更新子分类的CascadeId
foreach (var a in categorys)
{
ChangeModuleCascade(a);
_repository.Update(a);
_unitWork.Update(a);
}
_unitWork.Save();
}
}
@ -136,7 +121,7 @@ namespace OpenAuth.App
{
string cascadeId;
int currentCascadeId = 1; //当前结点的级联节点最后一位
var sameLevels = _repository.Find(o => o.ParentId == org.ParentId && o.Id != org.Id);
var sameLevels = _unitWork.Find<Category>(o => o.ParentId == org.ParentId && o.Id != org.Id);
foreach (var obj in sameLevels)
{
int objCascadeId = int.Parse(obj.CascadeId.TrimEnd('.').Split('.').Last());
@ -145,7 +130,7 @@ namespace OpenAuth.App
if (org.ParentId != null && org.ParentId != string.Empty)
{
var parentOrg = _repository.FindSingle(o => o.Id == org.ParentId);
var parentOrg = _unitWork.FindSingle<Category>(o => o.Id == org.ParentId);
if (parentOrg != null)
{
cascadeId = parentOrg.CascadeId + currentCascadeId +".";

View File

@ -1,70 +0,0 @@
// ***********************************************************************
// Assembly : OpenAuth.App
// Author : Yubao Li
// Created : 12-02-2015
//
// Last Modified By : Yubao Li
// Last Modified On : 12-02-2015
// ***********************************************************************
// <copyright file="ModuleElementManagerApp.cs" company="">
// Copyright (c) . All rights reserved.
// </copyright>
// <summary>模块元素</summary>
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Infrastructure;
using OpenAuth.App.SSO;
using OpenAuth.App.ViewModel;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using OpenAuth.Domain.Service;
namespace OpenAuth.App
{
public class ModuleElementManagerApp
{
private ModuleEleManService _moduleEleManService;
public ModuleElementManagerApp(ModuleEleManService moduleEleManService)
{
_moduleEleManService = moduleEleManService;
}
public void AddOrUpdate(ModuleElement model)
{
var newbtn = new ModuleElement();
model.CopyTo(newbtn);
_moduleEleManService.AddOrUpdate(newbtn);
}
public IEnumerable<ModuleElement> LoadByModuleId(string id)
{
string username = AuthUtil.GetUserName();
return _moduleEleManService.LoadByModuleId(username, id);
}
/// <summary>
/// 获取带有授权状态的菜单列表
/// </summary>
/// <param name="accessType">授权类型当前有RoleElement/UserElement</param>
/// <param name="firstId">
/// 当为RoleElement时表示RoleId
/// 当为UserElement时表示UserId
/// </param>
/// <param name="moduleId">模块ID</param>
public List<dynamic> LoadWithAccess(string accessType, string firstId, string moduleId)
{
string username = AuthUtil.GetUserName();
return _moduleEleManService.LoadWithAccess(username, accessType, firstId, moduleId);
}
public void Delete(string[] objs)
{
_moduleEleManService.Delete(objs);
}
}
}

View File

@ -1,26 +1,22 @@
using OpenAuth.Domain;
using System.Collections.Generic;
using OpenAuth.Domain.Interface;
using OpenAuth.Domain.Service;
namespace OpenAuth.App
{
public class ModuleManagerApp
{
private ModuleManService _moduleManService;
public ModuleManagerApp(ModuleManService moduleManService)
{
_moduleManService = moduleManService;
}
public IUnitWork _unitWork { get; set; }
public void Delete(string id)
{
_moduleManService.Delete(id);
// _unitWork.Delete<Module>(id);
}
public void AddOrUpdate(Module vm)
{
_moduleManService.AddOrUpdate(vm);
// _moduleManService.AddOrUpdate(vm);
}
#region /
@ -32,7 +28,7 @@ namespace OpenAuth.App
/// <param name="userId">The user unique identifier.</param>
public List<Module> LoadForUser(string userId)
{
return _moduleManService.LoadForUser(userId);
return null;
}
/// <summary>
@ -41,7 +37,7 @@ namespace OpenAuth.App
/// <param name="roleId">The role unique identifier.</param>
public List<Module> LoadForRole(string roleId)
{
return _moduleManService.LoadForRole(roleId);
return null;
}
#endregion /

View File

@ -80,6 +80,8 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AuthoriseFactory.cs" />
<Compile Include="AuthoriseService.cs" />
<Compile Include="CategoryManagerApp.cs" />
<Compile Include="AuthorizeApp.cs" />
<Compile Include="Extention\IWF_Runtime.cs" />
@ -89,14 +91,12 @@
<Compile Include="Request\IdPageReq.cs" />
<Compile Include="Request\PageReq.cs" />
<Compile Include="Request\QueryUserListReq.cs" />
<Compile Include="RevelanceManagerApp.cs" />
<Compile Include="SystemAuthService.cs" />
<Compile Include="WFFormService.cs" />
<Compile Include="WFProcessInstanceService.cs" />
<Compile Include="WFSchemeService.cs" />
<Compile Include="ModuleElementManagerApp.cs" />
<Compile Include="ModuleManagerApp.cs" />
<Compile Include="ResourceManagerApp.cs" />
<Compile Include="RevelanceManagerApp.cs" />
<Compile Include="RoleManagerApp.cs" />
<Compile Include="SSO\AppInfo.cs" />
<Compile Include="SSO\AppInfoService.cs" />
<Compile Include="SSO\AuthUtil.cs" />
@ -106,7 +106,6 @@
<Compile Include="SSO\LoginResult.cs" />
<Compile Include="SSO\SSOAuthAttribute.cs" />
<Compile Include="SSO\UserAuthSession.cs" />
<Compile Include="StockManagerApp.cs" />
<Compile Include="UserManagerApp.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="OrgManagerApp.cs" />
@ -123,9 +122,9 @@
<Project>{5FEAEC9A-4F1E-4EE7-B377-9DB1B0870DAC}</Project>
<Name>Infrastructure</Name>
</ProjectReference>
<ProjectReference Include="..\OpenAuth.Domain\OpenAuth.Domain.csproj">
<Project>{6108da8e-92a1-4abe-b9f5-26d64d55ca2c}</Project>
<Name>OpenAuth.Domain</Name>
<ProjectReference Include="..\OpenAuth.Repository\OpenAuth.Repository.csproj">
<Project>{e8df8dea-e2cf-4bdb-8f4f-3f8205b0e03a}</Project>
<Name>OpenAuth.Repository</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>

View File

@ -9,47 +9,7 @@ namespace OpenAuth.App
{
public class OrgManagerApp
{
private IOrgRepository _repository;
private IRelevanceRepository _relevanceRepository;
public OrgManagerApp(IOrgRepository repository, IRelevanceRepository relevanceRepository)
{
_repository = repository;
_relevanceRepository = relevanceRepository;
}
public IList<Org> GetAll()
{
return _repository.LoadOrgs().ToList();
}
/// <summary>
/// 部门的直接子部门
/// <para>TODO:可以根据用户的喜好决定选择LoadAllChildren或LoadDirectChildren</para>
/// </summary>
/// <param name="orgId">The org unique identifier.</param>
/// <returns>IEnumerable{Org}.</returns>
public IList<Org> LoadDirectChildren(string orgId)
{
return _repository.Find(u => u.ParentId == orgId).ToList();
}
/// <summary>
/// 得到部门的所有子部门
/// <para>如果orgId为0表示取得所有部门</para>
/// </summary>
public GridData LoadAllChildren(string orgId)
{
var query = _repository.GetSubOrgs(orgId);
return new GridData
{
page = 1,
data = query.ToList(),
count = query.Count(),
total = 1
};
}
public IUnitWork _unitWork { get; set; }
/// <summary>
/// 添加部门
@ -62,23 +22,23 @@ namespace OpenAuth.App
ChangeModuleCascade(org);
if (org.Id == string.Empty)
{
_repository.Add(org);
_unitWork.Add(org);
}
else
{
//获取旧的的CascadeId
var CascadeId = _repository.FindSingle(o => o.Id == org.Id).CascadeId;
var CascadeId = _unitWork.FindSingle<Org>(o => o.Id == org.Id).CascadeId;
//根据CascadeId查询子部门
var orgs = _repository.Find(u => u.CascadeId.Contains(CascadeId) && u.Id != org.Id).OrderBy(u => u.CascadeId).ToList();
var orgs = _unitWork.Find<Org>(u => u.CascadeId.Contains(CascadeId) && u.Id != org.Id).OrderBy(u => u.CascadeId).ToList();
//更新操作
_repository.Update(org);
_unitWork.Update(org);
//更新子部门的CascadeId
foreach (var a in orgs)
{
ChangeModuleCascade(a);
_repository.Update(a);
_unitWork.Update(a);
}
}
@ -90,10 +50,10 @@ namespace OpenAuth.App
/// </summary>
public void DelOrg(string[] ids)
{
var delOrg = _repository.Find(u => ids.Contains(u.Id)).ToList();
var delOrg = _unitWork.Find<Org>(u => ids.Contains(u.Id)).ToList();
foreach (var org in delOrg)
{
_repository.Delete(u => u.CascadeId.Contains(org.CascadeId));
_unitWork.Delete<Org>(u => u.CascadeId.Contains(org.CascadeId));
}
}
@ -107,17 +67,17 @@ namespace OpenAuth.App
{
//用户角色
var userRoleIds =
_relevanceRepository.Find(u => u.FirstId == userId && u.Key == "UserRole").Select(u => u.SecondId).ToList();
_unitWork.Find<Relevance>(u => u.FirstId == userId && u.Key == "UserRole").Select(u => u.SecondId).ToList();
//用户角色与自己分配到的角色ID
var moduleIds =
_relevanceRepository.Find(
_unitWork.Find<Relevance>(
u =>
(u.FirstId == userId && u.Key == "UserOrg") ||
(u.Key == "RoleOrg" && userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId).ToList();
if (!moduleIds.Any()) return new List<Org>();
return _repository.Find(u => moduleIds.Contains(u.Id)).ToList();
return _unitWork.Find<Org>(u => moduleIds.Contains(u.Id)).ToList();
}
/// <summary>
@ -127,11 +87,40 @@ namespace OpenAuth.App
public List<Org> LoadForRole(string roleId)
{
var moduleIds =
_relevanceRepository.Find(u => u.FirstId == roleId && u.Key == "RoleOrg")
_unitWork.Find<Relevance>(u => u.FirstId == roleId && u.Key == "RoleOrg")
.Select(u => u.SecondId)
.ToList();
if (!moduleIds.Any()) return new List<Org>();
return _repository.Find(u => moduleIds.Contains(u.Id)).ToList();
return _unitWork.Find<Org>(u => moduleIds.Contains(u.Id)).ToList();
}
/// <summary>
/// 得到部门的所有子部门
/// <para>如果orgId为0表示取得所有部门</para>
/// </summary>
public GridData LoadAllChildren(string orgId)
{
var query = GetSubOrgs(orgId);
return new GridData
{
data = query.ToList(),
count = query.Count(),
};
}
public IEnumerable<Org> GetSubOrgs(string orgId)
{
string cascadeId = "0.";
if (!string.IsNullOrEmpty(orgId))
{
var org = _unitWork.FindSingle<Org>(u => u.Id == orgId);
if (org == null)
throw new Exception("未能找到指定对象信息");
cascadeId = org.CascadeId;
}
return _unitWork.Find<Org>(u => u.CascadeId.Contains(cascadeId));
}
#region
@ -141,7 +130,7 @@ namespace OpenAuth.App
{
string cascadeId;
int currentCascadeId = 1; //当前结点的级联节点最后一位
var sameLevels = _repository.Find(o => o.ParentId == org.ParentId && o.Id != org.Id);
var sameLevels = _unitWork.Find<Org>(o => o.ParentId == org.ParentId && o.Id != org.Id);
foreach (var obj in sameLevels)
{
int objCascadeId = int.Parse(obj.CascadeId.TrimEnd('.').Split('.').Last());
@ -150,7 +139,7 @@ namespace OpenAuth.App
if (org.ParentId != null && org.ParentId != string.Empty)
{
var parentOrg = _repository.FindSingle(o => o.Id == org.ParentId);
var parentOrg = _unitWork.FindSingle<Org>(o => o.Id == org.ParentId);
if (parentOrg != null)
{
cascadeId = parentOrg.CascadeId + currentCascadeId+".";

View File

@ -1,70 +0,0 @@

using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using Infrastructure;
using OpenAuth.App.ViewModel;
using OpenAuth.Domain.Service;
namespace OpenAuth.App
{
public class ResourceManagerApp
{
private ResManagerService _resManagerService;
public ResourceManagerApp(ResManagerService resManagerService)
{
_resManagerService = resManagerService;
}
public int GetResourceCntInOrg(string orgId)
{
return _resManagerService.GetResourceCntInOrg(orgId);
}
public List<Resource> LoadAll()
{
return _resManagerService.LoadAll();
}
/// <summary>
/// 加载一个节点下面的一个或全部Resources
/// </summary>
public dynamic Load(string username, string categoryId, int pageindex, int pagesize)
{
return _resManagerService.Load(username, categoryId, pageindex, pagesize);
}
public void Delete(string[] ids)
{
_resManagerService.Delete(ids);
}
public void AddOrUpdate(Resource model)
{
Resource resource = new Resource();
model.CopyTo(resource);
_resManagerService.AddOrUpdate(resource);
}
/// <summary>
/// 获取带有授权状态的菜单列表
/// </summary>
/// <param name="accessType">授权类型当前有RoleResource/UserResource</param>
/// <param name="firstId">
/// 当为RoleResource时表示RoleId
/// 当为UserResource时表示UserId
/// </param>
/// <param name="cId">分类ID</param>
public List<dynamic> LoadWithAccess(string username, string accessType, string firstId, string cId)
{
return _resManagerService.LoadWithAccess(username, accessType, firstId, cId);
}
}
}

View File

@ -1,44 +1,93 @@

using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using Infrastructure;
using OpenAuth.App.ViewModel;
namespace OpenAuth.App
{
public class RevelanceManagerApp
{
private readonly IRelevanceRepository _relevanceRepository;
public RevelanceManagerApp(IRelevanceRepository relevanceRepository)
{
_relevanceRepository = relevanceRepository;
}
/// <summary>
/// 添加关联
/// <para>比如给用户分配资源那么firstId就是用户IDsecIds就是资源ID列表</para>
/// </summary>
/// <param name="type">关联的类型,如"UserResource"</param>
public void Assign(string type, string firstId, string[] secIds)
{
_relevanceRepository.AddRelevance(type, secIds.ToLookup(u => firstId));
}
/// <summary>
/// 取消关联
/// </summary>
/// <param name="type">关联的类型,如"UserResource"</param>
/// <param name="firstId">The first identifier.</param>
/// <param name="secIds">The sec ids.</param>
public void UnAssign(string type, string firstId, string[] secIds)
{
_relevanceRepository.DeleteBy(type, secIds.ToLookup(u =>firstId));
}
}

using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using System;
using System.Linq;
namespace OpenAuth.App
{
public class RevelanceManagerApp
{
public IUnitWork _unitWork { get; set; }
/// <summary>
/// 添加关联
/// <para>比如给用户分配资源那么firstId就是用户IDsecIds就是资源ID列表</para>
/// </summary>
/// <param name="type">关联的类型,如"UserResource"</param>
public void Assign(string type, string firstId, string[] secIds)
{
Assign(type, secIds.ToLookup(u => firstId));
}
public void Assign(string key, ILookup<string, string> idMaps)
{
DeleteBy(key, idMaps);
_unitWork.BatchAdd((from sameVals in idMaps
from value in sameVals
select new Relevance
{
Key = key,
FirstId = sameVals.Key,
SecondId = value,
OperateTime = DateTime.Now
}).ToArray());
_unitWork.Save();
}
/// <summary>
/// 删除关联
/// </summary>
/// <param name="key">关联标识</param>
/// <param name="idMaps">关联的&lt;firstId, secondId&gt;数组</param>
public void DeleteBy(string key, ILookup<string, string> idMaps)
{
foreach (var sameVals in idMaps)
{
foreach (var value in sameVals)
{
_unitWork.Delete<Relevance>(u => u.Key == key && u.FirstId == sameVals.Key && u.SecondId == value);
}
}
}
/// <summary>
/// 取消关联
/// </summary>
/// <param name="type">关联的类型,如"UserResource"</param>
/// <param name="firstId">The first identifier.</param>
/// <param name="secIds">The sec ids.</param>
public void UnAssign(string type, string firstId, string[] secIds)
{
DeleteBy(type, secIds.ToLookup(u =>firstId));
}
public void DeleteBy(string key, params string[] firstIds)
{
_unitWork.Delete<Relevance>(u => firstIds.Contains(u.FirstId) && u.Key == key);
}
/// <summary>
/// 添加新的关联
/// </summary>
/// <param name="key">关联标识</param>
/// <param name="idMaps">关联的&lt;firstId, secondId&gt;数组</param>
public void AddRelevance(string key, ILookup<string, string> idMaps)
{
DeleteBy(key, idMaps);
_unitWork.BatchAdd<Relevance>((from sameVals in idMaps
from value in sameVals
select new Relevance
{
Key = key,
FirstId = sameVals.Key,
SecondId = value,
OperateTime = DateTime.Now
}).ToArray());
_unitWork.Save();
}
}
}

View File

@ -1,151 +0,0 @@
using OpenAuth.App.ViewModel;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using Newtonsoft.Json.Linq;
namespace OpenAuth.App
{
public class RoleManagerApp
{
private IRoleRepository _repository;
private IOrgRepository _orgRepository;
private IRelevanceRepository _relevanceRepository;
public RoleManagerApp(IRoleRepository repository,
IOrgRepository orgRepository,
IRelevanceRepository relevanceRepository)
{
_repository = repository;
_orgRepository = orgRepository;
_relevanceRepository = relevanceRepository;
}
public int GetRoleCntInOrg(string orgId)
{
if (orgId == string.Empty)
{
return _repository.Find(null).Count();
}
else
{
return _repository.GetRoleCntInOrgs(GetSubOrgIds(orgId));
}
}
/// <summary>
/// 加载一个部门及子部门全部Roles
/// </summary>
public GridData Load(string orgId, int pageindex, int pagesize)
{
if (pageindex < 1) pageindex = 1; //TODO:如果列表为空新增加一个用户后前端会传一个0过来奇怪
IEnumerable<Role> roles;
int total = 0;
if (orgId == string.Empty)
{
roles = _repository.LoadRoles(pageindex, pagesize);
total = _repository.GetCount();
}
else
{
roles = _repository.LoadInOrgs(pageindex, pagesize, GetSubOrgIds(orgId));
total = _repository.GetRoleCntInOrgs(orgId);
}
var rolevms = new List<RoleVM>();
foreach (var role in roles)
{
RoleVM rolevm = role;
var orgs = _orgRepository.LoadByRole(role.Id);
rolevm.Organizations = string.Join(",", orgs.Select(u => u.Name).ToList());
rolevm.OrganizationIds = string.Join(",", orgs.Select(u => u.Id).ToList());
rolevms.Add(rolevm);
}
var result = new GridData
{
count = total,
total = (int)Math.Ceiling((double)total/pagesize),
data = rolevms.ToList(),
page = pageindex
};
return result;
}
/// <summary>
/// 获取当前组织的所有下级组织
/// </summary>
private string[] GetSubOrgIds(string orgId)
{
var orgs = _orgRepository.GetSubOrgs(orgId).Select(u => u.Id).ToArray();
return orgs;
}
public Role Find(string id)
{
var role = _repository.FindSingle(u => u.Id == id);
if (role == null) role = new Role();
return role;
}
public void Delete(string id)
{
_repository.Delete(id);
}
public void AddOrUpdate(JObject obj)
{
var role = obj.ToObject<Role>();
if (role.Id == string.Empty)
{
role.CreateTime = DateTime.Now;
_repository.Add(role);
}
else
{
_repository.Update(role);
}
string[] orgIds = obj["OrganizationIds"].ToString().Split(',').ToArray();
_relevanceRepository.DeleteBy("RoleOrg", role.Id);
_relevanceRepository.AddRelevance("RoleOrg", orgIds.ToLookup(u => role.Id));
}
public List<Role> LoadForUser(string userId)
{
return _repository.LoadForUser(userId).ToList();
}
public List<RoleVM> LoadForOrgAndUser(string orgId, string userId)
{
var userroles = LoadForUser(userId);
var orgroles = _repository.LoadInOrgs(GetSubOrgIds(orgId)).ToList();
var rolevms = new List<RoleVM>();
foreach (var role in orgroles)
{
RoleVM rolevm = role;
rolevm.Checked = userroles.Any(u => u.Id == role.Id);
var orgs = _orgRepository.LoadByRole(role.Id);
rolevm.Organizations = string.Join(",", orgs.Select(u => u.Name).ToList());
rolevm.OrganizationIds = string.Join(",", orgs.Select(u => u.Id).ToList());
rolevms.Add(rolevm);
}
return rolevms;
}
public List<string> GetUsersInRole(string ruleName)
{
var role = _repository.FindSingle(u => u.Name == ruleName);
if (role == null) return null;
return _relevanceRepository.Find(u => u.Key == "UserRole"
&& u.SecondId == role.Id).Select(u => u.FirstId).ToList();
}
}
}

View File

@ -1,9 +1,9 @@
using Infrastructure;
namespace OpenAuth.App.SSO
{
public class LoginResult
public class LoginResult :Response<string>
{
public bool Success;
public string ErrorMsg;
public string ReturnUrl;
public string Token;
}

View File

@ -62,14 +62,14 @@ namespace OpenAuth.App.SSO
//´´½¨Session
new ObjCacheProvider<UserAuthSession>().Create(currentSession.Token, currentSession, DateTime.Now.AddDays(10));
result.Success = true;
result.Code = 200;
result.ReturnUrl = appInfo.ReturnUrl;
result.Token = currentSession.Token;
}
catch (Exception ex)
{
result.Success = false;
result.ErrorMsg = ex.Message;
result.Code = 500;
result.Message = ex.Message;
}
return result;

View File

@ -1,40 +0,0 @@
using System;
using OpenAuth.Domain;
using Infrastructure;
using OpenAuth.Domain.Service;
namespace OpenAuth.App
{
public class StockManagerApp
{
private StockManagerService _service;
public StockManagerApp(StockManagerService service)
{
_service = service;
}
/// <summary>
/// 根据部门ID得到进出库信息
/// </summary>
public dynamic Load(string username, string orgId, int page, int rows)
{
return _service.Load(username, orgId, page, rows);
}
public void Delete(string[] id)
{
_service.Delete(id);
}
public void AddOrUpdate(Stock model)
{
Stock stock = new Stock();
model.CopyTo(stock);
_service.AddOrUpdate(stock);
}
}
}

View File

@ -0,0 +1,58 @@
// ***********************************************************************
// Assembly : OpenAuth.Domain
// Author : yubaolee
// Created : 04-21-2016
//
// Last Modified By : yubaolee
// Last Modified On : 04-21-2016
// Contact : Microsoft
// File: AuthenService.cs
// ***********************************************************************
using OpenAuth.Domain.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenAuth.Domain.Service
{
/// <summary>
/// 领域服务
/// <para>超级管理员权限</para>
/// </summary>
public class SystemAuthService : AuthoriseService
{
public SystemAuthService()
{
_user = new User { Account = "System", Id = string.Empty };
}
public override IQueryable<Org> GetOrgsQuery()
{
return _unitWork.Find<Org>(null);
}
public override IQueryable<Resource> GetResourcesQuery()
{
return _unitWork.Find<Resource>(null);
}
public override IQueryable<ModuleElement> GetModuleElementsQuery()
{
return _unitWork.Find<ModuleElement>(null);
}
public override IQueryable<Module> GetModulesQuery()
{
return _unitWork.Find<Module>(null);
}
public override IQueryable<Role> GetRolesQuery()
{
//用户角色
return _unitWork.Find<Role>(null);
}
}
}

View File

@ -11,35 +11,15 @@ namespace OpenAuth.App
{
public class UserManagerApp
{
private IUserRepository _repository;
private IOrgRepository _orgRepository;
private IRelevanceRepository _relevanceRepository;
public IUnitWork _unitWork { get; set; }
public RevelanceManagerApp ReleManagerApp { get; set; }
public UserManagerApp(IUserRepository repository,
IOrgRepository orgRepository,
IRelevanceRepository relevanceRepository)
{
_repository = repository;
_orgRepository = orgRepository;
_relevanceRepository = relevanceRepository;
}
public User Get(string account)
{
return _repository.FindSingle(u => u.Account == account);
return _unitWork.FindSingle<User>(u => u.Account == account);
}
public int GetUserCntInOrg(string orgId)
{
if (orgId == string.Empty)
{
return _repository.Find(null).Count();
}
else
{
return _repository.GetUserCntInOrgs(GetSubOrgIds(orgId));
}
}
/// <summary>
/// 加载一个部门及子部门全部用户
@ -51,20 +31,20 @@ namespace OpenAuth.App
int records = 0;
if (request.orgId ==string.Empty)
{
users = _repository.LoadUsers(request.page, request.limit);
records = _repository.GetCount();
users = _unitWork.Find<User>(null).OrderBy(u => u.Id).Skip((request.page - 1) * request.limit).Take(request.limit);
records = _unitWork.GetCount<User>();
}
else
{
var ids = GetSubOrgIds(request.orgId);
users = _repository.LoadInOrgs(request.page, request.limit, ids);
records = _repository.GetUserCntInOrgs(ids);
users = _unitWork.Find<User>(u =>ids.Contains(u.Id)).OrderBy(u => u.Id).Skip((request.page - 1) * request.limit).Take(request.limit);
records = _unitWork.GetCount<User>();
}
var userviews = new List<UserView>();
foreach (var user in users)
{
UserView uv = user;
var orgs = _orgRepository.LoadByUser(user.Id);
UserView uv = user;
var orgs = LoadByUser(user.Id);
uv.Organizations = string.Join(",", orgs.Select(u => u.Name).ToList());
uv.OrganizationIds = string.Join(",", orgs.Select(u => u.Id).ToList());
userviews.Add(uv);
@ -73,9 +53,7 @@ namespace OpenAuth.App
return new GridData
{
count = records,
total = (int)Math.Ceiling((double)records / request.limit),
data = userviews,
page = request.page
};
}
@ -84,18 +62,18 @@ namespace OpenAuth.App
/// </summary>
private string[] GetSubOrgIds(string orgId)
{
var org = _orgRepository.FindSingle(u => u.Id == orgId);
var orgs = _orgRepository.Find(u => u.CascadeId.Contains(org.CascadeId)).Select(u => u.Id).ToArray();
var org = _unitWork.FindSingle<Org>(u => u.Id == orgId);
var orgs = _unitWork.Find<Org>(u => u.CascadeId.Contains(org.CascadeId)).Select(u => u.Id).ToArray();
return orgs;
}
public UserView Find(string id)
{
var user = _repository.FindSingle(u => u.Id == id);
var user = _unitWork.FindSingle<User>(u => u.Id == id);
if (user == null) return new UserView();
UserView view = user;
foreach (var org in _orgRepository.LoadByUser(id))
foreach (var org in LoadByUser(id))
{
view.Organizations += "," + org.Name;
view.OrganizationIds += "," + org.Id;
@ -107,10 +85,7 @@ namespace OpenAuth.App
public void Delete(string[] ids)
{
_repository.Delete(u => ids.Contains(u.Id));
_relevanceRepository.DeleteBy("UserOrg", ids);
_relevanceRepository.DeleteBy("UserModule", ids);
_relevanceRepository.DeleteBy("UserRole", ids);
_unitWork.Delete<User>(u => ids.Contains(u.Id));
}
public void AddOrUpdate(UserView view)
@ -120,18 +95,19 @@ namespace OpenAuth.App
User user = view;
if (string.IsNullOrEmpty(view.Id))
{
if (_repository.IsExist(u => u.Account == view.Account))
if (_unitWork.IsExist<User>(u => u.Account == view.Account))
{
throw new Exception("用户账号已存在");
}
user.CreateTime = DateTime.Now;
user.Password = user.Account; //初始密码与账号相同
_repository.Add(user);
_unitWork.Add(user);
_unitWork.Save();
view.Id = user.Id; //要把保存后的ID存入view
}
else
{
_repository.Update(u => u.Id == view.Id, u => new User
_unitWork.Update<User>(u => u.Id == view.Id, u => new User
{
Account = user.Account,
BizCode = user.BizCode,
@ -143,13 +119,22 @@ namespace OpenAuth.App
}
string[] orgIds = view.OrganizationIds.Split(',').ToArray();
_relevanceRepository.DeleteBy("UserOrg", user.Id);
_relevanceRepository.AddRelevance("UserOrg", orgIds.ToLookup(u => user.Id));
ReleManagerApp.DeleteBy("UserOrg", user.Id);
ReleManagerApp.AddRelevance("UserOrg", orgIds.ToLookup(u => user.Id));
}
public IEnumerable<User> GetUsers(IEnumerable<string> userids)
/// <summary>
/// 加载用户的所有机构
/// </summary>
public IEnumerable<Org> LoadByUser(string userId)
{
return _repository.Find(u => userids.Contains(u.Id));
var result = from userorg in _unitWork.Find<Relevance>(null)
join org in _unitWork.Find<Org>(null) on userorg.SecondId equals org.Id
where userorg.FirstId == userId && userorg.Key == "UserOrg"
select org;
return result;
}
}
}

View File

@ -27,14 +27,7 @@ namespace OpenAuth.App.ViewModel
/// 操作消息
/// </summary>
public string msg;
/// <summary>
/// 页码
/// </summary>
public int page;
/// <summary>
/// 总页数
/// </summary>
public int total;
/// <summary>
/// 总记录条数
/// </summary>

View File

@ -13,12 +13,7 @@ namespace OpenAuth.App
/// </summary>
public class WFFormService
{
protected IUnitWork _unitWork;
public WFFormService(IUnitWork unitWork)
{
_unitWork = unitWork;
}
public IUnitWork _unitWork { get; set; }
public List<WFFrmMain> GetAllList()
{
@ -39,12 +34,10 @@ namespace OpenAuth.App
{
var result = new GridData
{
page = pageCurrent
count = _unitWork.Find<WFFrmMain>(null).Count(),
data = _unitWork.Find<WFFrmMain>(pageCurrent, pageSize, "ModifyDate descending", null).ToList()
};
int cnt = _unitWork.Find<WFFrmMain>(null).Count();
result.total = cnt % pageSize == 0 ? cnt / pageSize : cnt / pageSize + 1;
result.data = _unitWork.Find<WFFrmMain>(pageCurrent, pageSize, "ModifyDate descending", null).ToList();
return result;
}

View File

@ -16,12 +16,7 @@ namespace OpenAuth.App
/// </summary>
public class WFProcessInstanceService
{
protected IUnitWork _unitWork;
public WFProcessInstanceService(IUnitWork unitWork)
{
_unitWork = unitWork;
}
public IUnitWork _unitWork { get; set; }
#region
/// <summary>
@ -306,27 +301,21 @@ namespace OpenAuth.App
public GridData Load(string userid, string type, int pageCurrent, int pageSize)
{
//todo:待办/已办/我的
var result = new GridData
{
page = pageCurrent
};
var result = new GridData();
var cnt = _unitWork.Find<WFProcessInstance>(u => u.CreateUserId == userid).Count();
result.count = _unitWork.Find<WFProcessInstance>(u => u.CreateUserId == userid).Count();
if (type == "inbox") //待办事项
{
result.total = cnt%pageSize == 0? cnt/pageSize : cnt/pageSize + 1;
result.data = _unitWork.Find<WFProcessInstance>(pageCurrent, pageSize, "CreateDate descending", null).ToList();
}
else if (type == "outbox") //已办事项
{
result.total = cnt % pageSize == 0 ? cnt / pageSize : cnt / pageSize + 1;
result.data = _unitWork.Find<WFProcessInstance>(pageCurrent, pageSize, "CreateDate descending", null).ToList();
}
else //我的流程
{
result.total = cnt % pageSize == 0 ? cnt / pageSize : cnt / pageSize + 1;
result.data = _unitWork.Find<WFProcessInstance>(pageCurrent, pageSize, "CreateDate descending", null).ToList();
}

View File

@ -13,12 +13,7 @@ namespace OpenAuth.App
/// </summary>
public class WFSchemeService
{
protected IUnitWork _unitWork;
public WFSchemeService(IUnitWork unitWork)
{
_unitWork = unitWork;
}
public IUnitWork _unitWork { get; set; }
/// <summary>
/// 保存流程
@ -109,13 +104,9 @@ namespace OpenAuth.App
public GridData Load(int pageCurrent, int pageSize)
{
var result = new GridData
{
page = pageCurrent
};
var result = new GridData();
int cnt = _unitWork.Find<WFSchemeInfo>(null).Count();
result.total = cnt%pageSize ==0?cnt/pageSize:cnt/pageSize+1;
result.count = _unitWork.Find<WFSchemeInfo>(null).Count();
result.data = _unitWork.Find<WFSchemeInfo>(pageCurrent, pageSize, "ModifyDate descending", null).ToList();
return result;

View File

@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenAuth.Domain.Interface
{
public interface ICategoryRepository :IRepository<Category>
{
IEnumerable<Category> LoadCategorys(int pageindex, int pagesize);
IEnumerable<Category> LoadInOrgs(params string[] orgId);
int GetCategoryCntInOrgs(params string[] orgIds);
IEnumerable<Category> LoadInOrgs(int pageindex, int pagesize, params string[] orgIds);
/// <summary>
/// 获取子分类ID
/// </summary>
string[] GetSubIds(string orgId);
void Delete(string id);
}
}

View File

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenAuth.Domain.Interface
{
public interface IModuleRepository :IRepository<Module>
{
IEnumerable<Module> LoadModules(int pageindex, int pagesize);
IEnumerable<Module> LoadInOrgs(params string[] orgId);
int GetModuleCntInOrgs(params string[] orgIds);
IEnumerable<Module> LoadInOrgs(int pageindex, int pagesize, params string[] orgIds);
void Delete(string id);
}
}

View File

@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenAuth.Domain.Interface
{
public interface IOrgRepository :IRepository<Org>
{
IEnumerable<Org> LoadOrgs();
IEnumerable<Org> LoadByUser(string userId);
IEnumerable<Org> LoadByRole(string roleId);
/// <summary>
/// 获取包括自己在内的全部子部门
/// </summary>
/// <param name="orgId">部门ID</param>
IEnumerable<Org> GetSubOrgs(string orgId);
}
}

View File

@ -1,28 +0,0 @@
// ***********************************************************************
// Assembly : OpenAuth.Domain
// Author : Yubao Li
// Created : 11-30-2015
//
// Last Modified By : Yubao Li
// Last Modified On : 11-30-2015
// ***********************************************************************
// <copyright file="IRelevanceRepository.cs" company="">
// Copyright (c) . All rights reserved.
// </copyright>
// <summary>多对多关系统一处理</summary>
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenAuth.Domain.Interface
{
public interface IRelevanceRepository : IRepository<Relevance>
{
void DeleteBy(string key, params string[] firstIds);
void DeleteBy(string key, ILookup<string, string> idMaps);
void AddRelevance( string key, ILookup<string, string> idMaps);
}
}

View File

@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenAuth.Domain.Interface
{
public interface IResourceRepository :IRepository<Resource>
{
IEnumerable<Resource> LoadResources(int pageindex, int pagesize);
IEnumerable<Resource> LoadInOrgs(params string[] orgId);
int GetResourceCntInOrgs(params string[] orgIds);
IEnumerable<Resource> LoadInOrgs(int pageindex, int pagesize, params string[] orgIds);
void Delete(string id);
}
}

View File

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenAuth.Domain.Interface
{
public interface IRoleRepository :IRepository<Role>
{
IEnumerable<Role> LoadRoles(int pageindex, int pagesize);
int GetRoleCntInOrgs(params string[] orgIds);
IEnumerable<Role> LoadInOrgs(int pageindex, int pagesize, params string[] orgIds);
IEnumerable<Role> LoadInOrgs(params string[] orgId);
IEnumerable<Role> LoadForUser(string userId);
void Delete(string id);
}
}

View File

@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenAuth.Domain.Interface
{
public interface IStockRepository :IRepository<Stock>
{
IEnumerable<Stock> LoadStocks(int pageindex, int pagesize);
IEnumerable<Stock> LoadInOrgs(params string[] orgId);
int GetStockCntInOrgs(params string[] orgIds);
IEnumerable<Stock> LoadInOrgs(int pageindex, int pagesize, params string[] orgIds);
void Delete(string id);
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenAuth.Domain.Interface
{
public interface IUserRepository :IRepository<User>
{
IEnumerable<User> LoadUsers(int pageindex, int pagesize);
IEnumerable<User> LoadInOrgs(params string[] orgId);
int GetUserCntInOrgs(params string[] orgIds);
IEnumerable<User> LoadInOrgs(int pageindex, int pagesize, params string[] orgIds);
}
}

View File

@ -42,44 +42,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Core\Application.cs" />
<Compile Include="Core\Category.cs" />
<Compile Include="Core\CategoryType.cs" />
<Compile Include="Core\UserExt.cs" />
<Compile Include="Core\Entity.cs" />
<Compile Include="Interface\ICategoryRepository.cs" />
<Compile Include="Interface\IModuleRepository.cs" />
<Compile Include="Interface\IOrgRepository.cs" />
<Compile Include="Interface\IRepository.cs" />
<Compile Include="Interface\IResourceRepository.cs" />
<Compile Include="Interface\IRoleRepository.cs" />
<Compile Include="Interface\IRelevanceRepository.cs" />
<Compile Include="Interface\IStockRepository.cs" />
<Compile Include="Interface\IUnitWork.cs" />
<Compile Include="Interface\IUserRepository.cs" />
<Compile Include="Core\Module.cs" />
<Compile Include="Core\ModuleElement.cs" />
<Compile Include="Core\Org.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Core\Relevance.cs" />
<Compile Include="Core\Resource.cs" />
<Compile Include="Core\Role.cs" />
<Compile Include="Service\AuthoriseFactory.cs" />
<Compile Include="Service\SystemAuthService.cs" />
<Compile Include="Service\AuthoriseService.cs" />
<Compile Include="Service\ModuleEleManService.cs" />
<Compile Include="Service\ModuleManService.cs" />
<Compile Include="Service\ResManagerService.cs" />
<Compile Include="Service\StockManagerService.cs" />
<Compile Include="Core\Stock.cs" />
<Compile Include="Core\User.cs" />
<Compile Include="Core\WFFrmMain.cs" />
<Compile Include="Core\WFProcessInstance.cs" />
<Compile Include="Core\WFProcessOperationHistory.cs" />
<Compile Include="Core\WFProcessScheme.cs" />
<Compile Include="Core\WFProcessTransitionHistory.cs" />
<Compile Include="Core\WFSchemeContent.cs" />
<Compile Include="Core\WFSchemeInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -1,31 +1,31 @@
using OpenAuth.Domain.Interface;
namespace OpenAuth.Domain.Service
{
/// <summary>
/// 权限分配工厂,根据是否是开发者账号创建
/// </summary>
public class AuthoriseFactory
{
private IUnitWork _unitWork;
public AuthoriseFactory(IUnitWork unitWork)
{
_unitWork = unitWork;
}
public AuthoriseService Create(string loginuser)
{
if (loginuser == "System")
{
return new SystemAuthService(_unitWork);
}
else
{
return new AuthoriseService(_unitWork)
{
User = _unitWork.FindSingle<User>(u =>u.Account == loginuser)
};
}
}
}
using OpenAuth.Domain.Interface;
namespace OpenAuth.Domain.Service
{
/// <summary>
/// 权限分配工厂,根据是否是开发者账号创建
/// </summary>
public class AuthoriseFactory
{
private IUnitWork _unitWork;
public AuthoriseFactory(IUnitWork unitWork)
{
_unitWork = unitWork;
}
public AuthoriseService Create(string loginuser)
{
if (loginuser == "System")
{
return new SystemAuthService(_unitWork);
}
else
{
return new AuthoriseService(_unitWork)
{
User = _unitWork.FindSingle<User>(u =>u.Account == loginuser)
};
}
}
}
}

View File

@ -1,136 +1,136 @@
// ***********************************************************************
// Assembly : OpenAuth.Domain
// Author : yubaolee
// Created : 04-21-2016
//
// Last Modified By : yubaolee
// Last Modified On : 04-21-2016
// Contact : Microsoft
// File: AuthenService.cs
// ***********************************************************************
using OpenAuth.Domain.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenAuth.Domain.Service
{
/// <summary>
/// 领域服务
/// <para>用户授权服务</para>
/// </summary>
public class AuthoriseService
{
protected IUnitWork _unitWork;
protected User _user;
private List<string> _userRoleIds; //用户角色GUID
public AuthoriseService(IUnitWork unitWork)
{
_unitWork = unitWork;
}
public List<Module> Modules
{
get { return GetModulesQuery().ToList(); }
}
public List<Role> Roles
{
get { return GetRolesQuery().ToList(); }
}
public List<ModuleElement> ModuleElements
{
get { return GetModuleElementsQuery().ToList(); }
}
public List<Resource> Resources
{
get { return GetResourcesQuery().ToList(); }
}
public List<Org> Orgs
{
get { return GetOrgsQuery().ToList(); }
}
public User User
{
get { return _user; }
set
{
_user = value;
_userRoleIds = _unitWork.Find<Relevance>(u => u.FirstId == _user.Id && u.Key == "UserRole").Select(u => u.SecondId).ToList();
}
}
public void Check(string userName, string password)
{
var _user = _unitWork.FindSingle<User>(u => u.Account == userName);
if (_user == null)
{
throw new Exception("用户帐号不存在");
}
_user.CheckPassword(password);
}
/// <summary>
/// 用户可访问的机构
/// </summary>
/// <returns>IQueryable&lt;Org&gt;.</returns>
public virtual IQueryable<Org> GetOrgsQuery()
{
var orgids = _unitWork.Find<Relevance>(
u =>
(u.FirstId == _user.Id && u.Key == "UserOrg") ||
(u.Key == "RoleOrg" && _userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId);
return _unitWork.Find<Org>(u => orgids.Contains(u.Id));
}
/// <summary>
/// 获取用户可访问的资源
/// </summary>
/// <returns>IQueryable&lt;Resource&gt;.</returns>
public virtual IQueryable<Resource> GetResourcesQuery()
{
var resourceIds = _unitWork.Find<Relevance>(
u =>
(u.FirstId == _user.Id && u.Key == "UserResource") ||
(u.Key == "RoleResource" && _userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId);
return _unitWork.Find<Resource>(u => resourceIds.Contains(u.Id));
}
/// <summary>
/// 模块菜单权限
/// </summary>
public virtual IQueryable<ModuleElement> GetModuleElementsQuery()
{
var elementIds = _unitWork.Find<Relevance>(
u =>
(u.FirstId == _user.Id && u.Key == "UserElement") ||
(u.Key == "RoleElement" && _userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId);
return _unitWork.Find<ModuleElement>(u => elementIds.Contains(u.Id));
}
/// <summary>
/// 得出最终用户拥有的模块
/// </summary>
public virtual IQueryable<Module> GetModulesQuery()
{
var moduleIds = _unitWork.Find<Relevance>(
u =>
(u.FirstId == _user.Id && u.Key == "UserModule") ||
(u.Key == "RoleModule" && _userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId);
return _unitWork.Find<Module>(u => moduleIds.Contains(u.Id)).OrderBy(u => u.SortNo);
}
//用户角色
public virtual IQueryable<Role> GetRolesQuery()
{
return _unitWork.Find<Role>(u => _userRoleIds.Contains(u.Id));
}
}
// ***********************************************************************
// Assembly : OpenAuth.Domain
// Author : yubaolee
// Created : 04-21-2016
//
// Last Modified By : yubaolee
// Last Modified On : 04-21-2016
// Contact : Microsoft
// File: AuthenService.cs
// ***********************************************************************
using OpenAuth.Domain.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenAuth.Domain.Service
{
/// <summary>
/// 领域服务
/// <para>用户授权服务</para>
/// </summary>
public class AuthoriseService
{
protected IUnitWork _unitWork;
protected User _user;
private List<string> _userRoleIds; //用户角色GUID
public AuthoriseService(IUnitWork unitWork)
{
_unitWork = unitWork;
}
public List<Module> Modules
{
get { return GetModulesQuery().ToList(); }
}
public List<Role> Roles
{
get { return GetRolesQuery().ToList(); }
}
public List<ModuleElement> ModuleElements
{
get { return GetModuleElementsQuery().ToList(); }
}
public List<Resource> Resources
{
get { return GetResourcesQuery().ToList(); }
}
public List<Org> Orgs
{
get { return GetOrgsQuery().ToList(); }
}
public User User
{
get { return _user; }
set
{
_user = value;
_userRoleIds = _unitWork.Find<Relevance>(u => u.FirstId == _user.Id && u.Key == "UserRole").Select(u => u.SecondId).ToList();
}
}
public void Check(string userName, string password)
{
var _user = _unitWork.FindSingle<User>(u => u.Account == userName);
if (_user == null)
{
throw new Exception("用户帐号不存在");
}
_user.CheckPassword(password);
}
/// <summary>
/// 用户可访问的机构
/// </summary>
/// <returns>IQueryable&lt;Org&gt;.</returns>
public virtual IQueryable<Org> GetOrgsQuery()
{
var orgids = _unitWork.Find<Relevance>(
u =>
(u.FirstId == _user.Id && u.Key == "UserOrg") ||
(u.Key == "RoleOrg" && _userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId);
return _unitWork.Find<Org>(u => orgids.Contains(u.Id));
}
/// <summary>
/// 获取用户可访问的资源
/// </summary>
/// <returns>IQueryable&lt;Resource&gt;.</returns>
public virtual IQueryable<Resource> GetResourcesQuery()
{
var resourceIds = _unitWork.Find<Relevance>(
u =>
(u.FirstId == _user.Id && u.Key == "UserResource") ||
(u.Key == "RoleResource" && _userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId);
return _unitWork.Find<Resource>(u => resourceIds.Contains(u.Id));
}
/// <summary>
/// 模块菜单权限
/// </summary>
public virtual IQueryable<ModuleElement> GetModuleElementsQuery()
{
var elementIds = _unitWork.Find<Relevance>(
u =>
(u.FirstId == _user.Id && u.Key == "UserElement") ||
(u.Key == "RoleElement" && _userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId);
return _unitWork.Find<ModuleElement>(u => elementIds.Contains(u.Id));
}
/// <summary>
/// 得出最终用户拥有的模块
/// </summary>
public virtual IQueryable<Module> GetModulesQuery()
{
var moduleIds = _unitWork.Find<Relevance>(
u =>
(u.FirstId == _user.Id && u.Key == "UserModule") ||
(u.Key == "RoleModule" && _userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId);
return _unitWork.Find<Module>(u => moduleIds.Contains(u.Id)).OrderBy(u => u.SortNo);
}
//用户角色
public virtual IQueryable<Role> GetRolesQuery()
{
return _unitWork.Find<Role>(u => _userRoleIds.Contains(u.Id));
}
}
}

View File

@ -1,102 +0,0 @@
// ***********************************************************************
// Assembly : OpenAuth.Domain
// Author : yubaolee
// Created : 05-27-2016
//
// Last Modified By : yubaolee
// Last Modified On : 05-27-2016
// Contact : Microsoft
// File: ModuleEleManService.cs
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using OpenAuth.Domain.Interface;
namespace OpenAuth.Domain.Service
{
/// <summary>
/// 领域服务
/// <para>模块菜单管理服务</para>
/// </summary>
public class ModuleEleManService
{
private readonly IUnitWork _unitWork;
private readonly AuthoriseFactory _factory;
public ModuleEleManService(IUnitWork unitWork, AuthoriseFactory authoriseService)
{
_unitWork = unitWork;
_factory = authoriseService;
}
public void AddOrUpdate(ModuleElement model)
{
if (model.Id == string.Empty)
{
_unitWork.Add(model);
}
else
{
_unitWork.Update(model);
}
_unitWork.Save();
}
public IEnumerable<ModuleElement> LoadByModuleId(string loginuser, string id)
{
var service = _factory.Create(loginuser);
if (!service.GetModuleElementsQuery().Any()) //用户没有任何资源
{
return new List<ModuleElement>();
}
var modules = service.GetModuleElementsQuery().Where(u => u.ModuleId == id).OrderBy(u =>u.Sort);
return modules;
}
/// <summary>
/// 获取带有授权状态的菜单列表
/// </summary>
/// <param name="username">当前登录的操作人</param>
/// <param name="accessType">授权类型当前有RoleElement/UserElement</param>
/// <param name="firstId">
/// 当为RoleElement时表示RoleId
/// 当为UserElement时表示UserId
/// </param>
/// <param name="moduleId">模块ID</param>
public List<dynamic> LoadWithAccess(string username, string accessType, string firstId, string moduleId)
{
var listVms = new List<dynamic>();
var service = _factory.Create(username);
if (!service.GetModuleElementsQuery().Any()) //用户没有任何资源
{
return listVms;
}
if (moduleId == string.Empty) return listVms;
foreach (var element in service.GetModuleElementsQuery().Where(u =>u.ModuleId ==moduleId))
{
var accessed = _unitWork.FindSingle<Relevance>(u =>u.Key == accessType
&& u.FirstId == firstId && u.SecondId == element.Id);
var vm = new
{
Id = element.Id,
Name = element.Name,
ModuleId = element.ModuleId,
DomId = element.DomId,
Checked = accessed != null
};
listVms.Add(vm);
}
return listVms;
}
public void Delete(string[] objs)
{
_unitWork.Delete<ModuleElement>(u =>objs.Contains(u.Id));
}
}
}

View File

@ -1,161 +0,0 @@
// ***********************************************************************
// Assembly : OpenAuth.Domain
// Author : yubaolee
// Created : 05-27-2016
//
// Last Modified By : yubaolee
// Last Modified On : 05-27-2016
// Contact : Microsoft
// File: ModuleManService.cs
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using OpenAuth.Domain.Interface;
namespace OpenAuth.Domain.Service
{
/// <summary>
/// 领域服务
/// <para>模块领域服务</para>
/// </summary>
public class ModuleManService
{
private readonly IModuleRepository _repository;
private readonly IRelevanceRepository _relevanceRepository;
private readonly AuthoriseFactory _factory;
public ModuleManService(IModuleRepository repository,
IRelevanceRepository relevanceRepository, AuthoriseFactory authoriseService)
{
_repository = repository;
_relevanceRepository = relevanceRepository;
_factory = authoriseService;
}
public void Delete(string id)
{
var del = _repository.FindSingle(u => u.Id == id);
if (del == null) return;
_repository.Delete(u => u.CascadeId.Contains(del.CascadeId));
}
public void AddOrUpdate(Module model)
{
ChangeModuleCascade(model);
if (string.IsNullOrEmpty(model.Id))
{
_repository.Add(model);
}
else
{
//获取旧的的CascadeId
var CascadeId = _repository.FindSingle(o => o.Id == model.Id).CascadeId;
//根据CascadeId查询子部门
var models = _repository.Find(u => u.CascadeId.Contains(CascadeId) && u.Id != model.Id).OrderBy(u => u.CascadeId).ToList();
_repository.Update(model);
//更新子部门的CascadeId
foreach (var a in models)
{
ChangeModuleCascade(a);
_repository.Update(a);
}
}
}
#region /
/// <summary>
/// 加载特定用户的模块
/// </summary>
/// <param name="userId">The user unique identifier.</param>
public List<Module> LoadForUser(string userId)
{
//用户角色
var userRoleIds =
_relevanceRepository.Find(u => u.FirstId == userId && u.Key == "UserRole").Select(u => u.SecondId).ToList();
//用户角色与自己分配到的模块ID
var moduleIds =
_relevanceRepository.Find(
u =>
(u.FirstId == userId && u.Key == "UserModule") ||
(u.Key == "RoleModule" && userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId).ToList();
//var moduleIds =
// _relevanceRepository.Find(u => u.FirstId == userId && u.Key == "UserModule")
// .Select(u => u.SecondId)
// .ToList();
if (!moduleIds.Any()) return new List<Module>();
return _repository.Find(u => moduleIds.Contains(u.Id)).ToList();
}
/// <summary>
/// 加载特定角色的模块
/// </summary>
/// <param name="roleId">The role unique identifier.</param>
public List<Module> LoadForRole(string roleId)
{
var moduleIds =
_relevanceRepository.Find(u => u.FirstId == roleId && u.Key == "RoleModule")
.Select(u => u.SecondId)
.ToList();
if (!moduleIds.Any()) return new List<Module>();
return _repository.Find(u => moduleIds.Contains(u.Id)).ToList();
}
#endregion /
#region
//根据同一级中最大的语义ID
private string[] GetSubIds(string parentId)
{
if (parentId == string.Empty) return _repository.Find(null).Select(u => u.Id).ToArray();
var parent = _repository.FindSingle(u => u.Id == parentId);
var orgs = _repository.Find(u => u.CascadeId.Contains(parent.CascadeId)).Select(u => u.Id).ToArray();
return orgs;
}
//修改对象的级联ID
private void ChangeModuleCascade(Module module)
{
string cascadeId;
int currentCascadeId = 1; //当前结点的级联节点最后一位
var sameLevels = _repository.Find(o => o.ParentId == module.ParentId && o.Id != module.Id);
foreach (var obj in sameLevels)
{
int objCascadeId = int.Parse(obj.CascadeId.TrimEnd('.').Split('.').Last());
if (currentCascadeId <= objCascadeId) currentCascadeId = objCascadeId + 1;
}
if (module.ParentId != null && module.ParentId != string.Empty)
{
var parentOrg = _repository.FindSingle(o => o.Id == module.ParentId);
if (parentOrg != null)
{
cascadeId = parentOrg.CascadeId + currentCascadeId +".";
module.ParentName = parentOrg.Name;
}
else
{
throw new Exception("未能找到该组织的父节点信息");
}
}
else
{
cascadeId = ".0." + currentCascadeId +".";
module.ParentName = "根节点";
}
module.CascadeId = cascadeId;
}
#endregion
}
}

View File

@ -1,170 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenAuth.Domain.Interface;
namespace OpenAuth.Domain.Service
{
/// <summary>
/// 领域服务
/// <para>资源管理领域</para>
/// </summary>
public class ResManagerService
{
private IResourceRepository _repository;
private readonly ICategoryRepository _categoryRepository;
private IRelevanceRepository _relevanceRepository;
private AuthoriseFactory _factory;
public ResManagerService(IResourceRepository repository,
ICategoryRepository categoryRepository,
IRelevanceRepository relevanceRepository,
AuthoriseFactory authoriseService)
{
_repository = repository;
_categoryRepository = categoryRepository;
_relevanceRepository = relevanceRepository;
_factory = authoriseService;
}
public int GetResourceCntInOrg(string orgId)
{
if (orgId == string.Empty)
{
return _repository.Find(null).Count();
}
else
{
return _repository.GetResourceCntInOrgs(_categoryRepository.GetSubIds(orgId));
}
}
public List<Resource> LoadAll()
{
return _repository.Find(null).ToList();
}
/// <summary>
/// 加载用户一个节点下面的一个或全部Resources
/// </summary>
public dynamic Load(string username, string categoryId, int page, int rows)
{
var service = _factory.Create(username);
if (!service.GetResourcesQuery().Any()) //用户没有任何资源
{
return new
{
total = 0,
page = 0,
records = 0
};
}
var subIds = _categoryRepository.GetSubIds(categoryId);
var query = service.GetResourcesQuery().Where(u => categoryId == string.Empty ||
(u.CategoryId != null && subIds.Contains(u.CategoryId)));
int total = query.Count();
if (total <= 0)
return new
{
total = 0,
page = 0,
records = 0
};
var listVms = new List<dynamic>();
var resources = query.OrderBy(u => u.SortNo).Skip((page - 1) * rows).Take(rows);
foreach (var element in resources)
{
var accessed = _categoryRepository.FindSingle(u => u.Id == element.CategoryId);
listVms.Add(new
{
element.Id,
element.Name,
element.Key,
element.SortNo,
element.CategoryId,
element.Status,
CategoryName = accessed != null ? accessed.Name : ""
});
}
return new
{
records = total,
total = (int)Math.Ceiling((double)total / rows),
rows = listVms,
page = page
};
}
public Resource Find(string id)
{
var resource = _repository.FindSingle(u => u.Id == id);
if (resource == null) return new Resource();
return resource;
}
public void Delete(string[] ids)
{
_repository.Delete(u => ids.Contains(u.Id));
}
public void AddOrUpdate(Resource resource)
{
if (resource.Id == string.Empty)
{
_repository.Add(resource);
}
else
{
_repository.Update(resource);
}
}
/// <summary>
/// 获取带有授权状态的菜单列表
/// </summary>
/// <param name="accessType">授权类型当前有RoleResource/UserResource</param>
/// <param name="firstId">
/// 当为RoleResource时表示RoleId
/// 当为UserResource时表示UserId
/// </param>
/// <param name="cId">分类ID</param>
public List<dynamic> LoadWithAccess(string username, string accessType, string firstId, string cId)
{
var listVms = new List<dynamic>();
var service = _factory.Create(username);
if (!service.GetResourcesQuery().Any()) //用户没有任何资源
{
return listVms;
}
var subIds = _categoryRepository.GetSubIds(cId);
var query = service.GetResourcesQuery().Where(u => cId == string.Empty || (u.CategoryId != null && subIds.Contains(u.CategoryId)));
foreach (var element in query)
{
var accessed = _relevanceRepository.FindSingle(u => u.Key == accessType
&& u.FirstId == firstId && u.SecondId == element.Id);
listVms.Add(new
{
Id = element.Id,
Name = element.Name,
Checked = accessed != null,
Description = element.Description,
Key = element.Key,
Status = element.Status
});
}
return listVms;
}
}
}

View File

@ -1,92 +0,0 @@
using System;
using System.Linq;
using System.Linq.Expressions;
using OpenAuth.Domain.Interface;
namespace OpenAuth.Domain.Service
{
/// <summary>
/// 领域服务
/// <para>进出库管理服务</para>
/// </summary>
public class StockManagerService
{
private IStockRepository _repository;
private IOrgRepository _orgRepository;
private AuthoriseFactory _factory;
public StockManagerService(IStockRepository repository,
IOrgRepository orgRepository, AuthoriseFactory service)
{
_repository = repository;
_orgRepository = orgRepository;
_factory = service;
}
/// <summary>
/// 根据部门ID得到进出库信息
/// </summary>
public dynamic Load(string username, string orgId, int pageindex, int pagesize)
{
var service = _factory.Create(username);
if (service.Orgs.Count == 0) //用户没有任何可见机构
{
return new
{
total = 0,
records = 0,
page = pageindex
};
}
var orgIds = service.Orgs.Select(u => u.Id).ToArray(); //用户可访问的机构ID
var orgs = _orgRepository.GetSubOrgs(orgId) //点击的节点与用户可访问的机构合并
.Where(u => orgIds.Contains(u.Id))
.Select(u => u.Id).ToArray();
var keys = service.Resources.Select(r => r.Key); //用户可访问的资源的KEY列表
Expression<Func<Stock, bool>> exp = u => u.OrgId != null &&orgs.Contains(u.OrgId) && (u.Viewable == "" || keys.Contains(u.Viewable));
var stocks = _repository.Find(pageindex, pagesize, "", exp);
int total = _repository.GetCount(exp);
return new
{
records = total,
total = (int)Math.Ceiling((double)total / pagesize),
rows = stocks,
page = pageindex
};
}
public Stock Find(string id)
{
var stock = _repository.FindSingle(u => u.Id == id);
if (stock == null) return new Stock();
return stock;
}
public void Delete(string[] id)
{
_repository.Delete(u =>id.Contains(u.Id));
}
public void AddOrUpdate(Stock stock)
{
if (string.IsNullOrEmpty(stock.Id))
{
_repository.Add(stock);
}
else
{
_repository.Update(stock);
}
}
}
}

View File

@ -1,58 +1,58 @@
// ***********************************************************************
// Assembly : OpenAuth.Domain
// Author : yubaolee
// Created : 04-21-2016
//
// Last Modified By : yubaolee
// Last Modified On : 04-21-2016
// Contact : Microsoft
// File: AuthenService.cs
// ***********************************************************************
using OpenAuth.Domain.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenAuth.Domain.Service
{
/// <summary>
/// 领域服务
/// <para>超级管理员权限</para>
/// </summary>
public class SystemAuthService : AuthoriseService
{
public SystemAuthService(IUnitWork unitWork):base(unitWork)
{
_user = new User { Account = "System", Id = string.Empty };
}
public override IQueryable<Org> GetOrgsQuery()
{
return _unitWork.Find<Org>(null);
}
public override IQueryable<Resource> GetResourcesQuery()
{
return _unitWork.Find<Resource>(null);
}
public override IQueryable<ModuleElement> GetModuleElementsQuery()
{
return _unitWork.Find<ModuleElement>(null);
}
public override IQueryable<Module> GetModulesQuery()
{
return _unitWork.Find<Module>(null);
}
public override IQueryable<Role> GetRolesQuery()
{
//用户角色
return _unitWork.Find<Role>(null);
}
}
// ***********************************************************************
// Assembly : OpenAuth.Domain
// Author : yubaolee
// Created : 04-21-2016
//
// Last Modified By : yubaolee
// Last Modified On : 04-21-2016
// Contact : Microsoft
// File: AuthenService.cs
// ***********************************************************************
using OpenAuth.Domain.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenAuth.Domain.Service
{
/// <summary>
/// 领域服务
/// <para>超级管理员权限</para>
/// </summary>
public class SystemAuthService : AuthoriseService
{
public SystemAuthService(IUnitWork unitWork):base(unitWork)
{
_user = new User { Account = "System", Id = string.Empty };
}
public override IQueryable<Org> GetOrgsQuery()
{
return _unitWork.Find<Org>(null);
}
public override IQueryable<Resource> GetResourcesQuery()
{
return _unitWork.Find<Resource>(null);
}
public override IQueryable<ModuleElement> GetModuleElementsQuery()
{
return _unitWork.Find<ModuleElement>(null);
}
public override IQueryable<Module> GetModulesQuery()
{
return _unitWork.Find<Module>(null);
}
public override IQueryable<Role> GetRolesQuery()
{
//用户角色
return _unitWork.Find<Role>(null);
}
}
}

View File

@ -14,6 +14,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpPost]
public string Add(HttpPostedFileBase Filedata)
{
var response = new Response<string>();
if (Filedata != null && Filedata.ContentLength > 0 && Filedata.ContentLength < 10485760)
{
using (var binaryReader = new BinaryReader(Filedata.InputStream))
@ -21,16 +22,16 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
var fileName = Path.GetFileName(Filedata.FileName);
var data = binaryReader.ReadBytes(Filedata.ContentLength);
var result = UploadFile(fileName, data, string.Empty);
Result.Result = result;
response.Result = result;
}
}
else
{
Result.Message = "文件过大";
Result.Status = false;
response.Message = "文件过大";
response.Code = 500;
}
return JsonHelper.Instance.Serialize(Result);
return JsonHelper.Instance.Serialize(response);
}

View File

@ -143,7 +143,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
}
catch (Exception e)
{
Result.Status = false;
Result.Code = 500;
Result.Message = e.Message;
return Result.ToJson();
}

View File

@ -119,7 +119,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
}
catch (Exception e)
{
Result.Status = false;
Result.Code = 500;
Result.Message = e.Message;
}
return Result.ToJson();

View File

@ -45,7 +45,7 @@ namespace OpenAuth.Mvc
|| u.Namespace == "OpenAuth.Domain.Interface");
//注册Repository
builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(UserRepository)))
builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(UserManagerApp)))
.AsImplementedInterfaces();
// 注册controller使用属性注入

View File

@ -44,7 +44,7 @@ namespace OpenAuth.Mvc.Controllers
}
catch (Exception ex)
{
Result.Status = false;
Result.Code = 500;
Result.Message = ex.Message;
}
return JsonHelper.Instance.Serialize(Result);
@ -58,7 +58,7 @@ namespace OpenAuth.Mvc.Controllers
}
catch (Exception e)
{
Result.Status = false;
Result.Code = 500;
Result.Message = e.Message;
}

View File

@ -24,7 +24,7 @@ namespace OpenAuth.Mvc.Controllers
Response.Charset = "utf-8";
var response = new Response
{
Status = false,
Code = 500,
Message = "演示版本,不能进行此操作"
};
return JsonHelper.Instance.Serialize(response);

View File

@ -20,12 +20,11 @@ namespace OpenAuth.Mvc.Controllers
[HttpPost]
public string Index(string username, string password)
{
var resp = new Response();
var resp = new LoginResult();
try
{
var result = AuthUtil.Login(_appKey, username, password);
resp.Status = result.Success;
if (result.Success)
if (result.Code ==200)
{
resp.Result = "/home/index?Token=" + result.Token;
}
@ -36,7 +35,7 @@ namespace OpenAuth.Mvc.Controllers
}
catch (Exception e)
{
resp.Status = false;
resp.Code = 500;
resp.Message = e.Message;
}
return JsonHelper.Instance.Serialize(resp);
@ -50,7 +49,7 @@ namespace OpenAuth.Mvc.Controllers
try
{
var result = AuthUtil.Login(_appKey, "System","123456");
if (result.Success)
if (result.Code ==200)
return Redirect("/home/index?Token=" + result.Token);
else
{

View File

@ -1,85 +0,0 @@
// ***********************************************************************
// Assembly : OpenAuth.Mvc
// Author : Yubao Li
// Created : 12-02-2015
//
// Last Modified By : Yubao Li
// Last Modified On : 12-02-2015
// ***********************************************************************
// <copyright file="ModuleElementManagerController.cs" company="">
// Copyright (c) . All rights reserved.
// </copyright>
// <summary>模块元素管理,无需权限控制</summary>
// ***********************************************************************
using Infrastructure;
using OpenAuth.App;
using OpenAuth.Domain;
using OpenAuth.Mvc.Models;
using System;
using System.Data.Entity.Validation;
using System.Web.Mvc;
namespace OpenAuth.Mvc.Controllers
{
public class ModuleElementManagerController : BaseController
{
public ModuleElementManagerApp App { get; set; }
public ActionResult Index(string id)
{
ViewBag.ModuleId = id;
return View();
}
public ActionResult Get(string moduleId)
{
return Json(App.LoadByModuleId(moduleId), JsonRequestBehavior.AllowGet);
}
[HttpPost]
public string AddOrEditButton(ModuleElement button)
{
try
{
App.AddOrUpdate(button);
}
catch (DbEntityValidationException e)
{
Result.Status=false;
Result.Message = e.Message;
}
return JsonHelper.Instance.Serialize( Result);
}
public string Del(string[] ids)
{
try
{
App.Delete(ids);
}
catch (Exception e)
{
Result.Status=false;
Result.Message = e.Message;
}
return JsonHelper.Instance.Serialize( Result);
}
/// <summary>
/// 分配模块菜单(按钮)界面
/// <para>可以为用户/角色分配同过keyUserElement/RoleElement区分</para>
/// </summary>
/// <param name="firstId">The first identifier.</param>
/// <param name="key">The key.</param>
/// <returns>ActionResult.</returns>
public ActionResult AssignModuleElement(string firstId, string key)
{
ViewBag.FirstId = firstId;
ViewBag.ModuleType = key;
return View();
}
public string LoadWithAccess(string tId, string firstId, string key)
{
return JsonHelper.Instance.Serialize(App.LoadWithAccess(key, firstId, tId));
}
}
}

View File

@ -137,7 +137,7 @@ namespace OpenAuth.Mvc.Controllers
}
catch (Exception ex)
{
Result.Status = false;
Result.Code = 500;
Result.Message = ex.Message;
}
return JsonHelper.Instance.Serialize(Result);
@ -155,7 +155,7 @@ namespace OpenAuth.Mvc.Controllers
}
catch (Exception e)
{
Result.Status = false;
Result.Code = 500;
Result.Message = e.Message;
}

View File

@ -48,7 +48,7 @@ namespace OpenAuth.Mvc.Controllers
}
catch (Exception ex)
{
Result.Status = false;
Result.Code = 500;
Result.Message = ex.Message;
}
return JsonHelper.Instance.Serialize(Result);
@ -73,7 +73,7 @@ namespace OpenAuth.Mvc.Controllers
}
catch (Exception e)
{
Result.Status = false;
Result.Code = 500;
Result.Message = e.Message;
}

View File

@ -23,7 +23,7 @@ namespace OpenAuth.Mvc.Controllers
}
catch (Exception ex)
{
Result.Status = false;
Result.Code = 500;
Result.Message = ex.Message;
}
return JsonHelper.Instance.Serialize(Result);
@ -37,7 +37,7 @@ namespace OpenAuth.Mvc.Controllers
}
catch (Exception ex)
{
Result.Status = false;
Result.Code = 500;
Result.Message = ex.Message;
}
return JsonHelper.Instance.Serialize(Result);

View File

@ -1,97 +0,0 @@
using Infrastructure;
using OpenAuth.App;
using OpenAuth.Domain;
using System;
using System.Linq;
using System.Web.Mvc;
using OpenAuth.App.SSO;
using OpenAuth.Mvc.Models;
namespace OpenAuth.Mvc.Controllers
{
public class ResourceManagerController : BaseController
{
public ResourceManagerApp App { get; set; }
//
// GET: /UserManager/
[Authenticate]
public ActionResult Index()
{
return View();
}
//添加或修改Resource
[HttpPost]
public string Add(Resource model)
{
try
{
App.AddOrUpdate(model);
}
catch (Exception ex)
{
Result.Status = false;
Result.Message = ex.Message;
}
return JsonHelper.Instance.Serialize(Result);
}
/// <summary>
/// 加载某分类的所有Resources
/// </summary>
public string Load(string categoryId, int page = 1, int rows = 30)
{
return JsonHelper.Instance.Serialize(App.Load(AuthUtil.GetUserName(), categoryId, page, rows));
}
public string LoadForTree()
{
var models = App.LoadAll();
return JsonHelper.Instance.Serialize(models);
}
[HttpPost]
public string Delete(string[] ids)
{
try
{
App.Delete(ids);
}
catch (Exception e)
{
Result.Status = false;
Result.Message = e.Message;
}
return JsonHelper.Instance.Serialize(Result);
}
/// <summary>
/// 为用户或角色分配权限
/// </summary>
/// <param name="firstId">关联表中的firstId.</param>
/// <param name="key">关联表中的Key
/// <para>如UserResource/RoleResource</para>
/// </param>
/// <returns>ActionResult.</returns>
public ActionResult AssignRes(string firstId, string key)
{
ViewBag.FirstId = firstId;
ViewBag.ModuleType = key;
return View();
}
/// <summary>
/// 加载带有授权的资源信息
/// </summary>
/// <param name="cId">分类ID</param>
/// <param name="firstId">关联表中的firstId</param>
/// <param name="key">关联表中的key</param>
/// <returns>System.String.</returns>
public string LoadWithAccess(string cId, string firstId, string key)
{
return JsonHelper.Instance.Serialize(App.LoadWithAccess(AuthUtil.GetUserName(),key,firstId, cId));
}
}
}

View File

@ -1,81 +0,0 @@
using Infrastructure;
using OpenAuth.App;
using System;
using System.Web.Http;
using System.Web.Mvc;
using Newtonsoft.Json.Linq;
using OpenAuth.Mvc.Models;
namespace OpenAuth.Mvc.Controllers
{
public class RoleManagerController : BaseController
{
public RoleManagerApp App { get; set; }
//
// GET: /RoleManager/
[Authenticate]
public ActionResult Index()
{
return View();
}
//添加或修改角色
[System.Web.Mvc.HttpPost]
public string Add([FromBody]JObject obj)
{
try
{
App.AddOrUpdate(obj);
}
catch (Exception ex)
{
Result.Status = false;
Result.Message = ex.Message;
}
return JsonHelper.Instance.Serialize(Result);
}
/// <summary>
/// 加载角色下面的所有用户
/// </summary>
public string Load(string orgId, int pageCurrent = 1, int pageSize = 30)
{
return JsonHelper.Instance.Serialize(App.Load(orgId, pageCurrent, pageSize));
}
[System.Web.Mvc.HttpPost]
public string Delete(string[] ids)
{
try
{
foreach (var obj in ids)
{
App.Delete(obj);
}
}
catch (Exception e)
{
Result.Status = false;
Result.Message = e.Message;
}
return JsonHelper.Instance.Serialize(Result);
}
#region
public ActionResult LookupMulti(string firstId, string key)
{
ViewBag.FirstId = firstId;
ViewBag.ModuleType = key;
return View();
}
public string LoadForOrgAndUser(string orgId, string userId)
{
return JsonHelper.Instance.Serialize(App.LoadForOrgAndUser(orgId, userId));
}
#endregion
}
}

View File

@ -1,68 +0,0 @@
using Infrastructure;
using OpenAuth.App;
using OpenAuth.Domain;
using System;
using System.Web.Mvc;
using OpenAuth.App.SSO;
using OpenAuth.Mvc.Models;
namespace OpenAuth.Mvc.Controllers
{
/// <summary>
/// 进出库管理
/// <para>本示例主要演示如何使用用户拥有的机构/资源</para>
/// </summary>
public class StockManagerController : BaseController
{
public StockManagerApp App { get; set; }
//
// GET: /UserManager/
[Authenticate]
public ActionResult Index()
{
return View();
}
//添加或修改Stock
[HttpPost]
public string Add(Stock model)
{
try
{
var newmodel = new Stock();
model.CopyTo(newmodel);
App.AddOrUpdate(newmodel);
}
catch (Exception ex)
{
Result.Status = false;
Result.Message = ex.Message;
}
return JsonHelper.Instance.Serialize(Result);
}
/// <summary>
/// 加载节点下面的所有Stocks
/// </summary>
public string Load(string parentId, int page = 1, int rows = 30)
{
return JsonHelper.Instance.Serialize(App.Load(AuthUtil.GetUserName(), parentId, page, rows));
}
public string Delete(string[] ids)
{
try
{
App.Delete(ids);
}
catch (Exception e)
{
Result.Status = false;
Result.Message = e.Message;
}
return JsonHelper.Instance.Serialize(Result);
}
}
}

View File

@ -33,7 +33,7 @@ namespace OpenAuth.Mvc.Controllers
}
catch (Exception ex)
{
Result.Status = false;
Result.Code = 500;
Result.Message = ex.Message;
}
return JsonHelper.Instance.Serialize(Result);
@ -56,7 +56,7 @@ namespace OpenAuth.Mvc.Controllers
}
catch (Exception e)
{
Result.Status = false;
Result.Code = 500;
Result.Message = e.Message;
}

View File

@ -30,10 +30,8 @@ namespace OpenAuth.Mvc.Controllers
}
var data = new GridData
{
page = 1,
data = query,
count = query.Count(),
total = 1
};
return JsonHelper.Instance.Serialize(data);
}

View File

@ -153,13 +153,9 @@
<Compile Include="Areas\FlowManage\Controllers\FlowInstancesController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\LoginController.cs" />
<Compile Include="Controllers\ModuleElementManagerController.cs" />
<Compile Include="Controllers\ModuleManagerController.cs" />
<Compile Include="Controllers\OrgManagerController.cs" />
<Compile Include="Controllers\RelevanceManagerController.cs" />
<Compile Include="Controllers\ResourceManagerController.cs" />
<Compile Include="Controllers\RoleManagerController.cs" />
<Compile Include="Controllers\StockManagerController.cs" />
<Compile Include="Controllers\UserManagerController.cs" />
<Compile Include="Controllers\UserSessionController.cs" />
<Compile Include="Models\JobjectModelBinder.cs" />
@ -396,10 +392,6 @@
<Project>{0bbf2d65-fffd-4272-b138-8ea4fb6fec48}</Project>
<Name>OpenAuth.App</Name>
</ProjectReference>
<ProjectReference Include="..\OpenAuth.Domain\OpenAuth.Domain.csproj">
<Project>{6108da8e-92a1-4abe-b9f5-26d64d55ca2c}</Project>
<Name>OpenAuth.Domain</Name>
</ProjectReference>
<ProjectReference Include="..\OpenAuth.Repository\OpenAuth.Repository.csproj">
<Project>{e8df8dea-e2cf-4bdb-8f4f-3f8205b0e03a}</Project>
<Name>OpenAuth.Repository</Name>

View File

@ -128,6 +128,6 @@ tpwidget("init", {
<script type="text/javascript" src="/layui/layui.js"></script>
<script type="text/javascript" src="/js/leftNav.js"></script>
<script type="text/javascript" src="/js/index.js"></script>
<script type="text/javascript" src="/js/index.js?v=1"></script>
</body>
</html>

View File

@ -14,14 +14,16 @@ layui.config({
//更换皮肤
function skins(){
var skin = window.sessionStorage.getItem("skin");
if(skin){ //如果更换过皮肤
if(window.sessionStorage.getItem("skinValue") != "自定义"){
$("body").addClass(window.sessionStorage.getItem("skin"));
}else{
$(".layui-layout-admin .layui-header").css("background-color",skin.split(',')[0]);
$(".layui-bg-black").css("background-color",skin.split(',')[1]);
$(".hideMenu").css("background-color",skin.split(',')[2]);
}
if (skin) { //如果更换过皮肤
if (window.sessionStorage.getItem("skinValue") != "自定义") {
$("body").addClass(window.sessionStorage.getItem("skin"));
} else {
$(".layui-layout-admin .layui-header").css("background-color", skin.split(',')[0]);
$(".layui-bg-black").css("background-color", skin.split(',')[1]);
$(".hideMenu").css("background-color", skin.split(',')[2]);
}
} else {
$("body").addClass("blue");
}
}
skins();

View File

@ -1,54 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
namespace OpenAuth.Repository
{
public class CategoryRepository :BaseRepository<Category>, ICategoryRepository
{
public IEnumerable<Category> LoadCategorys(int pageindex, int pagesize)
{
return Context.Categories.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public IEnumerable<Category> LoadInOrgs(params string[] orgId)
{
var result = from category in Context.Categories where orgId.Contains(category.Id)
select category;
return result;
}
public int GetCategoryCntInOrgs(params string[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}
public IEnumerable<Category> LoadInOrgs(int pageindex, int pagesize, params string[] orgIds)
{
return LoadInOrgs(orgIds).OrderBy(u =>u.Id).Skip((pageindex -1)*pagesize).Take(pagesize);
}
public void Delete(string id)
{
Delete(u =>u.Id == id);
}
/// <summary>
/// 获取当前节点的所有下级节点
/// </summary>
public string[] GetSubIds(string orgId)
{
if (orgId == string.Empty)
{
return Find(null).Select(u => u.Id).ToArray();
}
var org = FindSingle(u => u.Id == orgId);
var ids = Find(u => u.CascadeId.Contains(org.CascadeId)).Select(u => u.Id).ToArray();
return ids;
}
}
}

View File

@ -1,45 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
namespace OpenAuth.Repository
{
public class ModuleRepository :BaseRepository<Module>, IModuleRepository
{
public IEnumerable<Module> LoadModules(int pageindex, int pagesize)
{
return Context.Modules.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public int GetRoleCntInOrgs(params string[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}
public int GetModuleCntInOrgs(params string[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}
public IEnumerable<Module> LoadInOrgs(int pageindex, int pagesize, params string[] orgIds)
{
return LoadInOrgs(orgIds).OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public void Delete(string id)
{
Delete(u =>u.Id == id);
}
public IEnumerable<Module> LoadInOrgs(params string[] orgId)
{
var result = from role in Context.Modules.Where(u =>u.ParentId != null && orgId.Contains(u.ParentId)) select role;
return result;
}
}
}

View File

@ -55,46 +55,56 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Models\Mapping\ApplicationMap.cs" />
<Compile Include="Models\Mapping\CategoryTypeMap.cs" />
<Compile Include="Models\Mapping\WFFrmMainMap.cs" />
<Compile Include="Models\Mapping\WFProcessInstanceMap.cs" />
<Compile Include="Models\Mapping\WFProcessOperationHistoryMap.cs" />
<Compile Include="Models\Mapping\WFProcessSchemeMap.cs" />
<Compile Include="Models\Mapping\WFProcessTransitionHistoryMap.cs" />
<Compile Include="Models\Mapping\WFSchemeContentMap.cs" />
<Compile Include="Models\Mapping\WFSchemeInfoMap.cs" />
<Compile Include="Domain\Application.cs" />
<Compile Include="Domain\Category.cs" />
<Compile Include="Domain\CategoryType.cs" />
<Compile Include="Domain\Entity.cs" />
<Compile Include="Domain\Module.cs" />
<Compile Include="Domain\ModuleElement.cs" />
<Compile Include="Domain\Org.cs" />
<Compile Include="Domain\Relevance.cs" />
<Compile Include="Domain\Resource.cs" />
<Compile Include="Domain\Role.cs" />
<Compile Include="Domain\Stock.cs" />
<Compile Include="Domain\User.cs" />
<Compile Include="Domain\UserExt.cs" />
<Compile Include="Domain\WFFrmMain.cs" />
<Compile Include="Domain\WFProcessInstance.cs" />
<Compile Include="Domain\WFProcessOperationHistory.cs" />
<Compile Include="Domain\WFProcessScheme.cs" />
<Compile Include="Domain\WFProcessTransitionHistory.cs" />
<Compile Include="Domain\WFSchemeContent.cs" />
<Compile Include="Domain\WFSchemeInfo.cs" />
<Compile Include="Interface\IRepository.cs" />
<Compile Include="Interface\IUnitWork.cs" />
<Compile Include="Mapping\ApplicationMap.cs" />
<Compile Include="Mapping\CategoryTypeMap.cs" />
<Compile Include="Mapping\WFFrmMainMap.cs" />
<Compile Include="Mapping\WFProcessInstanceMap.cs" />
<Compile Include="Mapping\WFProcessOperationHistoryMap.cs" />
<Compile Include="Mapping\WFProcessSchemeMap.cs" />
<Compile Include="Mapping\WFProcessTransitionHistoryMap.cs" />
<Compile Include="Mapping\WFSchemeContentMap.cs" />
<Compile Include="Mapping\WFSchemeInfoMap.cs" />
<Compile Include="UnitWork.cs" />
<Compile Include="BaseRepository.cs" />
<Compile Include="Models\Mapping\CategoryMap.cs" />
<Compile Include="Models\Mapping\ModuleElementMap.cs" />
<Compile Include="Models\Mapping\ModuleMap.cs" />
<Compile Include="Models\Mapping\OrgMap.cs" />
<Compile Include="Models\Mapping\RelevanceMap.cs" />
<Compile Include="Models\Mapping\ResourceMap.cs" />
<Compile Include="Models\Mapping\RoleMap.cs" />
<Compile Include="Models\Mapping\StockMap.cs" />
<Compile Include="Models\Mapping\UserMap.cs" />
<Compile Include="Models\OpenAuthDBContext.cs" />
<Compile Include="OrgRepository.cs" />
<Compile Include="Mapping\CategoryMap.cs" />
<Compile Include="Mapping\ModuleElementMap.cs" />
<Compile Include="Mapping\ModuleMap.cs" />
<Compile Include="Mapping\OrgMap.cs" />
<Compile Include="Mapping\RelevanceMap.cs" />
<Compile Include="Mapping\ResourceMap.cs" />
<Compile Include="Mapping\RoleMap.cs" />
<Compile Include="Mapping\StockMap.cs" />
<Compile Include="Mapping\UserMap.cs" />
<Compile Include="OpenAuthDBContext.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ModuleRepository.cs" />
<Compile Include="RoleRepository.cs" />
<Compile Include="ResourceRepository.cs" />
<Compile Include="CategoryRepository.cs" />
<Compile Include="StockRepository.cs" />
<Compile Include="UserRepository.cs" />
<Compile Include="RelevanceRepository.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj">
<Project>{5feaec9a-4f1e-4ee7-b377-9db1b0870dac}</Project>
<Name>Infrastructure</Name>
</ProjectReference>
<ProjectReference Include="..\OpenAuth.Domain\OpenAuth.Domain.csproj">
<Project>{6108da8e-92a1-4abe-b9f5-26d64d55ca2c}</Project>
<Name>OpenAuth.Domain</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />

View File

@ -6,13 +6,12 @@
// file will be lost if the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Data.Entity;
using System.Collections.Generic;
using OpenAuth.Domain;
using OpenAuth.Repository.Models.Mapping;
namespace OpenAuth.Repository.Models
namespace OpenAuth.Repository
{
public partial class OpenAuthDBContext: DbContext
{

View File

@ -1,56 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
namespace OpenAuth.Repository
{
public class OrgRepository : BaseRepository<Org>, IOrgRepository
{
public IEnumerable<Org> LoadOrgs()
{
return Find();
}
/// <summary>
/// 加载用户的所有机构
/// </summary>
public IEnumerable<Org> LoadByUser(string userId)
{
var result = from userorg in Context.Relevances
join org in Context.Orgs on userorg.SecondId equals org.Id
where userorg.FirstId == userId && userorg.Key =="UserOrg"
select org;
return result;
}
/// <summary>
/// 加载角色的所有机构
/// </summary>
public IEnumerable<Org> LoadByRole(string roleId)
{
var result = from userorg in Context.Relevances
join org in Context.Orgs on userorg.SecondId equals org.Id
where userorg.FirstId == roleId && userorg.Key == "RoleOrg"
select org;
return result;
}
public IEnumerable<Org> GetSubOrgs(string orgId)
{
string cascadeId = "0.";
if (!string.IsNullOrEmpty(orgId))
{
var org = FindSingle(u => u.Id == orgId);
if (org == null)
throw new Exception("未能找到指定对象信息");
cascadeId = org.CascadeId;
}
return Find(u => u.CascadeId.Contains(cascadeId));
}
}
}

Some files were not shown because too many files have changed in this diff Show More