mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-30 20:58:01 +08:00
修正因合并多对多映射造成的BUG
This commit is contained in:
parent
464f04bb32
commit
afceafb00c
@ -1,10 +1,10 @@
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.ViewModel;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Infrastructure;
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
@ -51,13 +51,7 @@ namespace OpenAuth.App
|
||||
/// </summary>
|
||||
public List<Module> LoadForTree()
|
||||
{
|
||||
return _repository.Find(null).ToList();
|
||||
}
|
||||
public List<Module> LoadForUser(int userId)
|
||||
{
|
||||
var moduleIds = _relevanceRepository.Find(u => u.FirstId == userId).Select(u => u.SecondId).ToList();
|
||||
if(!moduleIds.Any()) return null;
|
||||
return _repository.Find(u => moduleIds.Contains(u.Id)).ToList();
|
||||
return _repository.Find(null).ToList();
|
||||
}
|
||||
|
||||
public List<Module> LoadForNav()
|
||||
@ -114,12 +108,60 @@ namespace OpenAuth.App
|
||||
}
|
||||
}
|
||||
|
||||
public void AccessModules(int userId, int[] ids)
|
||||
#region 用户/角色分配模块
|
||||
|
||||
/// <summary>
|
||||
/// 加载特定用户的模块
|
||||
/// </summary>
|
||||
/// <param name="userId">The user unique identifier.</param>
|
||||
public List<Module> LoadForUser(int userId)
|
||||
{
|
||||
_relevanceRepository.DeleteBy("UserModule",userId);
|
||||
_relevanceRepository.AddRelevance("UserModule",ids.ToDictionary(u =>userId));
|
||||
var moduleIds =
|
||||
_relevanceRepository.Find(u => u.FirstId == userId && u.Key == "UserModule")
|
||||
.Select(u => u.SecondId)
|
||||
.ToList();
|
||||
if (!moduleIds.Any()) return null;
|
||||
return _repository.Find(u => moduleIds.Contains(u.Id)).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为特定的用户分配模块
|
||||
/// </summary>
|
||||
/// <param name="userId">The user unique identifier.</param>
|
||||
/// <param name="ids">模块ID</param>
|
||||
public void AssignModuleForUser(int userId, int[] ids)
|
||||
{
|
||||
_relevanceRepository.DeleteBy("UserModule", userId);
|
||||
_relevanceRepository.AddRelevance("UserModule", ids.ToLookup(u => userId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载特定角色的模块
|
||||
/// </summary>
|
||||
/// <param name="roleId">The role unique identifier.</param>
|
||||
public List<Module> LoadForRole(int roleId)
|
||||
{
|
||||
var moduleIds =
|
||||
_relevanceRepository.Find(u => u.FirstId == roleId && u.Key == "RoleModule")
|
||||
.Select(u => u.SecondId)
|
||||
.ToList();
|
||||
if (!moduleIds.Any()) return null;
|
||||
return _repository.Find(u => moduleIds.Contains(u.Id)).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为特定的角色分配模块
|
||||
/// </summary>
|
||||
/// <param name="roleId">The user unique identifier.</param>
|
||||
/// <param name="ids">模块ID</param>
|
||||
public void AssignModuleForRole(int roleId, int[] ids)
|
||||
{
|
||||
_relevanceRepository.DeleteBy("RoleModule", roleId);
|
||||
_relevanceRepository.AddRelevance("RoleModule", ids.ToLookup(u => roleId));
|
||||
}
|
||||
|
||||
#endregion 用户/角色分配模块
|
||||
|
||||
#region 私有方法
|
||||
|
||||
//根据同一级中最大的语义ID
|
||||
@ -166,7 +208,5 @@ namespace OpenAuth.App
|
||||
}
|
||||
|
||||
#endregion 私有方法
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ using OpenAuth.Domain.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Security;
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
@ -53,7 +52,6 @@ namespace OpenAuth.App
|
||||
total = _repository.GetRoleCntInOrgs(orgId);
|
||||
}
|
||||
|
||||
|
||||
return new
|
||||
{
|
||||
total = total,
|
||||
@ -77,7 +75,6 @@ namespace OpenAuth.App
|
||||
var role = _repository.FindSingle(u => u.Id == id);
|
||||
if (role == null) role = new Role();
|
||||
return role;
|
||||
|
||||
}
|
||||
|
||||
public void Delete(int id)
|
||||
@ -96,10 +93,8 @@ namespace OpenAuth.App
|
||||
{
|
||||
_repository.Update(role);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<RoleVM> LoadWithUser(int userId)
|
||||
{
|
||||
var roleIds = _repository.Find(null).ToList();
|
||||
@ -108,9 +103,9 @@ namespace OpenAuth.App
|
||||
{
|
||||
RoleVM rolevm = role;
|
||||
rolevm.IsBelongUser = (_relevanceRepository.FindSingle(u => u.SecondId == role.Id
|
||||
&& u.FirstId == userId
|
||||
&& u.Key =="UserRole")
|
||||
!=null);
|
||||
&& u.FirstId == userId
|
||||
&& u.Key == "UserRole")
|
||||
!= null);
|
||||
rolevms.Add(rolevm);
|
||||
}
|
||||
return rolevms;
|
||||
@ -120,7 +115,7 @@ namespace OpenAuth.App
|
||||
{
|
||||
_relevanceRepository.DeleteBy("UserRole", userId);
|
||||
|
||||
_relevanceRepository.AddRelevance("UserRole",roleIds.ToDictionary(roleId => userId));
|
||||
_relevanceRepository.AddRelevance("UserRole", roleIds.ToLookup(roleId => userId));
|
||||
}
|
||||
}
|
||||
}
|
@ -116,7 +116,7 @@ namespace OpenAuth.App
|
||||
int[] orgIds = view.OrganizationIds.Split(',').Select(id => int.Parse(id)).ToArray();
|
||||
|
||||
_relevanceRepository.DeleteBy("UserOrg", user.Id);
|
||||
_relevanceRepository.AddRelevance("UserOrg", orgIds.ToDictionary(u =>user.Id));
|
||||
_relevanceRepository.AddRelevance("UserOrg", orgIds.ToLookup(u =>user.Id));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,12 +24,19 @@ namespace OpenAuth.Mvc.Controllers
|
||||
}
|
||||
|
||||
//用于选择模块时使用
|
||||
public ActionResult LookUpMulti(int userId)
|
||||
public ActionResult LookUpMultiForUser(int userId)
|
||||
{
|
||||
ViewBag.UserId = userId;
|
||||
return View();
|
||||
}
|
||||
|
||||
//为角色分配模块
|
||||
public ActionResult LookupMultiForRole(int roleId)
|
||||
{
|
||||
ViewBag.RoleId = roleId;
|
||||
return View();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载模块下面的所有模块
|
||||
/// </summary>
|
||||
@ -87,12 +94,42 @@ namespace OpenAuth.Mvc.Controllers
|
||||
return JsonHelper.Instance.Serialize(orgs);
|
||||
}
|
||||
|
||||
public string AccessModule(int userId, string moduleIds)
|
||||
public string LoadForRole(int roleId)
|
||||
{
|
||||
var orgs = _app.LoadForRole(roleId);
|
||||
//添加根节点
|
||||
orgs.Add(new Module
|
||||
{
|
||||
Id = 0,
|
||||
ParentId = -1,
|
||||
Name = "已为角色分配的模块",
|
||||
CascadeId = "0"
|
||||
});
|
||||
return JsonHelper.Instance.Serialize(orgs);
|
||||
}
|
||||
|
||||
public string AssignModuleForRole(int roleId, string moduleIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ids = moduleIds.Split(',').Select(id => int.Parse(id)).ToArray();
|
||||
_app.AccessModules(userId, ids);
|
||||
_app.AssignModuleForRole(roleId, ids);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BjuiResponse.message = e.Message;
|
||||
BjuiResponse.statusCode = "300";
|
||||
}
|
||||
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
|
||||
public string AssignModuleForUser(int userId, string moduleIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ids = moduleIds.Split(',').Select(id => int.Parse(id)).ToArray();
|
||||
_app.AssignModuleForUser(userId, ids);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -617,7 +617,8 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Views\ModuleManager\Index.cshtml" />
|
||||
<Content Include="Views\ModuleManager\Add.cshtml" />
|
||||
<Content Include="Views\ModuleManager\LookupMulti.cshtml" />
|
||||
<Content Include="Views\ModuleManager\LookupMultiForUser.cshtml" />
|
||||
<Content Include="Views\ModuleManager\LookupMultiForRole.cshtml" />
|
||||
<None Include="Views\OrgManager\AddOrg.cshtml" />
|
||||
<Content Include="Views\OrgManager\LookupParent.cshtml" />
|
||||
<Content Include="Views\UserManager\Index.cshtml" />
|
||||
|
@ -8,9 +8,7 @@
|
||||
<form action="/ModuleManager/Add" class="pageForm" data-toggle="validate">
|
||||
<table class="table table-condensed table-hover">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center"><h3>* 添加</h3></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
@Html.HiddenFor(m => m.Id)
|
||||
|
@ -1,123 +1,123 @@
|
||||
@*
|
||||
选择多个模块ID,以ids的形式返回
|
||||
*@
|
||||
|
||||
@{
|
||||
ViewBag.Title = "title";
|
||||
Layout = null;
|
||||
}
|
||||
<div class="bjui-pageContent">
|
||||
<input style="display: none" id="userId" value="@ViewBag.UserId"/>
|
||||
<div style="float: left; width: 220px; height: 240px; overflow: auto;" class="table table-bordered">
|
||||
<ul id="lookupTree" class="ztree"></ul>
|
||||
</div>
|
||||
<!--已经选中的列表-->
|
||||
<div style="margin-left: 225px">
|
||||
<ul id="selected" class="ztree"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bjui-pageFooter">
|
||||
<ul>
|
||||
<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
|
||||
<li><button type="button" onclick="save()" class="btn btn-blue" data-icon="check">保存</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var moduleIds;
|
||||
$(document).ready(function () {
|
||||
Init();
|
||||
InitSelected();
|
||||
});
|
||||
function Init() {
|
||||
var setting = {
|
||||
view: {
|
||||
selectedMulti: false
|
||||
},
|
||||
check: {
|
||||
enable: true,
|
||||
chkStyle: "checkbox"
|
||||
},
|
||||
data: {
|
||||
key: {
|
||||
name: 'Name',
|
||||
title: 'Name'
|
||||
},
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: 'Id',
|
||||
pIdKey: 'ParentId',
|
||||
rootPId: 'null'
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onClick: zTreeOnClick,
|
||||
onCheck: zTreeCheck
|
||||
}
|
||||
};
|
||||
$.getJSON('ModuleManager/LoadForTree', function (json) {
|
||||
var zTreeObj = $.fn.zTree.init($('#lookupTree'), setting, json);
|
||||
zTreeObj.expandAll(true);
|
||||
});
|
||||
}
|
||||
|
||||
function InitSelected() {
|
||||
var setting = {
|
||||
|
||||
data: {
|
||||
key: {
|
||||
name: 'Name',
|
||||
title: 'Name'
|
||||
},
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: 'Id',
|
||||
pIdKey: 'ParentId',
|
||||
rootPId: 'null'
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onClick: zTreeOnClick,
|
||||
onCheck: zTreeCheck
|
||||
}
|
||||
};
|
||||
$.post('ModuleManager/LoadForUser', { userId: $('#userId').val() },
|
||||
function (json) {
|
||||
var zTreeObj = $.fn.zTree.init($('#selected'), setting, eval(json));
|
||||
zTreeObj.expandAll(true);
|
||||
});
|
||||
}
|
||||
|
||||
function save() {
|
||||
$.post('ModuleManager/AccessModule', { userId: $('#userId').val(), moduleIds: moduleIds },
|
||||
function (json) {
|
||||
var rel = $.parseJSON(json);
|
||||
if (rel.statusCode == "200") {
|
||||
$(this).alertmsg('ok', rel.message);
|
||||
} else {
|
||||
$(this).alertmsg('error', rel.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function zTreeCheck(e, treeId, treeNode) {
|
||||
var zTree = $.fn.zTree.getZTreeObj(treeId),
|
||||
nodes = zTree.getCheckedNodes(true);
|
||||
var ids = '';
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
ids += ',' + nodes[i].Id;
|
||||
}
|
||||
if (ids.length > 0) { //去掉第一个逗号
|
||||
ids = ids.substr(1);
|
||||
}
|
||||
|
||||
moduleIds = ids;
|
||||
}
|
||||
function zTreeOnClick(event, treeId, treeNode) {
|
||||
var zTree = $.fn.zTree.getZTreeObj(treeId);
|
||||
zTree.checkNode(treeNode, !treeNode.checked, true, true);
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
//@@ sourceURL=lookupMulti.js
|
||||
@*
|
||||
选择多个模块ID,以ids的形式返回
|
||||
*@
|
||||
|
||||
@{
|
||||
ViewBag.Title = "title";
|
||||
Layout = null;
|
||||
}
|
||||
<div class="bjui-pageContent">
|
||||
<input style="display: none" id="userId" value="@ViewBag.UserId"/>
|
||||
<div style="float: left; width: 220px; height: 240px; overflow: auto;" class="table table-bordered">
|
||||
<ul id="lookupTree" class="ztree"></ul>
|
||||
</div>
|
||||
<!--已经选中的列表-->
|
||||
<div style="margin-left: 225px">
|
||||
<ul id="selected" class="ztree"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bjui-pageFooter">
|
||||
<ul>
|
||||
<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
|
||||
<li><button type="button" onclick="save()" class="btn btn-blue" data-icon="check">保存</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var moduleIds;
|
||||
$(document).ready(function () {
|
||||
Init();
|
||||
InitSelected();
|
||||
});
|
||||
function Init() {
|
||||
var setting = {
|
||||
view: {
|
||||
selectedMulti: false
|
||||
},
|
||||
check: {
|
||||
enable: true,
|
||||
chkStyle: "checkbox"
|
||||
},
|
||||
data: {
|
||||
key: {
|
||||
name: 'Name',
|
||||
title: 'Name'
|
||||
},
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: 'Id',
|
||||
pIdKey: 'ParentId',
|
||||
rootPId: 'null'
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onClick: zTreeOnClick,
|
||||
onCheck: zTreeCheck
|
||||
}
|
||||
};
|
||||
$.getJSON('ModuleManager/LoadForTree', function (json) {
|
||||
var zTreeObj = $.fn.zTree.init($('#lookupTree'), setting, json);
|
||||
zTreeObj.expandAll(true);
|
||||
});
|
||||
}
|
||||
|
||||
function InitSelected() {
|
||||
var setting = {
|
||||
|
||||
data: {
|
||||
key: {
|
||||
name: 'Name',
|
||||
title: 'Name'
|
||||
},
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: 'Id',
|
||||
pIdKey: 'ParentId',
|
||||
rootPId: 'null'
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onClick: zTreeOnClick,
|
||||
onCheck: zTreeCheck
|
||||
}
|
||||
};
|
||||
$.post('ModuleManager/LoadForUser', { userId: $('#userId').val() },
|
||||
function (json) {
|
||||
var zTreeObj = $.fn.zTree.init($('#selected'), setting, eval(json));
|
||||
zTreeObj.expandAll(true);
|
||||
});
|
||||
}
|
||||
|
||||
function save() {
|
||||
$.post('ModuleManager/AssignModuleForUser', { userId: $('#userId').val(), moduleIds: moduleIds },
|
||||
function (json) {
|
||||
var rel = $.parseJSON(json);
|
||||
if (rel.statusCode == "200") {
|
||||
$(this).alertmsg('ok', rel.message);
|
||||
} else {
|
||||
$(this).alertmsg('error', rel.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function zTreeCheck(e, treeId, treeNode) {
|
||||
var zTree = $.fn.zTree.getZTreeObj(treeId),
|
||||
nodes = zTree.getCheckedNodes(true);
|
||||
var ids = '';
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
ids += ',' + nodes[i].Id;
|
||||
}
|
||||
if (ids.length > 0) { //去掉第一个逗号
|
||||
ids = ids.substr(1);
|
||||
}
|
||||
|
||||
moduleIds = ids;
|
||||
}
|
||||
function zTreeOnClick(event, treeId, treeNode) {
|
||||
var zTree = $.fn.zTree.getZTreeObj(treeId);
|
||||
zTree.checkNode(treeNode, !treeNode.checked, true, true);
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
//@@ sourceURL=lookupMulti.js
|
||||
</script>
|
@ -1,5 +1,4 @@
|
||||
|
||||
@{
|
||||
@{
|
||||
ViewBag.Title = "title";
|
||||
Layout = null;
|
||||
}
|
||||
@ -8,26 +7,21 @@
|
||||
<form action="/OrgManager/AddOrg" class="pageForm" data-toggle="validate">
|
||||
<table class="table table-condensed table-hover">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center"><h3>* 添加</h3></td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label x90">机构名称:</label>
|
||||
<input type="text" name="Name" id="Name" value=""
|
||||
data-rule="required" size="20">
|
||||
data-rule="required" size="20">
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input id="ParentId" name="ParentId" type="hidden">
|
||||
<input id="ParentId" name="ParentId" type="hidden">
|
||||
<label for="ParentName" class="control-label x90">上级机构:</label>
|
||||
<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>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@ -37,7 +31,6 @@
|
||||
<option value="0">正常</option>
|
||||
<option value="1">禁用</option>
|
||||
</select>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -51,7 +44,6 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
Init();
|
||||
@ -112,4 +104,4 @@
|
||||
zTree.checkNode(treeNode, !treeNode.checked, true, true);
|
||||
event.preventDefault();
|
||||
}
|
||||
</script>
|
||||
</script>
|
@ -8,9 +8,7 @@
|
||||
<form action="/RoleManager/Add" class="pageForm" data-toggle="validate">
|
||||
<table class="table table-condensed table-hover">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center"><h3>* 添加</h3></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
@Html.HiddenFor(m => m.Id)
|
||||
|
@ -36,7 +36,8 @@
|
||||
toolbarItem: 'refresh, |, del',
|
||||
toolbarCustom: '<a href="/RoleManager/Add" class="btn btn-green" data-icon ="plus" ' +
|
||||
'data-toggle="dialog" data-id="dialog-mask" data-mask="true" data-on-close="refreshGrid">添加</a>' +
|
||||
'<button class=" btn-green" onclick="editRole()" data-icon="pencil" type="button">编辑</button>',
|
||||
'<button class=" btn-green" onclick="editRole()" data-icon="pencil" type="button">编辑</button>'+
|
||||
'<button type="button" class="btn btn-green" onclick="openModuleAccess(this)">角色模块</button>',
|
||||
columns: [
|
||||
{
|
||||
name: 'Id',
|
||||
@ -174,5 +175,22 @@
|
||||
$('#@_gridId').datagrid('refresh');
|
||||
// loadDataGrid();
|
||||
}
|
||||
|
||||
//用户模块授权按钮
|
||||
function openModuleAccess(obj) {
|
||||
|
||||
var selected = getSelected(2);
|
||||
if (selected == null) return;
|
||||
|
||||
$(obj).dialog({
|
||||
id: 'accessRoleModule',
|
||||
url: '/ModuleManager/LookupMultiForRole',
|
||||
title: '为角色分配模块',
|
||||
data: {
|
||||
roleid: selected
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//@@ sourceURL=RoleManagerIndex.js
|
||||
</script>
|
||||
|
@ -8,9 +8,7 @@
|
||||
<form action="/UserManager/Add" class="pageForm" data-toggle="validate">
|
||||
<table class="table table-condensed table-hover">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center"><h3>* 添加</h3></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
@Html.HiddenFor(m =>m.CreateTime)
|
||||
|
@ -185,7 +185,7 @@
|
||||
|
||||
$(obj).dialog({
|
||||
id: 'accessUserModule',
|
||||
url: '/ModuleManager/LookupMulti',
|
||||
url: '/ModuleManager/LookupMultiForUser',
|
||||
title: '为用户分配模块',
|
||||
data: {
|
||||
userId: selected
|
||||
|
@ -1,34 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenAuth.Repository
|
||||
{
|
||||
public class RelevanceRepository :BaseRepository<Relevance>, IRelevanceRepository
|
||||
public class RelevanceRepository : BaseRepository<Relevance>, IRelevanceRepository
|
||||
{
|
||||
|
||||
public void DeleteBy(string key,params int[] firstIds)
|
||||
public void DeleteBy(string key, params int[] firstIds)
|
||||
{
|
||||
Delete(u => firstIds.Contains(u.FirstId) && u.Key == key);
|
||||
}
|
||||
|
||||
public void AddRelevance(string key, Dictionary<int, int> ids)
|
||||
public void AddRelevance(string key, ILookup<int, int> idMaps)
|
||||
{
|
||||
foreach (var roleid in ids)
|
||||
foreach (var sameVals in idMaps)
|
||||
{
|
||||
Add(new Relevance
|
||||
foreach (var value in sameVals)
|
||||
{
|
||||
Key = key,
|
||||
FirstId = roleid.Key,
|
||||
SecondId = roleid.Value,
|
||||
OperateTime = DateTime.Now
|
||||
});
|
||||
Add(new Relevance
|
||||
{
|
||||
Key = key,
|
||||
FirstId = sameVals.Key,
|
||||
SecondId = value,
|
||||
OperateTime = DateTime.Now
|
||||
});
|
||||
}
|
||||
}
|
||||
Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user