mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-18 17:48:01 +08:00
完成机构与用户管理
This commit is contained in:
@@ -16,7 +16,7 @@ namespace OpenAuth.App
|
||||
|
||||
public void Login(string userName, string password)
|
||||
{
|
||||
var user = _repository.FindByAccount(userName);
|
||||
var user = _repository.FindSingle(u =>u.Account ==userName);
|
||||
if (user == null)
|
||||
{
|
||||
throw new Exception("<22>û<EFBFBD><C3BB>ʺŲ<CABA><C5B2><EFBFBD><EFBFBD><EFBFBD>");
|
||||
|
@@ -44,8 +44,10 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="LoginApp.cs" />
|
||||
<Compile Include="UserManagerApp.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="OrgManagerApp.cs" />
|
||||
<Compile Include="ViewModel\UserView.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj">
|
||||
@@ -57,6 +59,7 @@
|
||||
<Name>OpenAuth.Domain</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- 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.
|
||||
|
@@ -15,9 +15,9 @@ namespace OpenAuth.App
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
public IEnumerable<Org> GetAll()
|
||||
public IList<Org> GetAll()
|
||||
{
|
||||
return _repository.LoadOrgs();
|
||||
return _repository.LoadOrgs().ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -26,16 +26,16 @@ namespace OpenAuth.App
|
||||
/// </summary>
|
||||
/// <param name="orgId">The org unique identifier.</param>
|
||||
/// <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>
|
||||
/// 得到部门的所有子部门
|
||||
/// <para>如果orgId为0,表示取得所有部门</para>
|
||||
/// </summary>
|
||||
public IEnumerable<Org> LoadAllChildren(int orgId)
|
||||
public IList<Org> LoadAllChildren(int orgId)
|
||||
{
|
||||
string cascadeId = "0.";
|
||||
if (orgId != 0)
|
||||
@@ -46,7 +46,7 @@ namespace OpenAuth.App
|
||||
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>
|
||||
|
@@ -9,5 +9,7 @@ namespace OpenAuth.Domain.Interface
|
||||
public interface IOrgRepository :IRepository<Org>
|
||||
{
|
||||
IEnumerable<Org> LoadOrgs();
|
||||
|
||||
IEnumerable<Org> LoadByUser(int userId);
|
||||
}
|
||||
}
|
||||
|
@@ -5,10 +5,21 @@ namespace OpenAuth.Domain.Interface
|
||||
{
|
||||
public interface IUserRepository :IRepository<User>
|
||||
{
|
||||
User FindByAccount(string account);
|
||||
User FindById(string id);
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
@@ -12,13 +12,13 @@
|
||||
// <summary>IOC<4F><43>ʼ<EFBFBD><CABC></summary>
|
||||
// ***********************************************************************
|
||||
|
||||
using System.Reflection;
|
||||
using System.Web.Mvc;
|
||||
using Autofac;
|
||||
using Autofac.Integration.Mvc;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.Domain.Interface;
|
||||
using OpenAuth.Repository;
|
||||
using System.Reflection;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace OpenAuth.Mvc
|
||||
{
|
||||
@@ -32,6 +32,8 @@ namespace OpenAuth.Mvc
|
||||
builder.RegisterType<OrgRepository>().As<IOrgRepository>();
|
||||
builder.RegisterType<LoginApp>();
|
||||
builder.RegisterType<OrgManagerApp>();
|
||||
builder.RegisterType<UserManagerApp>();
|
||||
|
||||
|
||||
// Register your MVC controllers.
|
||||
builder.RegisterControllers(typeof(MvcApplication).Assembly);
|
||||
|
@@ -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.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_part{background-position:-19px -46px;}
|
||||
.ztree li span.button.chk.checkbox_false_part_focus{background-position:-19px -24px;}
|
||||
.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;*/background-position:0 -2px;}
|
||||
.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_focus{background-position:-19px -24px;}
|
||||
|
@@ -1,21 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using OpenAuth.App;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
public class HomeController : BaseController
|
||||
{
|
||||
private LoginApp _loginApp;
|
||||
|
||||
public HomeController()
|
||||
{
|
||||
_loginApp = (LoginApp)DependencyResolver.Current.GetService(typeof(LoginApp));
|
||||
}
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
@@ -30,11 +18,5 @@ namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public string LoadUsers()
|
||||
{
|
||||
return JsonConvert.SerializeObject(_loginApp.LoadUsers());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -33,6 +33,11 @@ namespace OpenAuth.Mvc.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult LookupMulti()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult AddOrg()
|
||||
{
|
||||
return View();
|
||||
@@ -71,7 +76,16 @@ namespace OpenAuth.Mvc.Controllers
|
||||
|
||||
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)
|
||||
|
@@ -1,18 +1,90 @@
|
||||
using System;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using OpenAuth.App.ViewModel;
|
||||
|
||||
namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
public class UserManagerController : BaseController
|
||||
{
|
||||
private UserManagerApp _app;
|
||||
|
||||
public UserManagerController()
|
||||
{
|
||||
_app = (UserManagerApp)DependencyResolver.Current.GetService(typeof(UserManagerApp));
|
||||
}
|
||||
|
||||
//
|
||||
// GET: /UserManager/
|
||||
public ActionResult Index()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -123,7 +123,6 @@
|
||||
<Compile Include="AutofacExt.cs" />
|
||||
<Compile Include="Controllers\BaseController.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\ModuleManagerController.cs" />
|
||||
<Compile Include="Controllers\OrgManagerController.cs" />
|
||||
<Compile Include="Controllers\UserManagerController.cs" />
|
||||
<Compile Include="Global.asax.cs">
|
||||
@@ -612,10 +611,9 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<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\AddOrg.cshtml" />
|
||||
<Content Include="Views\OrgManager\LookupOrg.cshtml" />
|
||||
<Content Include="Views\UserManager\Add.cshtml" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
|
@@ -24,8 +24,8 @@
|
||||
<td>
|
||||
<input id="ParentId" name="ParentId" type="hidden">
|
||||
<label for="ParentName" class="control-label x90">上级机构:</label>
|
||||
<input type="text" name="ParentName" id="ParentName"
|
||||
value="" data-toggle="lookup" data-url="/OrgManager/LookupParent">
|
||||
<input type="text" name="ParentName" id="ParentName" data-toggle="selectztree" size="20" data-tree="#j_select_tree1">
|
||||
<ul id="j_select_tree1" class="ztree hide" data-toggle="ztree"></ul>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
@@ -50,3 +50,66 @@
|
||||
<li><button type="submit" class="btn-green">保存</button></li>
|
||||
</ul>
|
||||
</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>
|
||||
|
@@ -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 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 id="ztree-detail" style="margin-left: 225px; width: auto;height: auto">
|
||||
<table id="mainGrid" data-width="100%" data-height="100%" class="table table-bordered"></table>
|
||||
<div id="@_treeDetail" style="margin-left: 225px; width: auto;height: auto">
|
||||
<table id="@_gridId" data-width="100%" data-height="100%" class="table table-bordered"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -16,11 +22,11 @@
|
||||
Init(0);
|
||||
});
|
||||
//加载数据到datagrid
|
||||
function loadDataGrid(data) {
|
||||
function LoadOrg(data) {
|
||||
//b-jui的datagrid需要重新处理HTML
|
||||
$('#ztree-detail').empty()
|
||||
.append('<table id="mainGrid" data-width="100%" data-height="100%" class="table table-bordered"></table>');
|
||||
$('#mainGrid').datagrid({
|
||||
$('#@_treeDetail').empty()
|
||||
.append('<table id="@_gridId" data-width="100%" data-height="100%" class="table table-bordered"></table>');
|
||||
$('#@_gridId').datagrid({
|
||||
gridTitle: '机构列表显示',
|
||||
showToolbar: true,
|
||||
toolbarItem: 'refresh, |, del,edit',
|
||||
@@ -100,7 +106,7 @@
|
||||
$.getJSON('OrgManager/LoadChildren', {
|
||||
id: treeNode.Id
|
||||
}, function (json) {
|
||||
loadDataGrid(json);
|
||||
LoadOrg(json);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -126,13 +132,13 @@
|
||||
}
|
||||
};
|
||||
$.getJSON('OrgManager/LoadOrg', function (json) {
|
||||
var zTreeObj = $.fn.zTree.init($('#orgTree'), setting, json);
|
||||
var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
|
||||
zTreeObj.expandAll(true);
|
||||
|
||||
$.getJSON('OrgManager/LoadChildren', {
|
||||
id: selectedId
|
||||
}, function (data) {
|
||||
loadDataGrid(data);
|
||||
LoadOrg(data);
|
||||
});
|
||||
|
||||
//TODO:设置ztree选中,不过没看到效果..
|
||||
@@ -145,7 +151,7 @@
|
||||
//获取勾选的值
|
||||
//column:为从0开始的列标识
|
||||
function getSelected(column) {
|
||||
var selected = $('#mainGrid').data('selectedTrs');
|
||||
var selected = $('#@_gridId').data('selectedTrs');
|
||||
if (selected == null || selected.length == 0) {
|
||||
$(this).alertmsg('warn', '至少选择一个对象', {
|
||||
displayMode: 'slide',
|
||||
|
@@ -15,7 +15,7 @@
|
||||
|
||||
<li>
|
||||
<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>
|
||||
</li>
|
||||
|
||||
|
@@ -1,30 +1,45 @@
|
||||
<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 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 id="ztree-detail" style="margin-left: 225px; width: auto;height: auto">
|
||||
<table id="mainGrid" data-width="100%" data-height="100%" class="table table-bordered"></table>
|
||||
<div id="@_treeDetail" style="margin-left: 225px; width: auto;height: auto">
|
||||
<table id="@_gridId" data-width="100%" data-height="100%" class="table table-bordered"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var gridid = '#@_gridId';
|
||||
var selectedId = 0;
|
||||
$(document).ready(function () {
|
||||
Init(0);
|
||||
initZtree();
|
||||
loadDataGrid();
|
||||
});
|
||||
//加载数据到datagrid
|
||||
function loadDataGrid(data) {
|
||||
function loadDataGrid() {
|
||||
$.getJSON('UserManager/Load', {
|
||||
orgId: selectedId
|
||||
}, function (data) {
|
||||
initGrid(data);
|
||||
});
|
||||
}
|
||||
function initGrid(data) {
|
||||
//b-jui的datagrid需要重新处理HTML
|
||||
$('#ztree-detail').empty()
|
||||
.append('<table id="mainGrid" data-width="100%" data-height="100%" class="table table-bordered"></table>');
|
||||
$('#mainGrid').datagrid({
|
||||
gridTitle: '机构列表显示',
|
||||
$('#@_treeDetail').empty()
|
||||
.append('<table id="@_gridId" data-width="100%" data-height="100%" class="table table-bordered"></table>');
|
||||
$(gridid).datagrid({
|
||||
gridTitle: '用户列表',
|
||||
showToolbar: true,
|
||||
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>' ,
|
||||
columns: [
|
||||
{
|
||||
@@ -34,25 +49,17 @@
|
||||
hide: true
|
||||
},
|
||||
{
|
||||
name: 'ParentId',
|
||||
label: '上级机构ID',
|
||||
attrs: { readonly: 'readonly'},
|
||||
hide: true
|
||||
},
|
||||
{
|
||||
name: 'CascadeId',
|
||||
label: '唯一标识',
|
||||
name: 'Account',
|
||||
label: '用户账号',
|
||||
attrs: { readonly: 'readonly'}
|
||||
},
|
||||
{
|
||||
name: 'Name',
|
||||
label: '机构名称'
|
||||
label: '姓名/昵称'
|
||||
},
|
||||
{
|
||||
name: 'ParentName',
|
||||
label: '上级机构',
|
||||
edit: false,
|
||||
attrs: { readonly: 'readonly' }
|
||||
name: 'Organizations',
|
||||
label: '所属机构'
|
||||
},
|
||||
{
|
||||
name: 'Status',
|
||||
@@ -61,6 +68,13 @@
|
||||
align: 'center',
|
||||
items:[{'0':'正常'}, {'1':'禁用'}]
|
||||
},
|
||||
{
|
||||
name: 'Sex',
|
||||
label: '性别',
|
||||
type: 'select',
|
||||
align: 'center',
|
||||
items: [{ '0': '男' }, { '1': '女' }]
|
||||
},
|
||||
{
|
||||
name: 'CreateTime',
|
||||
label: '登记日期',
|
||||
@@ -69,9 +83,9 @@
|
||||
}
|
||||
],
|
||||
data: data,
|
||||
delUrl: 'OrgManager/DelOrg',
|
||||
delUrl: 'UserManager/Delete',
|
||||
delPK: "Id",
|
||||
editUrl: 'OrgManager/EditOrg',
|
||||
editUrl: 'UserManager/Edit',
|
||||
editMode: 'dialog',
|
||||
fullGrid: true,
|
||||
showLinenumber: true,
|
||||
@@ -81,14 +95,14 @@
|
||||
showTfoot: true,
|
||||
delCallback: function (delResult) {
|
||||
if (delResult.statusCode == "200")
|
||||
Init(selectedId);
|
||||
loadDataGrid();
|
||||
else {
|
||||
$(this).alertmsg('warn', delResult.message);
|
||||
}
|
||||
},
|
||||
editCallback: function (delResult) {
|
||||
if (delResult.statusCode == "200")
|
||||
Init(selectedId);
|
||||
loadDataGrid();
|
||||
else {
|
||||
$(this).alertmsg('warn', delResult.message);
|
||||
}
|
||||
@@ -97,18 +111,12 @@
|
||||
}
|
||||
function zTreeOnClick(event, treeId, treeNode) {
|
||||
selectedId = treeNode.Id;
|
||||
$.getJSON('OrgManager/LoadChildren', {
|
||||
id: treeNode.Id
|
||||
}, function (json) {
|
||||
loadDataGrid(json);
|
||||
});
|
||||
loadDataGrid();
|
||||
}
|
||||
|
||||
function Init(selectedId) {
|
||||
function initZtree() {
|
||||
var setting = {
|
||||
view: {
|
||||
selectedMulti: false
|
||||
},
|
||||
view: {selectedMulti: false},
|
||||
data: {
|
||||
key: {
|
||||
name: 'Name',
|
||||
@@ -121,31 +129,18 @@
|
||||
rootPId: 'null'
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onClick: zTreeOnClick
|
||||
}
|
||||
callback: {onClick: zTreeOnClick}
|
||||
};
|
||||
$.getJSON('OrgManager/LoadOrg', function (json) {
|
||||
var zTreeObj = $.fn.zTree.init($('#orgTree'), setting, json);
|
||||
var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
|
||||
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开始的列标识
|
||||
function getSelected(column) {
|
||||
var selected = $('#mainGrid').data('selectedTrs');
|
||||
var selected = $(gridid).data('selectedTrs');
|
||||
if (selected == null || selected.length == 0) {
|
||||
$(this).alertmsg('warn', '至少选择一个对象', {
|
||||
displayMode: 'slide',
|
||||
@@ -170,5 +165,5 @@
|
||||
if (selected == null) return;
|
||||
|
||||
}
|
||||
//@@ sourceURL=orgIndex.js
|
||||
//@@ sourceURL=userManagerIndex.js
|
||||
</script>
|
||||
|
@@ -45,6 +45,7 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
|
@@ -14,5 +14,15 @@ namespace OpenAuth.Repository
|
||||
{
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,27 +1,70 @@
|
||||
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 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()
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -66,6 +66,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TestFunction.cs" />
|
||||
<Compile Include="TestUserApp.cs" />
|
||||
<Compile Include="TestOrgApp.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
<?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 -->
|
||||
|
||||
<Model xmlns:a="attribute" xmlns:c="collection" xmlns:o="object">
|
||||
@@ -12,7 +12,7 @@
|
||||
<a:Code>PDM_OA</a:Code>
|
||||
<a:CreationDate>1430102287</a:CreationDate>
|
||||
<a:Creator>yubaolee</a:Creator>
|
||||
<a:ModificationDate>1445752849</a:ModificationDate>
|
||||
<a:ModificationDate>1447121640</a:ModificationDate>
|
||||
<a:Modifier>Administrator</a:Modifier>
|
||||
<a:History>ORG {9C5FE510-8BFA-4205-BF00-FC94E77A24A2}
|
||||
DAT 1430102318
|
||||
@@ -204,7 +204,7 @@ GenScriptName6=
|
||||
GenScriptName7=
|
||||
GenScriptName8=
|
||||
GenScriptName9=
|
||||
GenPathName=F:\微云网盘\258210592\代码项目\OpenAuth.Net\数据库设计关系图\
|
||||
GenPathName=E:\测试学习\OpenAuth.Net\数据库设计关系图\
|
||||
GenSingleFile=Yes
|
||||
GenODBC=Yes
|
||||
GenCheckModel=No
|
||||
@@ -4642,7 +4642,7 @@ DESTINATION 0 新宋体,8,N</a:FontList>
|
||||
<a:CreationDate>1445621646</a:CreationDate>
|
||||
<a:ModificationDate>1445623386</a:ModificationDate>
|
||||
<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:ArrowStyle>1</a:ArrowStyle>
|
||||
<a:LineColor>12615680</a:LineColor>
|
||||
@@ -4686,7 +4686,7 @@ DESTINATION 0 新宋体,8,N</a:FontList>
|
||||
<o:ReferenceSymbol Id="o19">
|
||||
<a:CreationDate>1445622899</a:CreationDate>
|
||||
<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:CornerStyle>1</a:CornerStyle>
|
||||
<a:ArrowStyle>1</a:ArrowStyle>
|
||||
@@ -4819,7 +4819,7 @@ DESTINATION 0 新宋体,8,N</a:FontList>
|
||||
<o:ReferenceSymbol Id="o36">
|
||||
<a:CreationDate>1445692935</a:CreationDate>
|
||||
<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:CornerStyle>1</a:CornerStyle>
|
||||
<a:ArrowStyle>1</a:ArrowStyle>
|
||||
@@ -4863,7 +4863,7 @@ DESTINATION 0 新宋体,8,N</a:FontList>
|
||||
<o:ReferenceSymbol Id="o41">
|
||||
<a:CreationDate>1445703432</a:CreationDate>
|
||||
<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:CornerStyle>1</a:CornerStyle>
|
||||
<a:ArrowStyle>1</a:ArrowStyle>
|
||||
@@ -4885,7 +4885,7 @@ DESTINATION 0 新宋体,8,N</a:FontList>
|
||||
<o:ReferenceSymbol Id="o44">
|
||||
<a:CreationDate>1445703433</a:CreationDate>
|
||||
<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:CornerStyle>1</a:CornerStyle>
|
||||
<a:ArrowStyle>1</a:ArrowStyle>
|
||||
@@ -6075,10 +6075,11 @@ Drop=No</a:Settings>
|
||||
<a:Code>Id</a:Code>
|
||||
<a:CreationDate>1445528606</a:CreationDate>
|
||||
<a:Creator>Administrator</a:Creator>
|
||||
<a:ModificationDate>1446304241</a:ModificationDate>
|
||||
<a:ModificationDate>1447121106</a:ModificationDate>
|
||||
<a:Modifier>Administrator</a:Modifier>
|
||||
<a:Comment>流水号</a:Comment>
|
||||
<a:DataType>int</a:DataType>
|
||||
<a:Identity>1</a:Identity>
|
||||
<a:Column.Mandatory>1</a:Column.Mandatory>
|
||||
<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:CreationDate>1445528606</a:CreationDate>
|
||||
<a:Creator>Administrator</a:Creator>
|
||||
<a:ModificationDate>1445696426</a:ModificationDate>
|
||||
<a:ModificationDate>1447121989</a:ModificationDate>
|
||||
<a:Modifier>Administrator</a:Modifier>
|
||||
<a:Comment>流水号</a:Comment>
|
||||
<a:DataType>int</a:DataType>
|
||||
<a:Identity>1</a:Identity>
|
||||
<a:Column.Mandatory>1</a:Column.Mandatory>
|
||||
<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:CreationDate>1445528606</a:CreationDate>
|
||||
<a:Creator>Administrator</a:Creator>
|
||||
<a:ModificationDate>1445693006</a:ModificationDate>
|
||||
<a:ModificationDate>1447121562</a:ModificationDate>
|
||||
<a:Modifier>Administrator</a:Modifier>
|
||||
<a:Comment>流水号</a:Comment>
|
||||
<a:DataType>int</a:DataType>
|
||||
<a:Identity>1</a:Identity>
|
||||
<a:Column.Mandatory>1</a:Column.Mandatory>
|
||||
<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:CreationDate>1445528606</a:CreationDate>
|
||||
<a:Creator>Administrator</a:Creator>
|
||||
<a:ModificationDate>1445692257</a:ModificationDate>
|
||||
<a:ModificationDate>1447121551</a:ModificationDate>
|
||||
<a:Modifier>Administrator</a:Modifier>
|
||||
<a:Comment>流水号</a:Comment>
|
||||
<a:DataType>int</a:DataType>
|
||||
<a:Identity>1</a:Identity>
|
||||
<a:Column.Mandatory>1</a:Column.Mandatory>
|
||||
<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:CreationDate>1445528606</a:CreationDate>
|
||||
<a:Creator>Administrator</a:Creator>
|
||||
<a:ModificationDate>1445623684</a:ModificationDate>
|
||||
<a:ModificationDate>1447121216</a:ModificationDate>
|
||||
<a:Modifier>Administrator</a:Modifier>
|
||||
<a:Comment>流水号</a:Comment>
|
||||
<a:DataType>int</a:DataType>
|
||||
<a:Identity>1</a:Identity>
|
||||
<a:Column.Mandatory>1</a:Column.Mandatory>
|
||||
<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:CreationDate>1445528606</a:CreationDate>
|
||||
<a:Creator>Administrator</a:Creator>
|
||||
<a:ModificationDate>1445703339</a:ModificationDate>
|
||||
<a:ModificationDate>1447121207</a:ModificationDate>
|
||||
<a:Modifier>Administrator</a:Modifier>
|
||||
<a:Comment>流水号</a:Comment>
|
||||
<a:DataType>int</a:DataType>
|
||||
<a:Identity>1</a:Identity>
|
||||
<a:Column.Mandatory>1</a:Column.Mandatory>
|
||||
<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:CreationDate>1445528606</a:CreationDate>
|
||||
<a:Creator>Administrator</a:Creator>
|
||||
<a:ModificationDate>1445703451</a:ModificationDate>
|
||||
<a:ModificationDate>1447121195</a:ModificationDate>
|
||||
<a:Modifier>Administrator</a:Modifier>
|
||||
<a:Comment>流水号</a:Comment>
|
||||
<a:DataType>int</a:DataType>
|
||||
<a:Identity>1</a:Identity>
|
||||
<a:Column.Mandatory>1</a:Column.Mandatory>
|
||||
<a:ExtendedAttributesText>{F4F16ECD-F2F1-4006-AF6F-638D5C65F35E},MYSQL50,56={9C949EAB-FF87-446D-938C-8F03A4ABDC8E},National,4=true
|
||||
|
||||
|
Reference in New Issue
Block a user