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

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

@@ -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

@@ -0,0 +1,66 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 应用
/// </summary>
public partial class Application : Entity
{
public Application()
{
this.Name= string.Empty;
this.AppId= string.Empty;
this.AppKey= string.Empty;
this.Description= string.Empty;
this.Icon= string.Empty;
this.CreateTime= DateTime.Now;
this.CreateUser= string.Empty;
}
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 应用ID
/// </summary>
public string AppId { get; set; }
/// <summary>
/// 应用密钥
/// </summary>
public string AppKey { get; set; }
/// <summary>
/// 应用描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 应用图标
/// </summary>
public string Icon { get; set; }
/// <summary>
/// 是否可用
/// </summary>
public bool Disable { get; set; }
/// <summary>
/// 创建日期
/// </summary>
public System.DateTime? CreateTime { get; set; }
/// <summary>
/// 创建人
/// </summary>
public string CreateUser { get; set; }
}
}

View File

@@ -0,0 +1,62 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 分类表
/// </summary>
public partial class Category : Entity
{
public Category()
{
this.CascadeId= string.Empty;
this.Name= string.Empty;
this.Code= string.Empty;
this.Status= 0;
this.SortNo= 0;
this.TypeId= string.Empty;
this.ParentId= string.Empty;
}
/// <summary>
/// 节点语义ID
/// </summary>
public string CascadeId { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 编号
/// </summary>
public string Code { get; set; }
/// <summary>
/// 当前状态
/// </summary>
public int Status { get; set; }
/// <summary>
/// 排序号
/// </summary>
public int SortNo { get; set; }
/// <summary>
/// 分类所属科目
/// </summary>
public string TypeId { get; set; }
/// <summary>
/// 父节点流水号
/// </summary>
public string ParentId { get; set; }
}
}

View File

@@ -0,0 +1,47 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 分类类型
/// </summary>
public partial class CategoryType : Entity
{
public CategoryType()
{
this.Name= string.Empty;
this.Code= string.Empty;
this.CreateTime= DateTime.Now;
this.CreateUser= string.Empty;
}
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 编码
/// </summary>
public string Code { get; set; }
/// <summary>
/// 创建日期
/// </summary>
public System.DateTime? CreateTime { get; set; }
/// <summary>
/// 创建人
/// </summary>
public string CreateUser { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
namespace OpenAuth.Domain
{
public abstract class Entity
{
public string Id { get; set; }
public Entity()
{
Id = Guid.NewGuid().ToString();
}
}
}

View File

@@ -0,0 +1,85 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 功能模块表
/// </summary>
public partial class Module : Entity
{
public Module()
{
this.CascadeId= string.Empty;
this.Name= string.Empty;
this.Url= string.Empty;
this.HotKey= string.Empty;
this.IconName= string.Empty;
this.Status= 0;
this.ParentName= string.Empty;
this.Vector= string.Empty;
this.SortNo= 0;
this.ParentId= string.Empty;
}
/// <summary>
/// 节点语义ID
/// </summary>
public string CascadeId { get; set; }
/// <summary>
/// 功能模块名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 主页面URL
/// </summary>
public string Url { get; set; }
/// <summary>
/// 热键
/// </summary>
public string HotKey { get; set; }
/// <summary>
/// 是否叶子节点
/// </summary>
public bool IsLeaf { get; set; }
/// <summary>
/// 是否自动展开
/// </summary>
public bool IsAutoExpand { get; set; }
/// <summary>
/// 节点图标文件名称
/// </summary>
public string IconName { get; set; }
/// <summary>
/// 当前状态
/// </summary>
public int Status { get; set; }
/// <summary>
/// 父节点名称
/// </summary>
public string ParentName { get; set; }
/// <summary>
/// 矢量图标
/// </summary>
public string Vector { get; set; }
/// <summary>
/// 排序号
/// </summary>
public int SortNo { get; set; }
/// <summary>
/// 父节点流水号
/// </summary>
public string ParentId { get; set; }
}
}

View File

@@ -0,0 +1,77 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 模块元素表(需要权限控制的按钮)
/// </summary>
public partial class ModuleElement : Entity
{
public ModuleElement()
{
this.DomId= string.Empty;
this.Name= string.Empty;
this.Type= string.Empty;
this.Attr= string.Empty;
this.Script= string.Empty;
this.Icon= string.Empty;
this.Class= string.Empty;
this.Remark= string.Empty;
this.Sort= 0;
this.ModuleId= string.Empty;
}
/// <summary>
/// DOM ID
/// </summary>
public string DomId { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 类型
/// </summary>
public string Type { get; set; }
/// <summary>
/// 元素附加属性
/// </summary>
public string Attr { get; set; }
/// <summary>
/// 元素调用脚本
/// </summary>
public string Script { get; set; }
/// <summary>
/// 元素图标
/// </summary>
public string Icon { get; set; }
/// <summary>
/// 元素样式
/// </summary>
public string Class { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 排序字段
/// </summary>
public int Sort { get; set; }
/// <summary>
/// 功能模块Id
/// </summary>
public string ModuleId { get; set; }
}
}

View File

@@ -0,0 +1,100 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 组织表
/// </summary>
public partial class Org : Entity
{
public Org()
{
this.CascadeId= string.Empty;
this.Name= string.Empty;
this.HotKey= string.Empty;
this.ParentName= string.Empty;
this.IconName= string.Empty;
this.Status= 0;
this.Type= 0;
this.BizCode= string.Empty;
this.CustomCode= string.Empty;
this.CreateTime= DateTime.Now;
this.CreateId= 0;
this.SortNo= 0;
this.ParentId= string.Empty;
}
/// <summary>
/// 节点语义ID
/// </summary>
public string CascadeId { get; set; }
/// <summary>
/// 组织名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 热键
/// </summary>
public string HotKey { get; set; }
/// <summary>
/// 父节点名称
/// </summary>
public string ParentName { get; set; }
/// <summary>
/// 是否叶子节点
/// </summary>
public bool IsLeaf { get; set; }
/// <summary>
/// 是否自动展开
/// </summary>
public bool IsAutoExpand { get; set; }
/// <summary>
/// 节点图标文件名称
/// </summary>
public string IconName { get; set; }
/// <summary>
/// 当前状态
/// </summary>
public int Status { get; set; }
/// <summary>
/// 组织类型
/// </summary>
public int Type { get; set; }
/// <summary>
/// 业务对照码
/// </summary>
public string BizCode { get; set; }
/// <summary>
/// 自定义扩展码
/// </summary>
public string CustomCode { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public System.DateTime CreateTime { get; set; }
/// <summary>
/// 创建人ID
/// </summary>
public int CreateId { get; set; }
/// <summary>
/// 排序号
/// </summary>
public int SortNo { get; set; }
/// <summary>
/// 父节点流水号
/// </summary>
public string ParentId { get; set; }
}
}

View File

@@ -0,0 +1,62 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 多对多关系集中映射
/// </summary>
public partial class Relevance : Entity
{
public Relevance()
{
this.Description= string.Empty;
this.Key= string.Empty;
this.Status= 0;
this.OperateTime= DateTime.Now;
this.OperatorId= string.Empty;
this.FirstId= string.Empty;
this.SecondId= string.Empty;
}
/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 映射标识
/// </summary>
public string Key { get; set; }
/// <summary>
/// 状态
/// </summary>
public int Status { get; set; }
/// <summary>
/// 授权时间
/// </summary>
public System.DateTime OperateTime { get; set; }
/// <summary>
/// 授权人
/// </summary>
public string OperatorId { get; set; }
/// <summary>
/// 第一个表主键ID
/// </summary>
public string FirstId { get; set; }
/// <summary>
/// 第二个表主键ID
/// </summary>
public string SecondId { get; set; }
}
}

View File

@@ -0,0 +1,72 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 资源表
/// </summary>
public partial class Resource : Entity
{
public Resource()
{
this.CascadeId= string.Empty;
this.Key= string.Empty;
this.Name= string.Empty;
this.Status= 0;
this.SortNo= 0;
this.Description= string.Empty;
this.ParentId= string.Empty;
this.CategoryId= string.Empty;
this.AppId= string.Empty;
}
/// <summary>
/// 节点语义ID
/// </summary>
public string CascadeId { get; set; }
/// <summary>
/// 资源英文唯一标识
/// </summary>
public string Key { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 当前状态
/// </summary>
public int Status { get; set; }
/// <summary>
/// 排序号
/// </summary>
public int SortNo { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 父节点流水号
/// </summary>
public string ParentId { get; set; }
/// <summary>
/// 资源分类
/// </summary>
public string CategoryId { get; set; }
/// <summary>
/// 资源所属应用
/// </summary>
public string AppId { get; set; }
}
}

View File

@@ -0,0 +1,52 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 角色表
/// </summary>
public partial class Role : Entity
{
public Role()
{
this.Name= string.Empty;
this.Status= 0;
this.Type= 0;
this.CreateTime= DateTime.Now;
this.CreateId= string.Empty;
}
/// <summary>
/// 角色名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 当前状态
/// </summary>
public int Status { get; set; }
/// <summary>
/// 角色类型
/// </summary>
public int Type { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public System.DateTime CreateTime { get; set; }
/// <summary>
/// 创建人ID
/// </summary>
public string CreateId { get; set; }
}
}

View File

@@ -0,0 +1,67 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 出入库信息表
/// </summary>
public partial class Stock : Entity
{
public Stock()
{
this.Name= string.Empty;
this.Number= 0;
this.Price= 0;
this.Status= 0;
this.Viewable= string.Empty;
this.User= string.Empty;
this.Time= DateTime.Now;
this.OrgId= string.Empty;
}
/// <summary>
/// 产品名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 产品数量
/// </summary>
public int Number { get; set; }
/// <summary>
/// 产品单价
/// </summary>
public decimal Price { get; set; }
/// <summary>
/// 出库/入库
/// </summary>
public int Status { get; set; }
/// <summary>
/// 可见范围
/// </summary>
public string Viewable { get; set; }
/// <summary>
/// 操作人
/// </summary>
public string User { get; set; }
/// <summary>
/// 操作时间
/// </summary>
public System.DateTime Time { get; set; }
/// <summary>
/// 组织ID
/// </summary>
public string OrgId { get; set; }
}
}

View File

@@ -0,0 +1,72 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 用户基本信息表
/// </summary>
public partial class User : Entity
{
public User()
{
this.Account= string.Empty;
this.Password= string.Empty;
this.Name= string.Empty;
this.Sex= 0;
this.Status= 0;
this.Type= 0;
this.BizCode= string.Empty;
this.CreateTime= DateTime.Now;
this.CrateId= string.Empty;
}
/// <summary>
/// 用户登录帐号
/// </summary>
public string Account { get; set; }
/// <summary>
/// 密码
/// </summary>
public string Password { get; set; }
/// <summary>
/// 用户姓名
/// </summary>
public string Name { get; set; }
/// <summary>
/// 性别
/// </summary>
public int Sex { get; set; }
/// <summary>
/// 用户状态
/// </summary>
public int Status { get; set; }
/// <summary>
/// 用户类型
/// </summary>
public int Type { get; set; }
/// <summary>
/// 业务对照码
/// </summary>
public string BizCode { get; set; }
/// <summary>
/// 经办时间
/// </summary>
public System.DateTime CreateTime { get; set; }
/// <summary>
/// 创建人
/// </summary>
public string CrateId { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System;
namespace OpenAuth.Domain
{
/// <summary>
/// 用户ID
/// </summary>
public static class UserExt
{
public static void CheckPassword(this User user, string password)
{
if (user.Password != password)
{
throw new Exception("密码错误");
}
}
}
}

View File

@@ -0,0 +1,113 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 表单模板表
/// </summary>
public partial class WFFrmMain : Entity
{
public WFFrmMain()
{
this.FrmCode= string.Empty;
this.FrmName= string.Empty;
this.FrmType= string.Empty;
this.FrmTable= string.Empty;
this.FrmTableId= string.Empty;
this.FrmContent= string.Empty;
this.FrmDbId= string.Empty;
this.Description= string.Empty;
this.CreateDate= DateTime.Now;
this.CreateUserId= string.Empty;
this.CreateUserName= string.Empty;
this.ModifyDate= DateTime.Now;
this.ModifyUserId= string.Empty;
this.ModifyUserName= string.Empty;
}
/// <summary>
/// 表单编号
/// </summary>
public string FrmCode { get; set; }
/// <summary>
/// 表单名称
/// </summary>
public string FrmName { get; set; }
/// <summary>
/// 表单分类
/// </summary>
public string FrmType { get; set; }
/// <summary>
/// 数据表
/// </summary>
public string FrmTable { get; set; }
/// <summary>
/// 关联表的主键
/// </summary>
public string FrmTableId { get; set; }
/// <summary>
/// 是否需要建表0不建表,1建表
/// </summary>
public int? IsSystemTable { get; set; }
/// <summary>
/// 表单内容
/// </summary>
public string FrmContent { get; set; }
/// <summary>
/// 排序码
/// </summary>
public int? SortCode { get; set; }
/// <summary>
/// 删除标记
/// </summary>
public int? DeleteMark { get; set; }
/// <summary>
/// 数据库Id
/// </summary>
public string FrmDbId { get; set; }
/// <summary>
/// 有效
/// </summary>
public int? EnabledMark { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Description { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public System.DateTime? CreateDate { get; set; }
/// <summary>
/// 创建用户主键
/// </summary>
public string CreateUserId { get; set; }
/// <summary>
/// 创建用户
/// </summary>
public string CreateUserName { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public System.DateTime? ModifyDate { get; set; }
/// <summary>
/// 修改用户主键
/// </summary>
public string ModifyUserId { get; set; }
/// <summary>
/// 修改用户
/// </summary>
public string ModifyUserName { get; set; }
}
}

View File

@@ -0,0 +1,125 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 工作流流程实例表
/// </summary>
public partial class WFProcessInstance : Entity
{
public WFProcessInstance()
{
this.Code= string.Empty;
this.CustomName= string.Empty;
this.ActivityId= string.Empty;
this.ActivityName= string.Empty;
this.ProcessSchemeId= string.Empty;
this.PreviousId= string.Empty;
this.SchemeType= string.Empty;
this.CreateDate= DateTime.Now;
this.CreateUserId= string.Empty;
this.CreateUserName= string.Empty;
this.Description= string.Empty;
this.MakerList= string.Empty;
}
/// <summary>
/// 实例编号
/// </summary>
public string Code { get; set; }
/// <summary>
/// 自定义名称
/// </summary>
public string CustomName { get; set; }
/// <summary>
/// 当前节点ID
/// </summary>
public string ActivityId { get; set; }
/// <summary>
/// 当前节点类型0会签节点
/// </summary>
public int? ActivityType { get; set; }
/// <summary>
/// 当前节点名称
/// </summary>
public string ActivityName { get; set; }
/// <summary>
/// 流程实例模板Id
/// </summary>
public string ProcessSchemeId { get; set; }
/// <summary>
/// 前一个ID
/// </summary>
public string PreviousId { get; set; }
/// <summary>
/// 表单类型
/// </summary>
public int? FrmType { get; set; }
/// <summary>
/// 流程类型
/// </summary>
public string SchemeType { get; set; }
/// <summary>
/// 有效标志
/// </summary>
public int? EnabledMark { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public System.DateTime? CreateDate { get; set; }
/// <summary>
/// 创建用户主键
/// </summary>
public string CreateUserId { get; set; }
/// <summary>
/// 创建用户
/// </summary>
public string CreateUserName { get; set; }
/// <summary>
/// 等级
/// </summary>
public int? WfLevel { get; set; }
/// <summary>
/// 实例备注
/// </summary>
public string Description { get; set; }
/// <summary>
/// 是否完成
/// </summary>
public int? IsFinish { get; set; }
/// <summary>
/// 执行人
/// </summary>
public string MakerList { get; set; }
#region
/// <summary>
/// 新增调用
/// </summary>
public void Create()
{
this.CreateDate = DateTime.Now;
}
/// <summary>
/// 编辑调用
/// </summary>
/// <param name="keyValue"></param>
public void Modify(string keyValue)
{
this.Id = keyValue;
}
#endregion
}
}

View File

@@ -0,0 +1,52 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 工作流实例操作记录
/// </summary>
public partial class WFProcessOperationHistory : Entity
{
public WFProcessOperationHistory()
{
this.ProcessId= string.Empty;
this.Content= string.Empty;
this.CreateDate= DateTime.Now;
this.CreateUserId= string.Empty;
this.CreateUserName= string.Empty;
}
/// <summary>
/// 实例进程Id
/// </summary>
public string ProcessId { get; set; }
/// <summary>
/// 操作内容
/// </summary>
public string Content { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public System.DateTime? CreateDate { get; set; }
/// <summary>
/// 创建用户主键
/// </summary>
public string CreateUserId { get; set; }
/// <summary>
/// 创建用户
/// </summary>
public string CreateUserName { get; set; }
}
}

View File

@@ -0,0 +1,64 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 工作流实例模板对应表
/// </summary>
public partial class WFProcessScheme : Entity
{
public WFProcessScheme()
{
this.SchemeContent= string.Empty;
this.SchemeInfoId= string.Empty;
this.SchemeVersion= string.Empty;
}
/// <summary>
/// 流程模板内容
/// </summary>
public string SchemeContent { get; set; }
/// <summary>
/// 流程模板ID
/// </summary>
public string SchemeInfoId { get; set; }
/// <summary>
/// 流程内容版本
/// </summary>
public string SchemeVersion { get; set; }
/// <summary>
/// 类型(0正常,3草稿)
/// </summary>
public int? ProcessType { get; set; }
#region
/// <summary>
/// 新增调用
/// </summary>
public void Create()
{
this.Id = Guid.NewGuid().ToString();
}
/// <summary>
/// 编辑调用
/// </summary>
/// <param name="keyValue"></param>
public void Modify(string keyValue)
{
this.Id = keyValue;
}
#endregion
}
}

View File

@@ -0,0 +1,83 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 工作流实例流转历史记录
/// </summary>
public partial class WFProcessTransitionHistory : Entity
{
public WFProcessTransitionHistory()
{
this.ProcessId= string.Empty;
this.FromNodeId= string.Empty;
this.FromNodeName= string.Empty;
this.ToNodeId= string.Empty;
this.ToNodeName= string.Empty;
this.CreateDate= DateTime.Now;
this.CreateUserId= string.Empty;
this.CreateUserName= string.Empty;
}
/// <summary>
/// 实例进程Id
/// </summary>
public string ProcessId { get; set; }
/// <summary>
/// 开始节点Id
/// </summary>
public string FromNodeId { get; set; }
/// <summary>
/// 开始节点类型
/// </summary>
public int? FromNodeType { get; set; }
/// <summary>
/// 开始节点名称
/// </summary>
public string FromNodeName { get; set; }
/// <summary>
/// 结束节点Id
/// </summary>
public string ToNodeId { get; set; }
/// <summary>
/// 结束节点类型
/// </summary>
public int? ToNodeType { get; set; }
/// <summary>
/// 结束节点名称
/// </summary>
public string ToNodeName { get; set; }
/// <summary>
/// 转化状态
/// </summary>
public int? TransitionSate { get; set; }
/// <summary>
/// 是否结束
/// </summary>
public int? IsFinish { get; set; }
/// <summary>
/// 转化时间
/// </summary>
public System.DateTime? CreateDate { get; set; }
/// <summary>
/// 操作人Id
/// </summary>
public string CreateUserId { get; set; }
/// <summary>
/// 操作人名称
/// </summary>
public string CreateUserName { get; set; }
}
}

View File

@@ -0,0 +1,57 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 工作流模板内容表
/// </summary>
public partial class WFSchemeContent : Entity
{
public WFSchemeContent()
{
this.SchemeInfoId= string.Empty;
this.SchemeVersion= string.Empty;
this.SchemeContent= string.Empty;
this.CreateDate= DateTime.Now;
this.CreateUserId= string.Empty;
this.CreateUserName= string.Empty;
}
/// <summary>
/// 工作流模板信息主键Id
/// </summary>
public string SchemeInfoId { get; set; }
/// <summary>
/// 流程内容版本
/// </summary>
public string SchemeVersion { get; set; }
/// <summary>
/// 流程内容
/// </summary>
public string SchemeContent { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public System.DateTime? CreateDate { get; set; }
/// <summary>
/// 创建用户主键
/// </summary>
public string CreateUserId { get; set; }
/// <summary>
/// 创建用户
/// </summary>
public string CreateUserName { get; set; }
}
}

View File

@@ -0,0 +1,107 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenAuth.Domain
{
/// <summary>
/// 工作流模板信息表
/// </summary>
public partial class WFSchemeInfo : Entity
{
public WFSchemeInfo()
{
this.SchemeCode= string.Empty;
this.SchemeName= string.Empty;
this.SchemeType= string.Empty;
this.SchemeVersion= string.Empty;
this.SchemeCanUser= string.Empty;
this.Description= string.Empty;
this.CreateDate= DateTime.Now;
this.CreateUserId= string.Empty;
this.CreateUserName= string.Empty;
this.ModifyDate= DateTime.Now;
this.ModifyUserId= string.Empty;
this.ModifyUserName= string.Empty;
}
/// <summary>
/// 流程编号
/// </summary>
public string SchemeCode { get; set; }
/// <summary>
/// 流程名称
/// </summary>
public string SchemeName { get; set; }
/// <summary>
/// 流程分类
/// </summary>
public string SchemeType { get; set; }
/// <summary>
/// 流程内容版本
/// </summary>
public string SchemeVersion { get; set; }
/// <summary>
/// 流程模板使用者
/// </summary>
public string SchemeCanUser { get; set; }
/// <summary>
/// 表单类型
/// </summary>
public int? FrmType { get; set; }
/// <summary>
/// 模板权限类型0所有人,1指定成员
/// </summary>
public int? AuthorizeType { get; set; }
/// <summary>
/// 排序码
/// </summary>
public int? SortCode { get; set; }
/// <summary>
/// 删除标记
/// </summary>
public int? DeleteMark { get; set; }
/// <summary>
/// 有效
/// </summary>
public int? EnabledMark { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Description { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public System.DateTime? CreateDate { get; set; }
/// <summary>
/// 创建用户主键
/// </summary>
public string CreateUserId { get; set; }
/// <summary>
/// 创建用户
/// </summary>
public string CreateUserName { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public System.DateTime? ModifyDate { get; set; }
/// <summary>
/// 修改用户主键
/// </summary>
public string ModifyUserId { get; set; }
/// <summary>
/// 修改用户
/// </summary>
public string ModifyUserName { get; set; }
}
}

View File

@@ -0,0 +1,62 @@
// ***********************************************************************
// Assembly : OpenAuth.Domain
// Author : yubaolee
// Created : 10-25-2015
//
// Last Modified By : yubaolee
// Last Modified On : 10-25-2015
// ***********************************************************************
// <copyright file="IRepository.cs" company="www.cnblogs.com/yubaolee">
// Copyright (c) www.cnblogs.com/yubaolee. All rights reserved.
// </copyright>
// <summary>仓储接口</summary>
// ***********************************************************************
using System;
using System.Linq;
using System.Linq.Expressions;
namespace OpenAuth.Domain.Interface
{
public interface IRepository<T> where T : class
{
T FindSingle(Expression<Func<T, bool>> exp = null);
bool IsExist(Expression<Func<T, bool>> exp);
IQueryable<T> Find(Expression<Func<T, bool>> exp = null);
IQueryable<T> Find(int pageindex = 1, int pagesize = 10, string orderby = "",
Expression<Func<T, bool>> exp = null);
int GetCount(Expression<Func<T, bool>> exp = null);
void Add(T entity);
void BatchAdd(T[] entities);
/// <summary>
/// 更新一个实体的所有属性
/// </summary>
void Update(T entity);
void Delete(T entity);
/// <summary>
/// 按指定的ID进行批量更新
/// </summary>
void Update(Expression<Func<T, object>> identityExp, T entity);
/// <summary>
/// 实现按需要只更新部分更新
/// <para>如Update(u =>u.Id==1,u =>new User{Name="ok"});</para>
/// </summary>
/// <param name="where">更新条件</param>
/// <param name="entity">更新后的实体</param>
void Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> entity);
/// <summary>
/// 批量删除
/// </summary>
void Delete(Expression<Func<T, bool>> exp);
void Save();
}
}

View File

@@ -0,0 +1,67 @@
// ***********************************************************************
// Assembly : OpenAuth.Domain
// Author : yubaolee
// Created : 04-29-2016
//
// Last Modified By : yubaolee
// Last Modified On : 04-29-2016
// Contact : Microsoft
// File: IUnitWork.cs
// ***********************************************************************
using System;
using System.Linq;
using System.Linq.Expressions;
namespace OpenAuth.Domain.Interface
{
/// <summary>
/// 工作单元接口
/// <para> 适合在一下情况使用:</para>
/// <para>1 在同一事务中进行多表操作</para>
/// <para>2 需要多表联合查询</para>
/// <para>因为架构采用的是EF访问数据库暂时可以不用考虑采用传统Unit Work的注册机制</para>
/// </summary>
public interface IUnitWork
{
T FindSingle<T>(Expression<Func<T, bool>> exp = null) where T:class;
bool IsExist<T>(Expression<Func<T, bool>> exp) where T:class;
IQueryable<T> Find<T>(Expression<Func<T, bool>> exp = null) where T:class;
IQueryable<T> Find<T>(int pageindex = 1, int pagesize = 10, string orderby = "",
Expression<Func<T, bool>> exp = null) where T:class;
int GetCount<T>(Expression<Func<T, bool>> exp = null) where T:class;
void Add<T>(T entity) where T:Entity;
void BatchAdd<T>(T[] entities) where T:Entity;
/// <summary>
/// 更新一个实体的所有属性
/// </summary>
void Update<T>(T entity) where T:class;
void Delete<T>(T entity) where T:class;
/// <summary>
/// 按指定的ID进行批量更新
/// </summary>
void Update<T>(Expression<Func<T, object>> identityExp, T entity) where T:class;
/// <summary>
/// 实现按需要只更新部分更新
/// <para>如Update<T>(u =>u.Id==1,u =>new User{Name="ok"}) where T:class;</para>
/// </summary>
/// <param name="where">更新条件</param>
/// <param name="entity">更新后的实体</param>
void Update<T>(Expression<Func<T, bool>> where, Expression<Func<T, T>> entity) where T:class;
/// <summary>
/// 批量删除
/// </summary>
void Delete<T>(Expression<Func<T, bool>> exp) where T:class;
void Save();
}
}

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));
}
}
}

View File

@@ -1,51 +0,0 @@
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenAuth.Repository
{
public class RelevanceRepository : BaseRepository<Relevance>, IRelevanceRepository
{
public void DeleteBy(string key, params string[] firstIds)
{
Delete(u => firstIds.Contains(u.FirstId) && u.Key == key);
}
/// <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)
{
Delete(u =>u.Key == key && u.FirstId == sameVals.Key && u.SecondId == value);
}
}
}
/// <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);
BatchAdd((from sameVals in idMaps
from value in sameVals
select new Relevance
{
Key = key,
FirstId = sameVals.Key,
SecondId = value,
OperateTime = DateTime.Now
}).ToArray());
}
}
}

View File

@@ -1,40 +0,0 @@
using System;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using System.Collections.Generic;
using System.Linq;
namespace OpenAuth.Repository
{
public class ResourceRepository : BaseRepository<Resource>, IResourceRepository
{
public IEnumerable<Resource> 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<Resource> LoadInOrgs(params string[] orgId)
{
bool isZero = orgId.Length == 1 && orgId[0] == string.Empty; //判断传进来的是否为0
var result = from resource in Context.Resources.Where(u =>isZero
|| u.CascadeId != null &&orgId.Contains(u.CategoryId)) select resource;
return result;
}
public IEnumerable<Resource> LoadResources(int pageindex, int pagesize)
{
return Context.Resources.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public int GetResourceCntInOrgs(params string[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}
}
}

View File

@@ -1,57 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
namespace OpenAuth.Repository
{
public class RoleRepository :BaseRepository<Role>, IRoleRepository
{
public IEnumerable<Role> LoadRoles(int pageindex, int pagesize)
{
return Context.Roles.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public int GetRoleCntInOrgs(params string[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}
public IEnumerable<Role> 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<Role> LoadInOrgs(params string[] orgId)
{
var roles = Context.Relevances.Where(u => u.Key == "RoleOrg"
&& orgId.Contains(u.SecondId)).Select(u => u.FirstId); //机构关联的角色
var result = from role in Context.Roles.Where(u =>roles.Contains(u.Id)) select role;
return result;
}
public IEnumerable<Role> LoadForUser(string userId)
{
if (userId == string.Empty)
return Find(null);
var userRoleIds =
Context.Relevances.Where(u => u.FirstId == userId && u.Key == "UserRole")
.Select(u => u.SecondId).ToList();
return Find(u => userRoleIds.Contains(u.Id));
}
}
}

View File

@@ -1,40 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
namespace OpenAuth.Repository
{
public class StockRepository :BaseRepository<Stock>, IStockRepository
{
public IEnumerable<Stock> LoadStocks(int pageindex, int pagesize)
{
return Context.Stocks.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public IEnumerable<Stock> LoadInOrgs(params string[] orgId)
{
var result = from stock in Context.Stocks where stock.OrgId != null && orgId.Contains(stock.OrgId)
select stock;
return result;
}
public int GetStockCntInOrgs(params string[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}
public IEnumerable<Stock> 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);
}
}
}

View File

@@ -1,46 +0,0 @@
using OpenAuth.Domain.Interface;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Transactions;
using EntityFramework.Extensions;
using OpenAuth.Domain;
namespace OpenAuth.Repository
{
public class UserRepository :BaseRepository<User>, IUserRepository
{
public IEnumerable<User> LoadUsers(int pageindex, int pagesize)
{
return Context.Users.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public IEnumerable<User> LoadInOrgs(params string[] orgId)
{
var result = from user in Context.Users
where (
Context.Relevances.Where(uo => orgId.Contains(uo.SecondId) && uo.Key =="UserOrg")
.Select(u => u.FirstId)
.Distinct()
)
.Contains(user.Id)
select user;
return result;
}
public int GetUserCntInOrgs(params string[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}
public IEnumerable<User> LoadInOrgs(int pageindex, int pagesize, params string[] orgIds)
{
return LoadInOrgs(orgIds).OrderBy(u =>u.Id).Skip((pageindex -1)*pagesize).Take(pagesize);
}
}
}