完成机构与用户管理

This commit is contained in:
yubaolee
2015-11-13 21:33:53 +08:00
parent 8ab37845bc
commit 4dac594250
210 changed files with 74200 additions and 73971 deletions

View File

@@ -16,7 +16,7 @@ namespace OpenAuth.App
public void Login(string userName, string password) public void Login(string userName, string password)
{ {
var user = _repository.FindByAccount(userName); var user = _repository.FindSingle(u =>u.Account ==userName);
if (user == null) if (user == null)
{ {
throw new Exception("<22>û<EFBFBD><C3BB>ʺŲ<CABA><C5B2><EFBFBD><EFBFBD><EFBFBD>"); throw new Exception("<22>û<EFBFBD><C3BB>ʺŲ<CABA><C5B2><EFBFBD><EFBFBD><EFBFBD>");

View File

@@ -44,8 +44,10 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="LoginApp.cs" /> <Compile Include="LoginApp.cs" />
<Compile Include="UserManagerApp.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="OrgManagerApp.cs" /> <Compile Include="OrgManagerApp.cs" />
<Compile Include="ViewModel\UserView.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj"> <ProjectReference Include="..\Infrastructure\Infrastructure.csproj">
@@ -57,6 +59,7 @@
<Name>OpenAuth.Domain</Name> <Name>OpenAuth.Domain</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -15,9 +15,9 @@ namespace OpenAuth.App
_repository = repository; _repository = repository;
} }
public IEnumerable<Org> GetAll() public IList<Org> GetAll()
{ {
return _repository.LoadOrgs(); return _repository.LoadOrgs().ToList();
} }
/// <summary> /// <summary>
@@ -26,16 +26,16 @@ namespace OpenAuth.App
/// </summary> /// </summary>
/// <param name="orgId">The org unique identifier.</param> /// <param name="orgId">The org unique identifier.</param>
/// <returns>IEnumerable{Org}.</returns> /// <returns>IEnumerable{Org}.</returns>
public IEnumerable<Org> LoadDirectChildren(int orgId) public IList<Org> LoadDirectChildren(int orgId)
{ {
return _repository.Find(u => u.ParentId == orgId); return _repository.Find(u => u.ParentId == orgId).ToList();
} }
/// <summary> /// <summary>
/// 得到部门的所有子部门 /// 得到部门的所有子部门
/// <para>如果orgId为0表示取得所有部门</para> /// <para>如果orgId为0表示取得所有部门</para>
/// </summary> /// </summary>
public IEnumerable<Org> LoadAllChildren(int orgId) public IList<Org> LoadAllChildren(int orgId)
{ {
string cascadeId = "0."; string cascadeId = "0.";
if (orgId != 0) if (orgId != 0)
@@ -46,7 +46,7 @@ namespace OpenAuth.App
cascadeId = org.CascadeId; cascadeId = org.CascadeId;
} }
return _repository.Find(u => u.CascadeId.Contains(cascadeId) && u.Id != orgId); return _repository.Find(u => u.CascadeId.Contains(cascadeId) && u.Id != orgId).ToList();
} }
/// <summary> /// <summary>

View File

@@ -9,5 +9,7 @@ namespace OpenAuth.Domain.Interface
public interface IOrgRepository :IRepository<Org> public interface IOrgRepository :IRepository<Org>
{ {
IEnumerable<Org> LoadOrgs(); IEnumerable<Org> LoadOrgs();
IEnumerable<Org> LoadByUser(int userId);
} }
} }

View File

@@ -5,10 +5,21 @@ namespace OpenAuth.Domain.Interface
{ {
public interface IUserRepository :IRepository<User> public interface IUserRepository :IRepository<User>
{ {
User FindByAccount(string account);
User FindById(string id);
IEnumerable<User> LoadUsers(); IEnumerable<User> LoadUsers();
IEnumerable<User> LoadInOrgs(params int[] orgId);
int GetUserCount(params int[] orgIds);
IEnumerable<User> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds);
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>
/// </summary>
void AddWithOrg(User user, params int[] orgIds);
/// <summary>
/// ɾ<><C9BE><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>Ϣ
/// </summary>
void Delete(int id);
} }
} }

View File

@@ -12,13 +12,13 @@
// <summary>IOC<4F><43>ʼ<EFBFBD><CABC></summary> // <summary>IOC<4F><43>ʼ<EFBFBD><CABC></summary>
// *********************************************************************** // ***********************************************************************
using System.Reflection;
using System.Web.Mvc;
using Autofac; using Autofac;
using Autofac.Integration.Mvc; using Autofac.Integration.Mvc;
using OpenAuth.App; using OpenAuth.App;
using OpenAuth.Domain.Interface; using OpenAuth.Domain.Interface;
using OpenAuth.Repository; using OpenAuth.Repository;
using System.Reflection;
using System.Web.Mvc;
namespace OpenAuth.Mvc namespace OpenAuth.Mvc
{ {
@@ -32,9 +32,11 @@ namespace OpenAuth.Mvc
builder.RegisterType<OrgRepository>().As<IOrgRepository>(); builder.RegisterType<OrgRepository>().As<IOrgRepository>();
builder.RegisterType<LoginApp>(); builder.RegisterType<LoginApp>();
builder.RegisterType<OrgManagerApp>(); builder.RegisterType<OrgManagerApp>();
builder.RegisterType<UserManagerApp>();
// Register your MVC controllers. // Register your MVC controllers.
builder.RegisterControllers(typeof (MvcApplication).Assembly); builder.RegisterControllers(typeof(MvcApplication).Assembly);
// OPTIONAL: Register model binders that require DI. // OPTIONAL: Register model binders that require DI.
builder.RegisterModelBinders(Assembly.GetExecutingAssembly()); builder.RegisterModelBinders(Assembly.GetExecutingAssembly());

View File

@@ -668,8 +668,8 @@ span.tmpzTreeMove_arrow,.ztree .tree_add, .ztree .tree_del,
.ztree li span.button.chk{margin:0 3px 0 0; width:18px; height:20px; cursor:auto;} .ztree li span.button.chk{margin:0 3px 0 0; width:18px; height:20px; cursor:auto;}
.ztree li span.button.chk.checkbox_false_full{background-position:0 -2px;} .ztree li span.button.chk.checkbox_false_full{background-position:0 -2px;}
.ztree li span.button.chk.checkbox_false_full_focus{background-position:0 -24px;} .ztree li span.button.chk.checkbox_false_full_focus{background-position:0 -24px;}
.ztree li span.button.chk.checkbox_false_part{background-position:-19px -46px;} .ztree li span.button.chk.checkbox_false_part{/* background-position:-19px -46px; */background-position:0 -2px;}
.ztree li span.button.chk.checkbox_false_part_focus{background-position:-19px -24px;} .ztree li span.button.chk.checkbox_false_part_focus{/*background-position:-19px -24px;*/background-position:0 -2px;}
.ztree li span.button.chk.checkbox_false_disable{background-position:0 -68px;} .ztree li span.button.chk.checkbox_false_disable{background-position:0 -68px;}
.ztree li span.button.chk.checkbox_true_full{background-position:-19px -2px;} .ztree li span.button.chk.checkbox_true_full{background-position:-19px -2px;}
.ztree li span.button.chk.checkbox_true_full_focus{background-position:-19px -24px;} .ztree li span.button.chk.checkbox_true_full_focus{background-position:-19px -24px;}

View File

@@ -1,21 +1,9 @@
using System; using System.Web.Mvc;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Newtonsoft.Json;
using OpenAuth.App;
namespace OpenAuth.Mvc.Controllers namespace OpenAuth.Mvc.Controllers
{ {
public class HomeController : BaseController public class HomeController : BaseController
{ {
private LoginApp _loginApp;
public HomeController()
{
_loginApp = (LoginApp)DependencyResolver.Current.GetService(typeof(LoginApp));
}
public ActionResult Index() public ActionResult Index()
{ {
return View(); return View();
@@ -30,11 +18,5 @@ namespace OpenAuth.Mvc.Controllers
{ {
return View(); return View();
} }
public string LoadUsers()
{
return JsonConvert.SerializeObject(_loginApp.LoadUsers());
}
} }
} }

View File

@@ -33,6 +33,11 @@ namespace OpenAuth.Mvc.Controllers
return View(); return View();
} }
public ActionResult LookupMulti()
{
return View();
}
public ActionResult AddOrg() public ActionResult AddOrg()
{ {
return View(); return View();
@@ -71,7 +76,16 @@ namespace OpenAuth.Mvc.Controllers
public string LoadOrg() public string LoadOrg()
{ {
return JsonHelper.Instance.Serialize(_orgApp.GetAll()); var orgs = _orgApp.GetAll();
//添加根节点
orgs.Add(new Org
{
Id = 0,
ParentId = -1,
Name = "全部机构",
CascadeId = "0"
});
return JsonHelper.Instance.Serialize(orgs);
} }
public string LoadChildren(int id) public string LoadChildren(int id)

View File

@@ -1,18 +1,90 @@
using System; using Infrastructure;
using OpenAuth.App;
using OpenAuth.Domain;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using OpenAuth.App.ViewModel;
namespace OpenAuth.Mvc.Controllers namespace OpenAuth.Mvc.Controllers
{ {
public class UserManagerController : BaseController public class UserManagerController : BaseController
{ {
private UserManagerApp _app;
public UserManagerController()
{
_app = (UserManagerApp)DependencyResolver.Current.GetService(typeof(UserManagerApp));
}
// //
// GET: /UserManager/ // GET: /UserManager/
public ActionResult Index() public ActionResult Index()
{ {
return View(); return View();
} }
}
public ActionResult Add()
{
return View();
}
//添加组织提交
[HttpPost]
public string Add(UserView org)
{
try
{
int[] orgIds = org.OrganizationIds.Split(',').Select(id => int.Parse(id)).ToArray();
_app.Add(org, orgIds);
}
catch (Exception ex)
{
BjuiResponse.statusCode = "300";
BjuiResponse.message = ex.Message;
}
return JsonHelper.Instance.Serialize(BjuiResponse);
}
public string Edit(string json)
{
try
{
var org = JsonHelper.Instance.Deserialize<User>(json);
}
catch (Exception ex)
{
BjuiResponse.statusCode = "300";
BjuiResponse.message = ex.Message;
}
return JsonHelper.Instance.Serialize(BjuiResponse);
}
/// <summary>
/// 加载组织下面的所有用户
/// </summary>
public string Load(int orgId)
{
return JsonHelper.Instance.Serialize(_app.Load(orgId));
}
public string Delete(string Id)
{
try
{
foreach (var obj in Id.Split(','))
{
_app.Delete(int.Parse(obj));
}
}
catch (Exception e)
{
BjuiResponse.statusCode = "300";
BjuiResponse.message = e.Message;
}
return JsonHelper.Instance.Serialize(BjuiResponse);
}
}
} }

View File

@@ -123,7 +123,6 @@
<Compile Include="AutofacExt.cs" /> <Compile Include="AutofacExt.cs" />
<Compile Include="Controllers\BaseController.cs" /> <Compile Include="Controllers\BaseController.cs" />
<Compile Include="Controllers\HomeController.cs" /> <Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\ModuleManagerController.cs" />
<Compile Include="Controllers\OrgManagerController.cs" /> <Compile Include="Controllers\OrgManagerController.cs" />
<Compile Include="Controllers\UserManagerController.cs" /> <Compile Include="Controllers\UserManagerController.cs" />
<Compile Include="Global.asax.cs"> <Compile Include="Global.asax.cs">
@@ -612,10 +611,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Views\OrgManager\AddOrg.cshtml" /> <None Include="Views\OrgManager\AddOrg.cshtml" />
<None Include="Views\OrgManager\LookupParent.cshtml" /> <Content Include="Views\OrgManager\LookupParent.cshtml" />
<Content Include="Views\UserManager\Index.cshtml" /> <Content Include="Views\UserManager\Index.cshtml" />
<Content Include="Views\UserManager\AddOrg.cshtml" /> <Content Include="Views\UserManager\Add.cshtml" />
<Content Include="Views\OrgManager\LookupOrg.cshtml" />
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

View File

@@ -24,9 +24,9 @@
<td> <td>
<input id="ParentId" name="ParentId" type="hidden"> <input id="ParentId" name="ParentId" type="hidden">
<label for="ParentName" class="control-label x90">上级机构:</label> <label for="ParentName" class="control-label x90">上级机构:</label>
<input type="text" name="ParentName" id="ParentName" <input type="text" name="ParentName" id="ParentName" data-toggle="selectztree" size="20" data-tree="#j_select_tree1">
value="" data-toggle="lookup" data-url="/OrgManager/LookupParent"> <ul id="j_select_tree1" class="ztree hide" data-toggle="ztree"></ul>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -50,3 +50,66 @@
<li><button type="submit" class="btn-green">保存</button></li> <li><button type="submit" class="btn-green">保存</button></li>
</ul> </ul>
</div> </div>
<script type="text/javascript">
$(document).ready(function () {
Init();
});
function Init() {
var setting = {
view: {
selectedMulti: false
},
check: {
enable: true,
chkStyle: "radio",
radioType: "all"
},
data: {
key: {
name: 'Name',
title: 'Name'
},
simpleData: {
enable: true,
idKey: 'Id',
pIdKey: 'ParentId',
rootPId: 'null'
}
},
callback: {
onClick: zTreeOnClick,
onCheck: zTreeCheck
}
};
$.getJSON('OrgManager/LoadOrg', function (json) {
var zTreeObj = $.fn.zTree.init($('#j_select_tree1'), setting, json);
zTreeObj.expandAll(true);
});
}
function zTreeCheck(e, treeId, treeNode) {
var zTree = $.fn.zTree.getZTreeObj(treeId),
nodes = zTree.getCheckedNodes(true);
var ids = '', names = '';
for (var i = 0; i < nodes.length; i++) {
ids += ',' + nodes[i].Id;
names += ',' + nodes[i].Name;
}
if (ids.length > 0) { //去掉第一个逗号
ids = ids.substr(1);
names = names.substr(1);
}
var $from = $('#' + treeId).data('fromObj');
if ($from && $from.length) $from.val(names);
$('#ParentId').val(ids);
}
function zTreeOnClick(event, treeId, treeNode) {
var zTree = $.fn.zTree.getZTreeObj(treeId);
zTree.checkNode(treeNode, !treeNode.checked, true, true);
event.preventDefault();
}
</script>

View File

@@ -1,11 +1,17 @@
<div class="bjui-pageContent"> @{
string _prefix = "org";
var _treeId = _prefix + "Tree";
var _gridId = _prefix + "Grid";
var _treeDetail = _prefix + "Detail";
}
<div class="bjui-pageContent">
<div class="clearfix"> <div class="clearfix">
<div style="float: left; width: 220px; overflow: auto;" class="table table-bordered"> <div style="float: left; width: 220px; overflow: auto;" class="table table-bordered">
<ul id="orgTree" class="ztree"></ul> <ul id="@_treeId" class="ztree"></ul>
</div> </div>
<div id="ztree-detail" style="margin-left: 225px; width: auto;height: auto"> <div id="@_treeDetail" style="margin-left: 225px; width: auto;height: auto">
<table id="mainGrid" data-width="100%" data-height="100%" class="table table-bordered"></table> <table id="@_gridId" data-width="100%" data-height="100%" class="table table-bordered"></table>
</div> </div>
</div> </div>
</div> </div>
@@ -16,11 +22,11 @@
Init(0); Init(0);
}); });
//加载数据到datagrid //加载数据到datagrid
function loadDataGrid(data) { function LoadOrg(data) {
//b-jui的datagrid需要重新处理HTML //b-jui的datagrid需要重新处理HTML
$('#ztree-detail').empty() $('#@_treeDetail').empty()
.append('<table id="mainGrid" data-width="100%" data-height="100%" class="table table-bordered"></table>'); .append('<table id="@_gridId" data-width="100%" data-height="100%" class="table table-bordered"></table>');
$('#mainGrid').datagrid({ $('#@_gridId').datagrid({
gridTitle: '机构列表显示', gridTitle: '机构列表显示',
showToolbar: true, showToolbar: true,
toolbarItem: 'refresh, |, del,edit', toolbarItem: 'refresh, |, del,edit',
@@ -100,7 +106,7 @@
$.getJSON('OrgManager/LoadChildren', { $.getJSON('OrgManager/LoadChildren', {
id: treeNode.Id id: treeNode.Id
}, function (json) { }, function (json) {
loadDataGrid(json); LoadOrg(json);
}); });
} }
@@ -126,13 +132,13 @@
} }
}; };
$.getJSON('OrgManager/LoadOrg', function (json) { $.getJSON('OrgManager/LoadOrg', function (json) {
var zTreeObj = $.fn.zTree.init($('#orgTree'), setting, json); var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
zTreeObj.expandAll(true); zTreeObj.expandAll(true);
$.getJSON('OrgManager/LoadChildren', { $.getJSON('OrgManager/LoadChildren', {
id: selectedId id: selectedId
}, function (data) { }, function (data) {
loadDataGrid(data); LoadOrg(data);
}); });
//TODO设置ztree选中不过没看到效果.. //TODO设置ztree选中不过没看到效果..
@@ -145,7 +151,7 @@
//获取勾选的值 //获取勾选的值
//column:为从0开始的列标识 //column:为从0开始的列标识
function getSelected(column) { function getSelected(column) {
var selected = $('#mainGrid').data('selectedTrs'); var selected = $('#@_gridId').data('selectedTrs');
if (selected == null || selected.length == 0) { if (selected == null || selected.length == 0) {
$(this).alertmsg('warn', '至少选择一个对象', { $(this).alertmsg('warn', '至少选择一个对象', {
displayMode: 'slide', displayMode: 'slide',

View File

@@ -15,7 +15,7 @@
<li> <li>
<a href="javascript:;" id="btnSelected" data-toggle="lookupback" <a href="javascript:;" id="btnSelected" data-toggle="lookupback"
data-args="{nationid:'A001', nation:'CN'}" data-args=""
class="btn btn-blue" title="选择本项" data-icon="check">选择</a> class="btn btn-blue" title="选择本项" data-icon="check">选择</a>
</li> </li>

View File

@@ -1,77 +1,91 @@
<div class="bjui-pageContent"> @{
string _prefix = "user";
var _treeId = _prefix + "Tree";
var _gridId = _prefix + "Grid";
var _treeDetail = _prefix + "Detail";
}
<div class="bjui-pageContent">
<div class="clearfix"> <div class="clearfix">
<div style="float: left; width: 220px; overflow: auto;" class="table table-bordered"> <div style="float: left; width: 220px; overflow: auto;" class="table table-bordered">
<ul id="orgTree" class="ztree"></ul> <ul id="@_treeId" class="ztree"></ul>
</div> </div>
<div id="ztree-detail" style="margin-left: 225px; width: auto;height: auto"> <div id="@_treeDetail" style="margin-left: 225px; width: auto;height: auto">
<table id="mainGrid" data-width="100%" data-height="100%" class="table table-bordered"></table> <table id="@_gridId" data-width="100%" data-height="100%" class="table table-bordered"></table>
</div> </div>
</div> </div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var gridid = '#@_gridId';
var selectedId = 0; var selectedId = 0;
$(document).ready(function () { $(document).ready(function () {
Init(0); initZtree();
loadDataGrid();
}); });
//加载数据到datagrid //加载数据到datagrid
function loadDataGrid(data) { function loadDataGrid() {
$.getJSON('UserManager/Load', {
orgId: selectedId
}, function (data) {
initGrid(data);
});
}
function initGrid(data) {
//b-jui的datagrid需要重新处理HTML //b-jui的datagrid需要重新处理HTML
$('#ztree-detail').empty() $('#@_treeDetail').empty()
.append('<table id="mainGrid" data-width="100%" data-height="100%" class="table table-bordered"></table>'); .append('<table id="@_gridId" data-width="100%" data-height="100%" class="table table-bordered"></table>');
$('#mainGrid').datagrid({ $(gridid).datagrid({
gridTitle: '机构列表显示', gridTitle: '用户列表',
showToolbar: true, showToolbar: true,
toolbarItem: 'refresh, |, del,edit', toolbarItem: 'refresh, |, del,edit',
toolbarCustom: '<a href="/OrgManager/AddOrg" class="btn btn-green" data-icon ="plus" ' + toolbarCustom: '<a href="/UserManager/Add" class="btn btn-green" data-icon ="plus" ' +
'data-toggle="dialog" data-id="dialog-mask" data-mask="true">添加</a>' , 'data-toggle="dialog" data-id="dialog-mask" data-mask="true">添加</a>' ,
columns: [ columns: [
{ {
name: 'Id', name: 'Id',
label: 'Id', label: 'Id',
attrs: { readonly: 'readonly' }, attrs: { readonly: 'readonly' },
hide: true hide: true
}, },
{ {
name: 'ParentId', name: 'Account',
label: '上级机构ID', label: '用户账号',
attrs: { readonly: 'readonly'}, attrs: { readonly: 'readonly'}
hide: true },
}, {
{ name: 'Name',
name: 'CascadeId', label: '姓名/昵称'
label: '唯一标识', },
attrs: { readonly: 'readonly'} {
}, name: 'Organizations',
{ label: '所属机构'
name: 'Name', },
label: '机构名称' {
}, name: 'Status',
{ label: '状态',
name: 'ParentName', type: 'select',
label: '上级机构', align: 'center',
edit: false, items:[{'0':'正常'}, {'1':'禁用'}]
attrs: { readonly: 'readonly' } },
}, {
{ name: 'Sex',
name: 'Status', label: '性别',
label: '状态', type: 'select',
type: 'select', align: 'center',
align: 'center', items: [{ '0': '男' }, { '1': '女' }]
items:[{'0':'正常'}, {'1':'禁用'}] },
}, {
{ name: 'CreateTime',
name: 'CreateTime', label: '登记日期',
label: '登记日期', type: 'date',
type: 'date', pattern: 'yyyy-MM-dd HH:mm:ss'
pattern: 'yyyy-MM-dd HH:mm:ss' }
}
], ],
data: data, data: data,
delUrl: 'OrgManager/DelOrg', delUrl: 'UserManager/Delete',
delPK: "Id", delPK: "Id",
editUrl: 'OrgManager/EditOrg', editUrl: 'UserManager/Edit',
editMode: 'dialog', editMode: 'dialog',
fullGrid: true, fullGrid: true,
showLinenumber: true, showLinenumber: true,
@@ -81,14 +95,14 @@
showTfoot: true, showTfoot: true,
delCallback: function (delResult) { delCallback: function (delResult) {
if (delResult.statusCode == "200") if (delResult.statusCode == "200")
Init(selectedId); loadDataGrid();
else { else {
$(this).alertmsg('warn', delResult.message); $(this).alertmsg('warn', delResult.message);
} }
}, },
editCallback: function (delResult) { editCallback: function (delResult) {
if (delResult.statusCode == "200") if (delResult.statusCode == "200")
Init(selectedId); loadDataGrid();
else { else {
$(this).alertmsg('warn', delResult.message); $(this).alertmsg('warn', delResult.message);
} }
@@ -97,18 +111,12 @@
} }
function zTreeOnClick(event, treeId, treeNode) { function zTreeOnClick(event, treeId, treeNode) {
selectedId = treeNode.Id; selectedId = treeNode.Id;
$.getJSON('OrgManager/LoadChildren', { loadDataGrid();
id: treeNode.Id
}, function (json) {
loadDataGrid(json);
});
} }
function Init(selectedId) { function initZtree() {
var setting = { var setting = {
view: { view: {selectedMulti: false},
selectedMulti: false
},
data: { data: {
key: { key: {
name: 'Name', name: 'Name',
@@ -121,31 +129,18 @@
rootPId: 'null' rootPId: 'null'
} }
}, },
callback: { callback: {onClick: zTreeOnClick}
onClick: zTreeOnClick
}
}; };
$.getJSON('OrgManager/LoadOrg', function (json) { $.getJSON('OrgManager/LoadOrg', function (json) {
var zTreeObj = $.fn.zTree.init($('#orgTree'), setting, json); var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
zTreeObj.expandAll(true); zTreeObj.expandAll(true);
$.getJSON('OrgManager/LoadChildren', {
id: selectedId
}, function (data) {
loadDataGrid(data);
});
//TODO设置ztree选中不过没看到效果..
var selectedNod = zTreeObj.getNodesByParam('Id', selectedId, null);
zTreeObj.selectNode(selectedNod, false);
}); });
} }
//获取勾选的值 //获取勾选的值
//column:为从0开始的列标识 //column:为从0开始的列标识
function getSelected(column) { function getSelected(column) {
var selected = $('#mainGrid').data('selectedTrs'); var selected = $(gridid).data('selectedTrs');
if (selected == null || selected.length == 0) { if (selected == null || selected.length == 0) {
$(this).alertmsg('warn', '至少选择一个对象', { $(this).alertmsg('warn', '至少选择一个对象', {
displayMode: 'slide', displayMode: 'slide',
@@ -170,5 +165,5 @@
if (selected == null) return; if (selected == null) return;
} }
//@@ sourceURL=orgIndex.js //@@ sourceURL=userManagerIndex.js
</script> </script>

View File

@@ -45,6 +45,7 @@
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />

View File

@@ -14,5 +14,15 @@ namespace OpenAuth.Repository
{ {
return Find(); return Find();
} }
public IEnumerable<Org> LoadByUser(int userId)
{
var result = from userorg in Context.UserOrgs
join org in Context.Orgs on userorg.OrgId equals org.Id
where userorg.UserId == userId
select org;
return result;
}
} }
} }

View File

@@ -1,27 +1,70 @@
using OpenAuth.Domain.Interface; using OpenAuth.Domain.Interface;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Transactions;
using EntityFramework.Extensions;
using OpenAuth.Domain; using OpenAuth.Domain;
namespace OpenAuth.Repository namespace OpenAuth.Repository
{ {
public class UserRepository :BaseRepository<User>, IUserRepository public class UserRepository :BaseRepository<User>, IUserRepository
{ {
public User FindByAccount(string account)
{
return Context.Users.SingleOrDefault(u => u.Account == account);
}
public User FindById(string id)
{
return FindSingle(u => u.Account == id);
}
public IEnumerable<User> LoadUsers() public IEnumerable<User> LoadUsers()
{ {
return Context.Users.ToList(); return Context.Users.ToList();
} }
public IEnumerable<User> LoadInOrgs(params int[] orgId)
{
var result = from user in Context.Users
where (
Context.UserOrgs.Where(uo => orgId.Contains(uo.OrgId))
.Select(u => u.UserId)
.Distinct()
)
.Contains(user.Id)
select user;
return result;
}
public int GetUserCount(params int[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}
public IEnumerable<User> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds)
{
return LoadInOrgs(orgIds).OrderBy(u =>u.Name).Skip((pageindex -1)*pagesize).Take(pagesize);
}
public void AddWithOrg(User user, params int[] orgIds)
{
using (TransactionScope ts = new TransactionScope())
{
Add(user);
Save();
foreach (var orgId in orgIds)
{
Context.UserOrgs.Add(new UserOrg{OrgId = orgId,UserId = user.Id});
}
Save();
ts.Complete();
}
}
public void Delete(int id)
{
using (TransactionScope ts = new TransactionScope())
{
Context.UserOrgs.Where(u => u.UserId == id).Delete();
Delete(u =>u.Id == id);
ts.Complete();
}
}
} }
} }

View File

@@ -66,6 +66,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestFunction.cs" /> <Compile Include="TestFunction.cs" />
<Compile Include="TestUserApp.cs" />
<Compile Include="TestOrgApp.cs" /> <Compile Include="TestOrgApp.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?PowerDesigner AppLocale="UTF16" ID="{54F96D9D-A534-4ADF-ADAD-ACFE3C42BC44}" Label="" LastModificationDate="1446304241" Name="OpenAuthDB" Objects="263" Symbols="30" Target="Microsoft SQL Server 2008" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="16.5.0.3982"?> <?PowerDesigner AppLocale="UTF16" ID="{54F96D9D-A534-4ADF-ADAD-ACFE3C42BC44}" Label="" LastModificationDate="1447121989" Name="OpenAuthDB" Objects="248" Symbols="27" Target="Microsoft SQL Server 2008" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="16.5.0.3982"?>
<!-- do not edit this file --> <!-- do not edit this file -->
<Model xmlns:a="attribute" xmlns:c="collection" xmlns:o="object"> <Model xmlns:a="attribute" xmlns:c="collection" xmlns:o="object">
@@ -12,7 +12,7 @@
<a:Code>PDM_OA</a:Code> <a:Code>PDM_OA</a:Code>
<a:CreationDate>1430102287</a:CreationDate> <a:CreationDate>1430102287</a:CreationDate>
<a:Creator>yubaolee</a:Creator> <a:Creator>yubaolee</a:Creator>
<a:ModificationDate>1445752849</a:ModificationDate> <a:ModificationDate>1447121640</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier> <a:Modifier>Administrator</a:Modifier>
<a:History>ORG {9C5FE510-8BFA-4205-BF00-FC94E77A24A2} <a:History>ORG {9C5FE510-8BFA-4205-BF00-FC94E77A24A2}
DAT 1430102318 DAT 1430102318
@@ -204,7 +204,7 @@ GenScriptName6=
GenScriptName7= GenScriptName7=
GenScriptName8= GenScriptName8=
GenScriptName9= GenScriptName9=
GenPathName=F:\微云网盘\258210592\代码项目\OpenAuth.Net\数据库设计关系图\ GenPathName=E:\测试学习\OpenAuth.Net\数据库设计关系图\
GenSingleFile=Yes GenSingleFile=Yes
GenODBC=Yes GenODBC=Yes
GenCheckModel=No GenCheckModel=No
@@ -4642,7 +4642,7 @@ DESTINATION 0 新宋体,8,N</a:FontList>
<a:CreationDate>1445621646</a:CreationDate> <a:CreationDate>1445621646</a:CreationDate>
<a:ModificationDate>1445623386</a:ModificationDate> <a:ModificationDate>1445623386</a:ModificationDate>
<a:Rect>((-2897,-20310), (15477,1122))</a:Rect> <a:Rect>((-2897,-20310), (15477,1122))</a:Rect>
<a:ListOfPoints>((-2897,-20310),(-2404,-9215),(15252,-9215),(15252,1122))</a:ListOfPoints> <a:ListOfPoints>((-2897,-20310),(-2897,-9215),(15252,-9215),(15252,1122))</a:ListOfPoints>
<a:CornerStyle>1</a:CornerStyle> <a:CornerStyle>1</a:CornerStyle>
<a:ArrowStyle>1</a:ArrowStyle> <a:ArrowStyle>1</a:ArrowStyle>
<a:LineColor>12615680</a:LineColor> <a:LineColor>12615680</a:LineColor>
@@ -4686,7 +4686,7 @@ DESTINATION 0 新宋体,8,N</a:FontList>
<o:ReferenceSymbol Id="o19"> <o:ReferenceSymbol Id="o19">
<a:CreationDate>1445622899</a:CreationDate> <a:CreationDate>1445622899</a:CreationDate>
<a:ModificationDate>1445703422</a:ModificationDate> <a:ModificationDate>1445703422</a:ModificationDate>
<a:Rect>((-57424,-67162), (-9767,-51954))</a:Rect> <a:Rect>((-57312,-67162), (-9767,-51954))</a:Rect>
<a:ListOfPoints>((-55062,-67162),(-55062,-52366),(-9767,-52366))</a:ListOfPoints> <a:ListOfPoints>((-55062,-67162),(-55062,-52366),(-9767,-52366))</a:ListOfPoints>
<a:CornerStyle>1</a:CornerStyle> <a:CornerStyle>1</a:CornerStyle>
<a:ArrowStyle>1</a:ArrowStyle> <a:ArrowStyle>1</a:ArrowStyle>
@@ -4819,7 +4819,7 @@ DESTINATION 0 新宋体,8,N</a:FontList>
<o:ReferenceSymbol Id="o36"> <o:ReferenceSymbol Id="o36">
<a:CreationDate>1445692935</a:CreationDate> <a:CreationDate>1445692935</a:CreationDate>
<a:ModificationDate>1445692935</a:ModificationDate> <a:ModificationDate>1445692935</a:ModificationDate>
<a:Rect>((60088,-43886), (70437,-17618))</a:Rect> <a:Rect>((60200,-43886), (70324,-17618))</a:Rect>
<a:ListOfPoints>((62518,-17618),(62518,-31736),(68006,-31736),(68006,-43886))</a:ListOfPoints> <a:ListOfPoints>((62518,-17618),(62518,-31736),(68006,-31736),(68006,-43886))</a:ListOfPoints>
<a:CornerStyle>1</a:CornerStyle> <a:CornerStyle>1</a:CornerStyle>
<a:ArrowStyle>1</a:ArrowStyle> <a:ArrowStyle>1</a:ArrowStyle>
@@ -4863,7 +4863,7 @@ DESTINATION 0 新宋体,8,N</a:FontList>
<o:ReferenceSymbol Id="o41"> <o:ReferenceSymbol Id="o41">
<a:CreationDate>1445703432</a:CreationDate> <a:CreationDate>1445703432</a:CreationDate>
<a:ModificationDate>1445703433</a:ModificationDate> <a:ModificationDate>1445703433</a:ModificationDate>
<a:Rect>((-12393,-67673), (-2258,-48647))</a:Rect> <a:Rect>((-12329,-67673), (-2258,-48647))</a:Rect>
<a:ListOfPoints>((-12329,-67673),(-12329,-58993),(-2483,-58993),(-2483,-48647))</a:ListOfPoints> <a:ListOfPoints>((-12329,-67673),(-12329,-58993),(-2483,-58993),(-2483,-48647))</a:ListOfPoints>
<a:CornerStyle>1</a:CornerStyle> <a:CornerStyle>1</a:CornerStyle>
<a:ArrowStyle>1</a:ArrowStyle> <a:ArrowStyle>1</a:ArrowStyle>
@@ -4885,7 +4885,7 @@ DESTINATION 0 新宋体,8,N</a:FontList>
<o:ReferenceSymbol Id="o44"> <o:ReferenceSymbol Id="o44">
<a:CreationDate>1445703433</a:CreationDate> <a:CreationDate>1445703433</a:CreationDate>
<a:ModificationDate>1445703433</a:ModificationDate> <a:ModificationDate>1445703433</a:ModificationDate>
<a:Rect>((-32007,-84581), (-2662,-67995))</a:Rect> <a:Rect>((-32007,-84581), (-2774,-67995))</a:Rect>
<a:ListOfPoints>((-7461,-67995),(-7461,-84169),(-32007,-84169))</a:ListOfPoints> <a:ListOfPoints>((-7461,-67995),(-7461,-84169),(-32007,-84169))</a:ListOfPoints>
<a:CornerStyle>1</a:CornerStyle> <a:CornerStyle>1</a:CornerStyle>
<a:ArrowStyle>1</a:ArrowStyle> <a:ArrowStyle>1</a:ArrowStyle>
@@ -6075,10 +6075,11 @@ Drop=No</a:Settings>
<a:Code>Id</a:Code> <a:Code>Id</a:Code>
<a:CreationDate>1445528606</a:CreationDate> <a:CreationDate>1445528606</a:CreationDate>
<a:Creator>Administrator</a:Creator> <a:Creator>Administrator</a:Creator>
<a:ModificationDate>1446304241</a:ModificationDate> <a:ModificationDate>1447121106</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier> <a:Modifier>Administrator</a:Modifier>
<a:Comment>流水号</a:Comment> <a:Comment>流水号</a:Comment>
<a:DataType>int</a:DataType> <a:DataType>int</a:DataType>
<a:Identity>1</a:Identity>
<a:Column.Mandatory>1</a:Column.Mandatory> <a:Column.Mandatory>1</a:Column.Mandatory>
<a:ExtendedAttributesText>{F4F16ECD-F2F1-4006-AF6F-638D5C65F35E},MYSQL50,56={9C949EAB-FF87-446D-938C-8F03A4ABDC8E},National,4=true <a:ExtendedAttributesText>{F4F16ECD-F2F1-4006-AF6F-638D5C65F35E},MYSQL50,56={9C949EAB-FF87-446D-938C-8F03A4ABDC8E},National,4=true
@@ -6219,10 +6220,11 @@ Drop=No</a:Settings>
<a:Code>Id</a:Code> <a:Code>Id</a:Code>
<a:CreationDate>1445528606</a:CreationDate> <a:CreationDate>1445528606</a:CreationDate>
<a:Creator>Administrator</a:Creator> <a:Creator>Administrator</a:Creator>
<a:ModificationDate>1445696426</a:ModificationDate> <a:ModificationDate>1447121989</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier> <a:Modifier>Administrator</a:Modifier>
<a:Comment>流水号</a:Comment> <a:Comment>流水号</a:Comment>
<a:DataType>int</a:DataType> <a:DataType>int</a:DataType>
<a:Identity>1</a:Identity>
<a:Column.Mandatory>1</a:Column.Mandatory> <a:Column.Mandatory>1</a:Column.Mandatory>
<a:ExtendedAttributesText>{F4F16ECD-F2F1-4006-AF6F-638D5C65F35E},MYSQL50,56={9C949EAB-FF87-446D-938C-8F03A4ABDC8E},National,4=true <a:ExtendedAttributesText>{F4F16ECD-F2F1-4006-AF6F-638D5C65F35E},MYSQL50,56={9C949EAB-FF87-446D-938C-8F03A4ABDC8E},National,4=true
@@ -6347,10 +6349,11 @@ Drop=No</a:Settings>
<a:Code>Id</a:Code> <a:Code>Id</a:Code>
<a:CreationDate>1445528606</a:CreationDate> <a:CreationDate>1445528606</a:CreationDate>
<a:Creator>Administrator</a:Creator> <a:Creator>Administrator</a:Creator>
<a:ModificationDate>1445693006</a:ModificationDate> <a:ModificationDate>1447121562</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier> <a:Modifier>Administrator</a:Modifier>
<a:Comment>流水号</a:Comment> <a:Comment>流水号</a:Comment>
<a:DataType>int</a:DataType> <a:DataType>int</a:DataType>
<a:Identity>1</a:Identity>
<a:Column.Mandatory>1</a:Column.Mandatory> <a:Column.Mandatory>1</a:Column.Mandatory>
<a:ExtendedAttributesText>{F4F16ECD-F2F1-4006-AF6F-638D5C65F35E},MYSQL50,56={9C949EAB-FF87-446D-938C-8F03A4ABDC8E},National,4=true <a:ExtendedAttributesText>{F4F16ECD-F2F1-4006-AF6F-638D5C65F35E},MYSQL50,56={9C949EAB-FF87-446D-938C-8F03A4ABDC8E},National,4=true
@@ -6474,10 +6477,11 @@ Drop=No</a:Settings>
<a:Code>Id</a:Code> <a:Code>Id</a:Code>
<a:CreationDate>1445528606</a:CreationDate> <a:CreationDate>1445528606</a:CreationDate>
<a:Creator>Administrator</a:Creator> <a:Creator>Administrator</a:Creator>
<a:ModificationDate>1445692257</a:ModificationDate> <a:ModificationDate>1447121551</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier> <a:Modifier>Administrator</a:Modifier>
<a:Comment>流水号</a:Comment> <a:Comment>流水号</a:Comment>
<a:DataType>int</a:DataType> <a:DataType>int</a:DataType>
<a:Identity>1</a:Identity>
<a:Column.Mandatory>1</a:Column.Mandatory> <a:Column.Mandatory>1</a:Column.Mandatory>
<a:ExtendedAttributesText>{F4F16ECD-F2F1-4006-AF6F-638D5C65F35E},MYSQL50,56={9C949EAB-FF87-446D-938C-8F03A4ABDC8E},National,4=true <a:ExtendedAttributesText>{F4F16ECD-F2F1-4006-AF6F-638D5C65F35E},MYSQL50,56={9C949EAB-FF87-446D-938C-8F03A4ABDC8E},National,4=true
@@ -7477,10 +7481,11 @@ Drop=No</a:Settings>
<a:Code>Id</a:Code> <a:Code>Id</a:Code>
<a:CreationDate>1445528606</a:CreationDate> <a:CreationDate>1445528606</a:CreationDate>
<a:Creator>Administrator</a:Creator> <a:Creator>Administrator</a:Creator>
<a:ModificationDate>1445623684</a:ModificationDate> <a:ModificationDate>1447121216</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier> <a:Modifier>Administrator</a:Modifier>
<a:Comment>流水号</a:Comment> <a:Comment>流水号</a:Comment>
<a:DataType>int</a:DataType> <a:DataType>int</a:DataType>
<a:Identity>1</a:Identity>
<a:Column.Mandatory>1</a:Column.Mandatory> <a:Column.Mandatory>1</a:Column.Mandatory>
<a:ExtendedAttributesText>{F4F16ECD-F2F1-4006-AF6F-638D5C65F35E},MYSQL50,56={9C949EAB-FF87-446D-938C-8F03A4ABDC8E},National,4=true <a:ExtendedAttributesText>{F4F16ECD-F2F1-4006-AF6F-638D5C65F35E},MYSQL50,56={9C949EAB-FF87-446D-938C-8F03A4ABDC8E},National,4=true
@@ -7673,10 +7678,11 @@ Drop=No</a:Settings>
<a:Code>Id</a:Code> <a:Code>Id</a:Code>
<a:CreationDate>1445528606</a:CreationDate> <a:CreationDate>1445528606</a:CreationDate>
<a:Creator>Administrator</a:Creator> <a:Creator>Administrator</a:Creator>
<a:ModificationDate>1445703339</a:ModificationDate> <a:ModificationDate>1447121207</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier> <a:Modifier>Administrator</a:Modifier>
<a:Comment>流水号</a:Comment> <a:Comment>流水号</a:Comment>
<a:DataType>int</a:DataType> <a:DataType>int</a:DataType>
<a:Identity>1</a:Identity>
<a:Column.Mandatory>1</a:Column.Mandatory> <a:Column.Mandatory>1</a:Column.Mandatory>
<a:ExtendedAttributesText>{F4F16ECD-F2F1-4006-AF6F-638D5C65F35E},MYSQL50,56={9C949EAB-FF87-446D-938C-8F03A4ABDC8E},National,4=true <a:ExtendedAttributesText>{F4F16ECD-F2F1-4006-AF6F-638D5C65F35E},MYSQL50,56={9C949EAB-FF87-446D-938C-8F03A4ABDC8E},National,4=true
@@ -7781,10 +7787,11 @@ Drop=No</a:Settings>
<a:Code>Id</a:Code> <a:Code>Id</a:Code>
<a:CreationDate>1445528606</a:CreationDate> <a:CreationDate>1445528606</a:CreationDate>
<a:Creator>Administrator</a:Creator> <a:Creator>Administrator</a:Creator>
<a:ModificationDate>1445703451</a:ModificationDate> <a:ModificationDate>1447121195</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier> <a:Modifier>Administrator</a:Modifier>
<a:Comment>流水号</a:Comment> <a:Comment>流水号</a:Comment>
<a:DataType>int</a:DataType> <a:DataType>int</a:DataType>
<a:Identity>1</a:Identity>
<a:Column.Mandatory>1</a:Column.Mandatory> <a:Column.Mandatory>1</a:Column.Mandatory>
<a:ExtendedAttributesText>{F4F16ECD-F2F1-4006-AF6F-638D5C65F35E},MYSQL50,56={9C949EAB-FF87-446D-938C-8F03A4ABDC8E},National,4=true <a:ExtendedAttributesText>{F4F16ECD-F2F1-4006-AF6F-638D5C65F35E},MYSQL50,56={9C949EAB-FF87-446D-938C-8F03A4ABDC8E},National,4=true