diff --git a/Infrastructure/Response.cs b/Infrastructure/Response.cs
index fb627d8c..385a115a 100644
--- a/Infrastructure/Response.cs
+++ b/Infrastructure/Response.cs
@@ -2,8 +2,32 @@
{
public class Response
{
- public bool Status = true;
- public string Message = "操作成功";
- public dynamic Result;
+ ///
+ /// 操作消息【当Status不为 200时,显示详细的错误信息】
+ ///
+ public string Message { get; set; }
+
+ ///
+ /// 操作状态码,200为正常
+ ///
+ public int Code { get; set; }
+
+ public Response()
+ {
+ Code = 200;
+ }
+ }
+
+
+ ///
+ /// WEBAPI通用返回泛型基类
+ ///
+ ///
+ public class Response : Response
+ {
+ ///
+ /// 回传的结果
+ ///
+ public T Result { get; set; }
}
}
diff --git a/OpenAuth.App/AuthoriseFactory.cs b/OpenAuth.App/AuthoriseFactory.cs
new file mode 100644
index 00000000..5a2c28a5
--- /dev/null
+++ b/OpenAuth.App/AuthoriseFactory.cs
@@ -0,0 +1,28 @@
+using OpenAuth.Domain.Interface;
+
+namespace OpenAuth.Domain.Service
+{
+ ///
+ /// Ȩ乤Ƿǿ˺Ŵ
+ ///
+ 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(u =>u.Account == loginuser)
+ };
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenAuth.App/AuthoriseService.cs b/OpenAuth.App/AuthoriseService.cs
new file mode 100644
index 00000000..5fe6efff
--- /dev/null
+++ b/OpenAuth.App/AuthoriseService.cs
@@ -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
+{
+ ///
+ /// 领域服务
+ /// 用户授权服务
+ ///
+ public class AuthoriseService
+ {
+ public IUnitWork _unitWork { get; set; }
+ protected User _user;
+
+ private List _userRoleIds; //用户角色GUID
+
+ public List Modules
+ {
+ get { return GetModulesQuery().ToList(); }
+ }
+
+ public List Roles
+ {
+ get { return GetRolesQuery().ToList(); }
+ }
+
+ public List ModuleElements
+ {
+ get { return GetModuleElementsQuery().ToList(); }
+ }
+
+ public List Resources
+ {
+ get { return GetResourcesQuery().ToList(); }
+ }
+
+ public List Orgs
+ {
+ get { return GetOrgsQuery().ToList(); }
+ }
+
+ public User User
+ {
+ get { return _user; }
+ set
+ {
+ _user = value;
+ _userRoleIds = _unitWork.Find(u => u.FirstId == _user.Id && u.Key == "UserRole").Select(u => u.SecondId).ToList();
+ }
+ }
+
+ public void Check(string userName, string password)
+ {
+ var _user = _unitWork.FindSingle(u => u.Account == userName);
+ if (_user == null)
+ {
+ throw new Exception("用户帐号不存在");
+ }
+ _user.CheckPassword(password);
+ }
+
+ ///
+ /// 用户可访问的机构
+ ///
+ /// IQueryable<Org>.
+ public virtual IQueryable GetOrgsQuery()
+ {
+ var orgids = _unitWork.Find(
+ u =>
+ (u.FirstId == _user.Id && u.Key == "UserOrg") ||
+ (u.Key == "RoleOrg" && _userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId);
+ return _unitWork.Find(u => orgids.Contains(u.Id));
+ }
+
+ ///
+ /// 获取用户可访问的资源
+ ///
+ /// IQueryable<Resource>.
+ public virtual IQueryable GetResourcesQuery()
+ {
+ var resourceIds = _unitWork.Find(
+ u =>
+ (u.FirstId == _user.Id && u.Key == "UserResource") ||
+ (u.Key == "RoleResource" && _userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId);
+ return _unitWork.Find(u => resourceIds.Contains(u.Id));
+ }
+
+ ///
+ /// 模块菜单权限
+ ///
+ public virtual IQueryable GetModuleElementsQuery()
+ {
+ var elementIds = _unitWork.Find(
+ u =>
+ (u.FirstId == _user.Id && u.Key == "UserElement") ||
+ (u.Key == "RoleElement" && _userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId);
+ return _unitWork.Find(u => elementIds.Contains(u.Id));
+ }
+
+ ///
+ /// 得出最终用户拥有的模块
+ ///
+ public virtual IQueryable GetModulesQuery()
+ {
+ var moduleIds = _unitWork.Find(
+ u =>
+ (u.FirstId == _user.Id && u.Key == "UserModule") ||
+ (u.Key == "RoleModule" && _userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId);
+ return _unitWork.Find(u => moduleIds.Contains(u.Id)).OrderBy(u => u.SortNo);
+ }
+
+ //用户角色
+ public virtual IQueryable GetRolesQuery()
+ {
+ return _unitWork.Find(u => _userRoleIds.Contains(u.Id));
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenAuth.App/CategoryManagerApp.cs b/OpenAuth.App/CategoryManagerApp.cs
index 8464ca9a..53021fec 100644
--- a/OpenAuth.App/CategoryManagerApp.cs
+++ b/OpenAuth.App/CategoryManagerApp.cs
@@ -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 LoadAll()
{
- return _repository.Find(null).ToList();
+ return _unitWork.Find(null).ToList();
}
///
@@ -47,13 +33,13 @@ namespace OpenAuth.App
if (parentId == string.Empty)
{
categories = _unitWork.Find(pageindex, pagesize);
- total = _repository.GetCount();
+ total = _unitWork.GetCount();
}
else
{
var ids = GetSubCategories(parentId);
categories = _unitWork.Find(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(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(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(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(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(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(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(o => o.Id == org.ParentId);
if (parentOrg != null)
{
cascadeId = parentOrg.CascadeId + currentCascadeId +".";
diff --git a/OpenAuth.App/ModuleElementManagerApp.cs b/OpenAuth.App/ModuleElementManagerApp.cs
deleted file mode 100644
index 1b4790f5..00000000
--- a/OpenAuth.App/ModuleElementManagerApp.cs
+++ /dev/null
@@ -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 (c) . All rights reserved.
-//
-// 模块元素
-// ***********************************************************************
-
-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 LoadByModuleId(string id)
- {
- string username = AuthUtil.GetUserName();
- return _moduleEleManService.LoadByModuleId(username, id);
- }
-
- ///
- /// 获取带有授权状态的菜单列表
- ///
- /// 授权类型,当前有RoleElement/UserElement
- ///
- /// 当为RoleElement时,表示RoleId
- /// 当为UserElement时,表示UserId
- ///
- /// 模块ID
- public List 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);
- }
- }
-}
diff --git a/OpenAuth.App/ModuleManagerApp.cs b/OpenAuth.App/ModuleManagerApp.cs
index 96866a0a..7ecfd5c8 100644
--- a/OpenAuth.App/ModuleManagerApp.cs
+++ b/OpenAuth.App/ModuleManagerApp.cs
@@ -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(id);
}
public void AddOrUpdate(Module vm)
{
- _moduleManService.AddOrUpdate(vm);
+ // _moduleManService.AddOrUpdate(vm);
}
#region 用户/角色分配模块
@@ -32,7 +28,7 @@ namespace OpenAuth.App
/// The user unique identifier.
public List LoadForUser(string userId)
{
- return _moduleManService.LoadForUser(userId);
+ return null;
}
///
@@ -41,7 +37,7 @@ namespace OpenAuth.App
/// The role unique identifier.
public List LoadForRole(string roleId)
{
- return _moduleManService.LoadForRole(roleId);
+ return null;
}
#endregion 用户/角色分配模块
diff --git a/OpenAuth.App/OpenAuth.App.csproj b/OpenAuth.App/OpenAuth.App.csproj
index acf898d6..ccfd7626 100644
--- a/OpenAuth.App/OpenAuth.App.csproj
+++ b/OpenAuth.App/OpenAuth.App.csproj
@@ -80,6 +80,8 @@
+
+
@@ -89,14 +91,12 @@
+
+
-
-
-
-
@@ -106,7 +106,6 @@
-
@@ -123,9 +122,9 @@
{5FEAEC9A-4F1E-4EE7-B377-9DB1B0870DAC}
Infrastructure
-
- {6108da8e-92a1-4abe-b9f5-26d64d55ca2c}
- OpenAuth.Domain
+
+ {e8df8dea-e2cf-4bdb-8f4f-3f8205b0e03a}
+ OpenAuth.Repository
diff --git a/OpenAuth.App/OrgManagerApp.cs b/OpenAuth.App/OrgManagerApp.cs
index 8d17b9a8..5a80ba28 100644
--- a/OpenAuth.App/OrgManagerApp.cs
+++ b/OpenAuth.App/OrgManagerApp.cs
@@ -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 GetAll()
- {
- return _repository.LoadOrgs().ToList();
- }
-
- ///
- /// 部门的直接子部门
- /// TODO:可以根据用户的喜好决定选择LoadAllChildren或LoadDirectChildren
- ///
- /// The org unique identifier.
- /// IEnumerable{Org}.
- public IList LoadDirectChildren(string orgId)
- {
- return _repository.Find(u => u.ParentId == orgId).ToList();
- }
-
- ///
- /// 得到部门的所有子部门
- /// 如果orgId为0,表示取得所有部门
- ///
- 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; }
///
/// 添加部门
@@ -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(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(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
///
public void DelOrg(string[] ids)
{
- var delOrg = _repository.Find(u => ids.Contains(u.Id)).ToList();
+ var delOrg = _unitWork.Find(u => ids.Contains(u.Id)).ToList();
foreach (var org in delOrg)
{
- _repository.Delete(u => u.CascadeId.Contains(org.CascadeId));
+ _unitWork.Delete(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(u => u.FirstId == userId && u.Key == "UserRole").Select(u => u.SecondId).ToList();
//用户角色与自己分配到的角色ID
var moduleIds =
- _relevanceRepository.Find(
+ _unitWork.Find(
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();
- return _repository.Find(u => moduleIds.Contains(u.Id)).ToList();
+ return _unitWork.Find(u => moduleIds.Contains(u.Id)).ToList();
}
///
@@ -127,11 +87,40 @@ namespace OpenAuth.App
public List LoadForRole(string roleId)
{
var moduleIds =
- _relevanceRepository.Find(u => u.FirstId == roleId && u.Key == "RoleOrg")
+ _unitWork.Find(u => u.FirstId == roleId && u.Key == "RoleOrg")
.Select(u => u.SecondId)
.ToList();
if (!moduleIds.Any()) return new List();
- return _repository.Find(u => moduleIds.Contains(u.Id)).ToList();
+ return _unitWork.Find(u => moduleIds.Contains(u.Id)).ToList();
+ }
+
+
+ ///
+ /// 得到部门的所有子部门
+ /// 如果orgId为0,表示取得所有部门
+ ///
+ public GridData LoadAllChildren(string orgId)
+ {
+ var query = GetSubOrgs(orgId);
+ return new GridData
+ {
+ data = query.ToList(),
+ count = query.Count(),
+ };
+ }
+
+ public IEnumerable GetSubOrgs(string orgId)
+ {
+ string cascadeId = "0.";
+ if (!string.IsNullOrEmpty(orgId))
+ {
+ var org = _unitWork.FindSingle(u => u.Id == orgId);
+ if (org == null)
+ throw new Exception("未能找到指定对象信息");
+ cascadeId = org.CascadeId;
+ }
+
+ return _unitWork.Find(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(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(o => o.Id == org.ParentId);
if (parentOrg != null)
{
cascadeId = parentOrg.CascadeId + currentCascadeId+".";
diff --git a/OpenAuth.App/ResourceManagerApp.cs b/OpenAuth.App/ResourceManagerApp.cs
deleted file mode 100644
index 044cb7c5..00000000
--- a/OpenAuth.App/ResourceManagerApp.cs
+++ /dev/null
@@ -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 LoadAll()
- {
- return _resManagerService.LoadAll();
- }
-
- ///
- /// 加载一个节点下面的一个或全部Resources
- ///
- 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);
-
- }
-
- ///
- /// 获取带有授权状态的菜单列表
- ///
- /// 授权类型,当前有RoleResource/UserResource
- ///
- /// 当为RoleResource时,表示RoleId
- /// 当为UserResource时,表示UserId
- ///
- /// 分类ID
- public List LoadWithAccess(string username, string accessType, string firstId, string cId)
- {
- return _resManagerService.LoadWithAccess(username, accessType, firstId, cId);
- }
-
- }
-}
\ No newline at end of file
diff --git a/OpenAuth.App/RevelanceManagerApp.cs b/OpenAuth.App/RevelanceManagerApp.cs
index 8ab67257..aab0f212 100644
--- a/OpenAuth.App/RevelanceManagerApp.cs
+++ b/OpenAuth.App/RevelanceManagerApp.cs
@@ -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;
- }
-
- ///
- /// 添加关联
- /// 比如给用户分配资源,那么firstId就是用户ID,secIds就是资源ID列表
- ///
- /// 关联的类型,如"UserResource"
- public void Assign(string type, string firstId, string[] secIds)
- {
- _relevanceRepository.AddRelevance(type, secIds.ToLookup(u => firstId));
- }
-
- ///
- /// 取消关联
- ///
- /// 关联的类型,如"UserResource"
- /// The first identifier.
- /// The sec ids.
- 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; }
+
+ ///
+ /// 添加关联
+ /// 比如给用户分配资源,那么firstId就是用户ID,secIds就是资源ID列表
+ ///
+ /// 关联的类型,如"UserResource"
+ public void Assign(string type, string firstId, string[] secIds)
+ {
+ Assign(type, secIds.ToLookup(u => firstId));
+ }
+
+ public void Assign(string key, ILookup 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();
+ }
+
+
+
+ ///
+ /// 删除关联
+ ///
+ /// 关联标识
+ /// 关联的<firstId, secondId>数组
+ public void DeleteBy(string key, ILookup idMaps)
+ {
+ foreach (var sameVals in idMaps)
+ {
+ foreach (var value in sameVals)
+ {
+ _unitWork.Delete(u => u.Key == key && u.FirstId == sameVals.Key && u.SecondId == value);
+ }
+ }
+ }
+
+ ///
+ /// 取消关联
+ ///
+ /// 关联的类型,如"UserResource"
+ /// The first identifier.
+ /// The sec ids.
+ 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(u => firstIds.Contains(u.FirstId) && u.Key == key);
+ }
+
+ ///
+ /// 添加新的关联
+ ///
+ /// 关联标识
+ /// 关联的<firstId, secondId>数组
+ public void AddRelevance(string key, ILookup 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();
+ }
+ }
}
\ No newline at end of file
diff --git a/OpenAuth.App/RoleManagerApp.cs b/OpenAuth.App/RoleManagerApp.cs
deleted file mode 100644
index e1acd29b..00000000
--- a/OpenAuth.App/RoleManagerApp.cs
+++ /dev/null
@@ -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));
- }
- }
-
- ///
- /// 加载一个部门及子部门全部Roles
- ///
- public GridData Load(string orgId, int pageindex, int pagesize)
- {
- if (pageindex < 1) pageindex = 1; //TODO:如果列表为空新增加一个用户后,前端会传一个0过来,奇怪??
- IEnumerable 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();
- 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;
- }
-
- ///
- /// 获取当前组织的所有下级组织
- ///
- 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();
- 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 LoadForUser(string userId)
- {
- return _repository.LoadForUser(userId).ToList();
- }
-
- public List LoadForOrgAndUser(string orgId, string userId)
- {
- var userroles = LoadForUser(userId);
- var orgroles = _repository.LoadInOrgs(GetSubOrgIds(orgId)).ToList();
-
- var rolevms = new List();
- 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 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();
- }
- }
-}
\ No newline at end of file
diff --git a/OpenAuth.App/SSO/LoginResult.cs b/OpenAuth.App/SSO/LoginResult.cs
index 303daee7..2d9deaed 100644
--- a/OpenAuth.App/SSO/LoginResult.cs
+++ b/OpenAuth.App/SSO/LoginResult.cs
@@ -1,9 +1,9 @@
+using Infrastructure;
+
namespace OpenAuth.App.SSO
{
- public class LoginResult
+ public class LoginResult :Response
{
- public bool Success;
- public string ErrorMsg;
public string ReturnUrl;
public string Token;
}
diff --git a/OpenAuth.App/SSO/SSOAuthUtil.cs b/OpenAuth.App/SSO/SSOAuthUtil.cs
index 8e8e93bd..6975374b 100644
--- a/OpenAuth.App/SSO/SSOAuthUtil.cs
+++ b/OpenAuth.App/SSO/SSOAuthUtil.cs
@@ -62,14 +62,14 @@ namespace OpenAuth.App.SSO
//Session
new ObjCacheProvider().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;
diff --git a/OpenAuth.App/StockManagerApp.cs b/OpenAuth.App/StockManagerApp.cs
deleted file mode 100644
index 7587ba7a..00000000
--- a/OpenAuth.App/StockManagerApp.cs
+++ /dev/null
@@ -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;
- }
-
- ///
- /// 根据部门ID得到进出库信息
- ///
- 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);
-
- }
-
-
- }
-}
\ No newline at end of file
diff --git a/OpenAuth.App/SystemAuthService.cs b/OpenAuth.App/SystemAuthService.cs
new file mode 100644
index 00000000..7bef0908
--- /dev/null
+++ b/OpenAuth.App/SystemAuthService.cs
@@ -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
+{
+ ///
+ /// 领域服务
+ /// 超级管理员权限
+ ///
+ public class SystemAuthService : AuthoriseService
+ {
+ public SystemAuthService()
+ {
+ _user = new User { Account = "System", Id = string.Empty };
+ }
+
+
+
+ public override IQueryable GetOrgsQuery()
+ {
+ return _unitWork.Find(null);
+ }
+
+ public override IQueryable GetResourcesQuery()
+ {
+ return _unitWork.Find(null);
+ }
+
+ public override IQueryable GetModuleElementsQuery()
+ {
+ return _unitWork.Find(null);
+ }
+
+ public override IQueryable GetModulesQuery()
+ {
+ return _unitWork.Find(null);
+ }
+
+ public override IQueryable GetRolesQuery()
+ {
+ //用户角色
+ return _unitWork.Find(null);
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenAuth.App/UserManagerApp.cs b/OpenAuth.App/UserManagerApp.cs
index f34d14ca..8c0f3fc0 100644
--- a/OpenAuth.App/UserManagerApp.cs
+++ b/OpenAuth.App/UserManagerApp.cs
@@ -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(u => u.Account == account);
}
- public int GetUserCntInOrg(string orgId)
- {
- if (orgId == string.Empty)
- {
- return _repository.Find(null).Count();
- }
- else
- {
- return _repository.GetUserCntInOrgs(GetSubOrgIds(orgId));
- }
- }
///
/// 加载一个部门及子部门全部用户
@@ -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(null).OrderBy(u => u.Id).Skip((request.page - 1) * request.limit).Take(request.limit);
+ records = _unitWork.GetCount();
}
else
{
var ids = GetSubOrgIds(request.orgId);
- users = _repository.LoadInOrgs(request.page, request.limit, ids);
- records = _repository.GetUserCntInOrgs(ids);
+ users = _unitWork.Find(u =>ids.Contains(u.Id)).OrderBy(u => u.Id).Skip((request.page - 1) * request.limit).Take(request.limit);
+ records = _unitWork.GetCount();
}
var userviews = new List();
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
///
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(u => u.Id == orgId);
+ var orgs = _unitWork.Find(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(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(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(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(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 GetUsers(IEnumerable userids)
+ ///
+ /// 加载用户的所有机构
+ ///
+ public IEnumerable LoadByUser(string userId)
{
- return _repository.Find(u => userids.Contains(u.Id));
+ var result = from userorg in _unitWork.Find(null)
+ join org in _unitWork.Find(null) on userorg.SecondId equals org.Id
+ where userorg.FirstId == userId && userorg.Key == "UserOrg"
+ select org;
+ return result;
}
+
+
}
}
\ No newline at end of file
diff --git a/OpenAuth.App/ViewModel/GridData.cs b/OpenAuth.App/ViewModel/GridData.cs
index 45315976..b1cb30bb 100644
--- a/OpenAuth.App/ViewModel/GridData.cs
+++ b/OpenAuth.App/ViewModel/GridData.cs
@@ -27,14 +27,7 @@ namespace OpenAuth.App.ViewModel
/// 操作消息
///
public string msg;
- ///
- /// 页码
- ///
- public int page;
- ///
- /// 总页数
- ///
- public int total;
+
///
/// 总记录条数
///
diff --git a/OpenAuth.App/WFFormService.cs b/OpenAuth.App/WFFormService.cs
index 8ee59f24..84d8caaf 100644
--- a/OpenAuth.App/WFFormService.cs
+++ b/OpenAuth.App/WFFormService.cs
@@ -13,12 +13,7 @@ namespace OpenAuth.App
///
public class WFFormService
{
- protected IUnitWork _unitWork;
-
- public WFFormService(IUnitWork unitWork)
- {
- _unitWork = unitWork;
- }
+ public IUnitWork _unitWork { get; set; }
public List GetAllList()
{
@@ -39,12 +34,10 @@ namespace OpenAuth.App
{
var result = new GridData
{
- page = pageCurrent
+ count = _unitWork.Find(null).Count(),
+ data = _unitWork.Find(pageCurrent, pageSize, "ModifyDate descending", null).ToList()
};
- int cnt = _unitWork.Find(null).Count();
- result.total = cnt % pageSize == 0 ? cnt / pageSize : cnt / pageSize + 1;
- result.data = _unitWork.Find(pageCurrent, pageSize, "ModifyDate descending", null).ToList();
return result;
}
diff --git a/OpenAuth.App/WFProcessInstanceService.cs b/OpenAuth.App/WFProcessInstanceService.cs
index 12fc161b..9b9971d9 100644
--- a/OpenAuth.App/WFProcessInstanceService.cs
+++ b/OpenAuth.App/WFProcessInstanceService.cs
@@ -16,12 +16,7 @@ namespace OpenAuth.App
///
public class WFProcessInstanceService
{
- protected IUnitWork _unitWork;
-
- public WFProcessInstanceService(IUnitWork unitWork)
- {
- _unitWork = unitWork;
- }
+ public IUnitWork _unitWork { get; set; }
#region 获取数据
///
@@ -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(u => u.CreateUserId == userid).Count();
+ result.count = _unitWork.Find(u => u.CreateUserId == userid).Count();
if (type == "inbox") //待办事项
{
- result.total = cnt%pageSize == 0? cnt/pageSize : cnt/pageSize + 1;
result.data = _unitWork.Find(pageCurrent, pageSize, "CreateDate descending", null).ToList();
}
else if (type == "outbox") //已办事项
{
- result.total = cnt % pageSize == 0 ? cnt / pageSize : cnt / pageSize + 1;
result.data = _unitWork.Find(pageCurrent, pageSize, "CreateDate descending", null).ToList();
}
else //我的流程
{
- result.total = cnt % pageSize == 0 ? cnt / pageSize : cnt / pageSize + 1;
result.data = _unitWork.Find(pageCurrent, pageSize, "CreateDate descending", null).ToList();
}
diff --git a/OpenAuth.App/WFSchemeService.cs b/OpenAuth.App/WFSchemeService.cs
index 77374008..4c799d50 100644
--- a/OpenAuth.App/WFSchemeService.cs
+++ b/OpenAuth.App/WFSchemeService.cs
@@ -13,12 +13,7 @@ namespace OpenAuth.App
///
public class WFSchemeService
{
- protected IUnitWork _unitWork;
-
- public WFSchemeService(IUnitWork unitWork)
- {
- _unitWork = unitWork;
- }
+ public IUnitWork _unitWork { get; set; }
///
/// 保存流程
@@ -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(null).Count();
- result.total = cnt%pageSize ==0?cnt/pageSize:cnt/pageSize+1;
+ result.count = _unitWork.Find(null).Count();
result.data = _unitWork.Find(pageCurrent, pageSize, "ModifyDate descending", null).ToList();
return result;
diff --git a/OpenAuth.Domain/Interface/ICategoryRepository.cs b/OpenAuth.Domain/Interface/ICategoryRepository.cs
deleted file mode 100644
index b16a0ddf..00000000
--- a/OpenAuth.Domain/Interface/ICategoryRepository.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace OpenAuth.Domain.Interface
-{
- public interface ICategoryRepository :IRepository
- {
- IEnumerable LoadCategorys(int pageindex, int pagesize);
-
- IEnumerable LoadInOrgs(params string[] orgId);
- int GetCategoryCntInOrgs(params string[] orgIds);
- IEnumerable LoadInOrgs(int pageindex, int pagesize, params string[] orgIds);
-
- ///
- /// 获取子分类ID
- ///
- string[] GetSubIds(string orgId);
-
- void Delete(string id);
-
- }
-}
\ No newline at end of file
diff --git a/OpenAuth.Domain/Interface/IModuleRepository.cs b/OpenAuth.Domain/Interface/IModuleRepository.cs
deleted file mode 100644
index 302b9272..00000000
--- a/OpenAuth.Domain/Interface/IModuleRepository.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace OpenAuth.Domain.Interface
-{
- public interface IModuleRepository :IRepository
- {
- IEnumerable LoadModules(int pageindex, int pagesize);
-
- IEnumerable LoadInOrgs(params string[] orgId);
- int GetModuleCntInOrgs(params string[] orgIds);
- IEnumerable LoadInOrgs(int pageindex, int pagesize, params string[] orgIds);
-
-
- void Delete(string id);
-
- }
-}
\ No newline at end of file
diff --git a/OpenAuth.Domain/Interface/IOrgRepository.cs b/OpenAuth.Domain/Interface/IOrgRepository.cs
deleted file mode 100644
index 78318cda..00000000
--- a/OpenAuth.Domain/Interface/IOrgRepository.cs
+++ /dev/null
@@ -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
- {
- IEnumerable LoadOrgs();
-
- IEnumerable LoadByUser(string userId);
-
- IEnumerable LoadByRole(string roleId);
-
- ///
- /// 获取包括自己在内的全部子部门
- ///
- /// 部门ID
- IEnumerable GetSubOrgs(string orgId);
- }
-}
diff --git a/OpenAuth.Domain/Interface/IRelevanceRepository.cs b/OpenAuth.Domain/Interface/IRelevanceRepository.cs
deleted file mode 100644
index 29e95cef..00000000
--- a/OpenAuth.Domain/Interface/IRelevanceRepository.cs
+++ /dev/null
@@ -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 (c) . All rights reserved.
-//
-// 多对多关系统一处理
-// ***********************************************************************
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace OpenAuth.Domain.Interface
-{
- public interface IRelevanceRepository : IRepository
- {
- void DeleteBy(string key, params string[] firstIds);
- void DeleteBy(string key, ILookup idMaps);
-
- void AddRelevance( string key, ILookup idMaps);
- }
-}
diff --git a/OpenAuth.Domain/Interface/IResourceRepository.cs b/OpenAuth.Domain/Interface/IResourceRepository.cs
deleted file mode 100644
index bd381c54..00000000
--- a/OpenAuth.Domain/Interface/IResourceRepository.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace OpenAuth.Domain.Interface
-{
- public interface IResourceRepository :IRepository
- {
- IEnumerable LoadResources(int pageindex, int pagesize);
-
- IEnumerable LoadInOrgs(params string[] orgId);
- int GetResourceCntInOrgs(params string[] orgIds);
- IEnumerable LoadInOrgs(int pageindex, int pagesize, params string[] orgIds);
-
- void Delete(string id);
-
- }
-}
\ No newline at end of file
diff --git a/OpenAuth.Domain/Interface/IRoleRepository.cs b/OpenAuth.Domain/Interface/IRoleRepository.cs
deleted file mode 100644
index b4934d14..00000000
--- a/OpenAuth.Domain/Interface/IRoleRepository.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace OpenAuth.Domain.Interface
-{
- public interface IRoleRepository :IRepository
- {
- IEnumerable LoadRoles(int pageindex, int pagesize);
-
- int GetRoleCntInOrgs(params string[] orgIds);
- IEnumerable LoadInOrgs(int pageindex, int pagesize, params string[] orgIds);
- IEnumerable LoadInOrgs(params string[] orgId);
- IEnumerable LoadForUser(string userId);
-
- void Delete(string id);
-
- }
-}
\ No newline at end of file
diff --git a/OpenAuth.Domain/Interface/IStockRepository.cs b/OpenAuth.Domain/Interface/IStockRepository.cs
deleted file mode 100644
index a1d6cc1f..00000000
--- a/OpenAuth.Domain/Interface/IStockRepository.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace OpenAuth.Domain.Interface
-{
- public interface IStockRepository :IRepository
- {
- IEnumerable LoadStocks(int pageindex, int pagesize);
-
- IEnumerable LoadInOrgs(params string[] orgId);
- int GetStockCntInOrgs(params string[] orgIds);
- IEnumerable LoadInOrgs(int pageindex, int pagesize, params string[] orgIds);
-
- void Delete(string id);
-
- }
-}
\ No newline at end of file
diff --git a/OpenAuth.Domain/Interface/IUserRepository.cs b/OpenAuth.Domain/Interface/IUserRepository.cs
deleted file mode 100644
index 48b658be..00000000
--- a/OpenAuth.Domain/Interface/IUserRepository.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace OpenAuth.Domain.Interface
-{
- public interface IUserRepository :IRepository
- {
- IEnumerable LoadUsers(int pageindex, int pagesize);
-
- IEnumerable LoadInOrgs(params string[] orgId);
- int GetUserCntInOrgs(params string[] orgIds);
- IEnumerable LoadInOrgs(int pageindex, int pagesize, params string[] orgIds);
-
- }
-}
\ No newline at end of file
diff --git a/OpenAuth.Domain/OpenAuth.Domain.csproj b/OpenAuth.Domain/OpenAuth.Domain.csproj
index c2532388..a6054cb0 100644
--- a/OpenAuth.Domain/OpenAuth.Domain.csproj
+++ b/OpenAuth.Domain/OpenAuth.Domain.csproj
@@ -42,44 +42,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/OpenAuth.WebTest/Controllers/LoginController.cs b/OpenAuth.WebTest/Controllers/LoginController.cs
index 7e0f2257..430a6271 100644
--- a/OpenAuth.WebTest/Controllers/LoginController.cs
+++ b/OpenAuth.WebTest/Controllers/LoginController.cs
@@ -18,7 +18,7 @@ namespace OpenAuth.WebTest.Controllers
public ActionResult Index(string username, string password)
{
var result = AuthUtil.Login(_appKey, username, password);
- if (result.Success)
+ if (result.Code == 200)
return Redirect("/home/index?Token=" + result.Token);
else
{
diff --git a/OpenAuth.sln b/OpenAuth.sln
index a8e05b23..3f26ec0c 100644
--- a/OpenAuth.sln
+++ b/OpenAuth.sln
@@ -1,23 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
-VisualStudioVersion = 14.0.24720.0
+VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "1 Presentation(用户UI)", "1 Presentation(用户UI)", "{57649E80-38FC-421D-82E1-BE71A786F762}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "用户UI", "用户UI", "{57649E80-38FC-421D-82E1-BE71A786F762}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2 Application(应用层)", "2 Application(应用层)", "{757BB00A-46B6-4B9B-9331-D6B60BE92E05}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "应用层", "应用层", "{757BB00A-46B6-4B9B-9331-D6B60BE92E05}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3 Domain(领域层)", "3 Domain(领域层)", "{7618C0B1-D556-40C2-B2DD-CCECDC4E46B6}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "6 Test(测试)", "6 Test(测试)", "{C59DF46D-7815-462B-9FFF-750B2120B75B}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test(测试)", "Test(测试)", "{C59DF46D-7815-462B-9FFF-750B2120B75B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenAuth.App", "OpenAuth.App\OpenAuth.App.csproj", "{0BBF2D65-FFFD-4272-B138-8EA4FB6FEC48}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenAuth.Domain", "OpenAuth.Domain\OpenAuth.Domain.csproj", "{6108DA8E-92A1-4ABE-B9F5-26D64D55CA2C}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenAuth.UnitTest", "OpenAuth.UnitTest\OpenAuth.UnitTest.csproj", "{2E6B5B73-7757-43F0-8AC8-3030F7C191B8}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "4 功能适配层", "4 功能适配层", "{7A38939E-FC9B-44A9-BD3D-E0CE438624E6}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "基础功能", "基础功能", "{7A38939E-FC9B-44A9-BD3D-E0CE438624E6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenAuth.Repository", "OpenAuth.Repository\OpenAuth.Repository.csproj", "{E8DF8DEA-E2CF-4BDB-8F4F-3F8205B0E03A}"
EndProject
@@ -39,10 +35,6 @@ Global
{0BBF2D65-FFFD-4272-B138-8EA4FB6FEC48}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0BBF2D65-FFFD-4272-B138-8EA4FB6FEC48}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0BBF2D65-FFFD-4272-B138-8EA4FB6FEC48}.Release|Any CPU.Build.0 = Release|Any CPU
- {6108DA8E-92A1-4ABE-B9F5-26D64D55CA2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {6108DA8E-92A1-4ABE-B9F5-26D64D55CA2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {6108DA8E-92A1-4ABE-B9F5-26D64D55CA2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {6108DA8E-92A1-4ABE-B9F5-26D64D55CA2C}.Release|Any CPU.Build.0 = Release|Any CPU
{2E6B5B73-7757-43F0-8AC8-3030F7C191B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E6B5B73-7757-43F0-8AC8-3030F7C191B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E6B5B73-7757-43F0-8AC8-3030F7C191B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -73,7 +65,6 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0BBF2D65-FFFD-4272-B138-8EA4FB6FEC48} = {757BB00A-46B6-4B9B-9331-D6B60BE92E05}
- {6108DA8E-92A1-4ABE-B9F5-26D64D55CA2C} = {7618C0B1-D556-40C2-B2DD-CCECDC4E46B6}
{2E6B5B73-7757-43F0-8AC8-3030F7C191B8} = {C59DF46D-7815-462B-9FFF-750B2120B75B}
{E8DF8DEA-E2CF-4BDB-8F4F-3F8205B0E03A} = {7A38939E-FC9B-44A9-BD3D-E0CE438624E6}
{2A9D9687-1822-41CF-B7DF-819BFC0F8FE9} = {57649E80-38FC-421D-82E1-BE71A786F762}
diff --git a/数据库设计关系图/OpenAuthDB.pdm b/数据库设计关系图/OpenAuthDB.pdm
index d03c9958..d04f1a20 100644
--- a/数据库设计关系图/OpenAuthDB.pdm
+++ b/数据库设计关系图/OpenAuthDB.pdm
@@ -1,5 +1,5 @@
-
+
@@ -3967,7 +3967,7 @@ PhysOpts=
[ModelOptions\Default Opts\FRMESOB<<WorkloadGroup>>]
PhysOpts=
-D:\Project\OpenAuth.Net\数据库设计关系图\OpenAuthDB.pdm
+F:\测试学习\OpenAuth.Net\数据库设计关系图\OpenAuthDB.pdm
9401CEBA-B163-4ADB-AECF-03CE78C0FFF3
@@ -4609,8 +4609,8 @@ Shadow=0
1445621646
1486308596
-((-16289,-28155), (-4109,-13841))
-((-11320,-28155),(-11320,-20119),(-9079,-20119),(-9079,-13841))
+((-15525,-28159), (-4651,-13633))
+((-11187,-28159),(-11187,-20119),(-8989,-20119),(-8989,-13633))
1
1
12615680
@@ -4632,8 +4632,8 @@ DESTINATION 0 新宋体,8,N
1507604605
1507605628
-((37892,-46260), (50904,-35818))
-((37892,-46260),(50904,-35818))
+((38717,-46225), (50312,-35679))
+((38717,-46225),(50312,-35679))
1
1
12615680
@@ -4677,7 +4677,7 @@ DESTINATION 0 新宋体,8,N
1445619891
1504801532
-1
-((-20822,-18333), (4556,-4087))
+((-19617,-17771), (3351,-4649))
3
12615680
1
@@ -4702,7 +4702,7 @@ Triggers 0 新宋体,8,N
1445621167
1504801532
-1
-((-20854,-34427), (1064,-21981))
+((-19834,-33940), (44,-22468))
3
12615680
1
@@ -4754,7 +4754,7 @@ Triggers 0 新宋体,8,N
1445623111
1505973354
-1
-((35997,-28184), (61807,-11238))
+((37225,-27510), (60579,-11912))
3
12615680
1
@@ -4779,7 +4779,7 @@ Triggers 0 新宋体,8,N
1445623375
1504801532
-1
-((33792,-9961), (54844,-2015))
+((34765,-9662), (53871,-2314))
3
12615680
1
@@ -4804,7 +4804,7 @@ Triggers 0 新宋体,8,N
1445623879
1505973346
-1
-((7453,-25554), (31967,-15808))
+((8612,-25180), (30808,-16182))
3
12615680
1
@@ -4856,7 +4856,7 @@ Triggers 0 新宋体,8,N
1450016158
1507605628
-1
-((35555,-50674), (57905,-40926))
+((36598,-50299), (56862,-41301))
3
12615680
1
@@ -4881,7 +4881,7 @@ Triggers 0 新宋体,8,N
1507604399
1507605628
-1
-((33979,-37468), (55031,-30422))
+((34952,-37206), (54058,-30684))
3
12615680
1