重构代码:移除JObject参数使用[FromQuery]string type
This commit is contained in:
parent
8dd846824c
commit
3e74b7bf07
|
@ -2,7 +2,6 @@
|
|||
using Bootstrap.DataAccess;
|
||||
using Longbow.Web.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -13,93 +12,91 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// </summary>
|
||||
[Route("api/[controller]")]
|
||||
public class GroupsController : Controller
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public QueryData<Group> Get(QueryGroupOption value)
|
||||
{
|
||||
return value.RetrieveData();
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}")]
|
||||
public Group Get(int id)
|
||||
{
|
||||
return GroupHelper.RetrieveGroups().FirstOrDefault(t => t.Id == id);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
[HttpPost]
|
||||
public bool Post([FromBody]Group value)
|
||||
{
|
||||
return GroupHelper.SaveGroup(value);
|
||||
}
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public QueryData<Group> Get(QueryGroupOption value)
|
||||
{
|
||||
return value.RetrieveData();
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}")]
|
||||
public Group Get(int id)
|
||||
{
|
||||
return GroupHelper.RetrieveGroups().FirstOrDefault(t => t.Id == id);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
[HttpPost]
|
||||
public bool Post([FromBody]Group value)
|
||||
{
|
||||
return GroupHelper.SaveGroup(value);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
[HttpDelete]
|
||||
public bool Delete([FromBody]IEnumerable<int> value)
|
||||
{
|
||||
return GroupHelper.DeleteGroup(value);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{id}")]
|
||||
public IEnumerable<Group> Post(int id, [FromBody]JObject value)
|
||||
{
|
||||
var ret = new List<Group>();
|
||||
dynamic json = value;
|
||||
switch ((string)json.type)
|
||||
{
|
||||
case "user":
|
||||
ret = GroupHelper.RetrieveGroupsByUserId(id).ToList();
|
||||
break;
|
||||
case "role":
|
||||
ret = GroupHelper.RetrieveGroupsByRoleId(id).ToList();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
public bool Put(int id, [FromBody]JObject value)
|
||||
{
|
||||
var ret = false;
|
||||
dynamic json = value;
|
||||
string groupIds = json.groupIds;
|
||||
switch ((string)json.type)
|
||||
{
|
||||
case "user":
|
||||
ret = GroupHelper.SaveGroupsByUserId(id, groupIds);
|
||||
break;
|
||||
case "role":
|
||||
ret = GroupHelper.SaveGroupsByRoleId(id, groupIds);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
public bool Delete([FromBody]IEnumerable<int> value)
|
||||
{
|
||||
return GroupHelper.DeleteGroup(value);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{id}")]
|
||||
public IEnumerable<Group> Post(int id, [FromQuery]string type)
|
||||
{
|
||||
var ret = new List<Group>();
|
||||
switch (type)
|
||||
{
|
||||
case "user":
|
||||
ret = GroupHelper.RetrieveGroupsByUserId(id).ToList();
|
||||
break;
|
||||
case "role":
|
||||
ret = GroupHelper.RetrieveGroupsByRoleId(id).ToList();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="groupIds"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
public bool Put(int id, [FromBody]IEnumerable<int> groupIds, [FromQuery]string type)
|
||||
{
|
||||
var ret = false;
|
||||
switch (type)
|
||||
{
|
||||
case "user":
|
||||
ret = GroupHelper.SaveGroupsByUserId(id, groupIds);
|
||||
break;
|
||||
case "role":
|
||||
ret = GroupHelper.SaveGroupsByRoleId(id, groupIds);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ using Bootstrap.DataAccess;
|
|||
using Bootstrap.Security;
|
||||
using Longbow.Web.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -50,11 +49,10 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{id}")]
|
||||
public IEnumerable<BootstrapMenu> Post(int id, [FromBody]JObject value)
|
||||
public IEnumerable<BootstrapMenu> Post(int id, [FromQuery]string type)
|
||||
{
|
||||
var ret = new List<BootstrapMenu>();
|
||||
dynamic json = value;
|
||||
switch ((string)json.type)
|
||||
switch (type)
|
||||
{
|
||||
case "role":
|
||||
ret = MenuHelper.RetrieveMenusByRoleId(id).ToList();
|
||||
|
|
|
@ -25,19 +25,17 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
{
|
||||
return value.RetrieveData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 通过指定ID获得所有角色集合
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="id">用户ID/部门ID/菜单ID</param>
|
||||
/// <param name="type">类型</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{id}")]
|
||||
public IEnumerable<Role> Post(int id, [FromBody]JObject value)
|
||||
public IEnumerable<Role> Post(int id, [FromQuery]string type)
|
||||
{
|
||||
var ret = new List<Role>();
|
||||
dynamic json = value;
|
||||
switch ((string)json.type)
|
||||
switch (type)
|
||||
{
|
||||
case "user":
|
||||
ret = RoleHelper.RetrieveRolesByUserId(id).ToList();
|
||||
|
@ -53,18 +51,18 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>根据GroupID获取
|
||||
/// <summary>
|
||||
/// 根据GroupID获取
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="roleIds"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
public bool Put(int id, [FromBody]JObject value)
|
||||
public bool Put(int id, [FromBody]IEnumerable<int> roleIds, [FromQuery]string type)
|
||||
{
|
||||
var ret = false;
|
||||
dynamic json = value;
|
||||
string roleIds = json.roleIds;
|
||||
switch ((string)json.type)
|
||||
switch (type)
|
||||
{
|
||||
case "user":
|
||||
ret = RoleHelper.SaveRolesByUserId(id, roleIds);
|
||||
|
|
|
@ -3,7 +3,6 @@ using Bootstrap.DataAccess;
|
|||
using Longbow.Web.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -53,14 +52,13 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{id}")]
|
||||
public IEnumerable<User> Post(int id, [FromBody]JObject value)
|
||||
public IEnumerable<User> Post(int id, [FromQuery]string type)
|
||||
{
|
||||
var ret = new List<User>();
|
||||
dynamic json = value;
|
||||
switch ((string)json.type)
|
||||
switch (type)
|
||||
{
|
||||
case "role":
|
||||
ret = UserHelper.RetrieveUsersByRoleId(id).ToList();
|
||||
|
@ -89,15 +87,14 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="userIds"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
public bool Put(int id, [FromBody]JObject value)
|
||||
public bool Put(int id, [FromBody]IEnumerable<int> userIds, [FromQuery]string type)
|
||||
{
|
||||
var ret = false;
|
||||
dynamic json = value;
|
||||
string userIds = json.userIds;
|
||||
switch ((string)json.type)
|
||||
switch (type)
|
||||
{
|
||||
case "role":
|
||||
ret = UserHelper.SaveUsersByRoleId(id, userIds);
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
nestMenu: function (callback) {
|
||||
var $this = $(this);
|
||||
$.bc({
|
||||
id: 0, url: Menu.url, data: { type: "user" }, method: "post",
|
||||
id: 0, url: Menu.url, query: { type: "user" }, method: "post",
|
||||
callback: function (result) {
|
||||
var html = "";
|
||||
if ($.isArray(result)) html = cascadeMenu(result);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
events: {
|
||||
'#btn_assignRole': function (row) {
|
||||
$.bc({
|
||||
id: row.Id, url: Role.url, data: { type: "group" }, method: "post",
|
||||
id: row.Id, url: Role.url, query: { type: "group" }, method: "post",
|
||||
callback: function (result) {
|
||||
var htmlTemplate = this.htmlTemplate;
|
||||
var html = $.map(result, function (element, index) {
|
||||
|
@ -33,7 +33,7 @@
|
|||
},
|
||||
'#btn_assignUser': function (row) {
|
||||
$.bc({
|
||||
id: row.Id, url: User.url, data: { type: "group" }, method: "post",
|
||||
id: row.Id, url: User.url, query: { type: "group" }, method: "post",
|
||||
callback: function (result) {
|
||||
var htmlTemplate = this.htmlTemplate;
|
||||
var html = $.map(result, function (element, index) {
|
||||
|
@ -51,15 +51,15 @@
|
|||
var groupId = row.Id;
|
||||
var roleIds = $dialogRole.find('input:checked').map(function (index, element) {
|
||||
return $(element).val();
|
||||
}).toArray().join(',');
|
||||
$.bc({ id: groupId, url: Role.url, method: "put", data: { type: "group", roleIds: roleIds }, title: Role.title, modal: '#dialogRole' });
|
||||
}).toArray();
|
||||
$.bc({ id: groupId, url: Role.url, method: "put", data: roleIds, query: { type: "group" }, title: Role.title, modal: '#dialogRole' });
|
||||
},
|
||||
'#btnSubmitUser': function (row) {
|
||||
var groupId = row.Id;
|
||||
var userIds = $dialogUser.find(':checked').map(function (index, element) {
|
||||
return $(element).val();
|
||||
}).toArray().join(',');
|
||||
$.bc({ id: groupId, url: User.url, method: "put", data: { type: "group", userIds: userIds }, title: User.title, modal: '#dialogUser' });
|
||||
}).toArray();
|
||||
$.bc({ id: groupId, url: User.url, method: "put", data: userIds, query: { type: "group" }, title: User.title, modal: '#dialogUser' });
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -143,9 +143,16 @@
|
|||
|
||||
|
||||
var data = options.method === 'get' ? options.data : JSON.stringify(options.data);
|
||||
var url = options.id !== '' ? $.formatUrl(options.url) + '/' + options.id : $.formatUrl(options.url);
|
||||
var url = options.id !== '' ? options.url + '/' + options.id : options.url;
|
||||
if (options.query) {
|
||||
var qs = [];
|
||||
for (var key in options.query) {
|
||||
qs.push($.format("{0}={1}", key, options.query[key]));
|
||||
}
|
||||
url = url + "?" + qs.join('&');
|
||||
}
|
||||
var ajaxSettings = {
|
||||
url: url,
|
||||
url: $.formatUrl(url),
|
||||
data: data,
|
||||
method: options.method,
|
||||
contentType: options.contentType,
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
events: {
|
||||
'#btn_assignRole': function (row) {
|
||||
$.bc({
|
||||
id: row.Id, url: Role.url, data: { type: "menu" }, method: "post",
|
||||
id: row.Id, url: Role.url, query: { type: "menu" }, method: "post",
|
||||
callback: function (result) {
|
||||
var htmlTemplate = this.htmlTemplate;
|
||||
var html = $.map(result, function (element, index) {
|
||||
|
@ -60,8 +60,8 @@
|
|||
var menuId = row.Id;
|
||||
var roleIds = $dialogRole.find('input:checked').map(function (index, element) {
|
||||
return $(element).val();
|
||||
}).toArray().join(',');
|
||||
$.bc({ id: menuId, url: Role.url, method: "put", data: { type: "menu", roleIds: roleIds }, title: Role.title, modal: '#dialogRole' });
|
||||
}).toArray();
|
||||
$.bc({ id: menuId, url: Role.url, method: "put", data: roleIds, query: { type: "menu" }, title: Role.title, modal: '#dialogRole' });
|
||||
}
|
||||
},
|
||||
callback: function (result) {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
events: {
|
||||
'#btn_assignUser': function (row) {
|
||||
$.bc({
|
||||
id: row.Id, url: User.url, data: { type: "role" }, method: "post",
|
||||
id: row.Id, url: User.url, query: { type: "role" }, method: "post",
|
||||
callback: function (result) {
|
||||
var htmlTemplate = this.htmlTemplate;
|
||||
var html = $.map(result, function (element, index) {
|
||||
|
@ -39,7 +39,7 @@
|
|||
},
|
||||
'#btn_assignGroup': function (row) {
|
||||
$.bc({
|
||||
id: row.Id, url: Group.url, data: { type: "role" }, method: "post",
|
||||
id: row.Id, url: Group.url, query: { type: "role" }, method: "post",
|
||||
callback: function (result) {
|
||||
var htmlTemplate = this.htmlTemplate;
|
||||
var html = $.map(result, function (element, index) {
|
||||
|
@ -55,7 +55,7 @@
|
|||
},
|
||||
'#btn_assignMenu': function (row) {
|
||||
$.bc({
|
||||
id: row.Id, url: Menu.url, data: { type: "role" }, method: "post",
|
||||
id: row.Id, url: Menu.url, query: { type: "role" }, method: "post",
|
||||
callback: function (result) {
|
||||
$dialogMenuHeader.text($.format('{0}-菜单授权窗口', row.RoleName));
|
||||
$btnSubmitMenu.data('type', 'menu');
|
||||
|
@ -75,15 +75,15 @@
|
|||
var roleId = row.Id;
|
||||
var userIds = $dialogUser.find(':checked').map(function (index, element) {
|
||||
return $(element).val();
|
||||
}).toArray().join(',');
|
||||
$.bc({ id: roleId, url: User.url, method: "put", data: { type: "role", userIds: userIds }, modal: '#dialogUser', title: User.title });
|
||||
}).toArray();
|
||||
$.bc({ id: roleId, url: User.url, method: "put", data: userIds, query: { type: "role" }, modal: '#dialogUser', title: User.title });
|
||||
},
|
||||
'#btnSubmitGroup': function (row) {
|
||||
var roleId = row.Id;
|
||||
var groupIds = $dialogGroup.find(':checked').map(function (index, element) {
|
||||
return $(element).val();
|
||||
}).toArray().join(',');
|
||||
$.bc({ id: roleId, url: Group.url, method: "put", data: { type: "role", groupIds: groupIds }, modal: '#dialogGroup', title: Group.title });
|
||||
}).toArray();
|
||||
$.bc({ id: roleId, url: Group.url, method: "put", data: groupIds, query: { type: "role" }, modal: '#dialogGroup', title: Group.title });
|
||||
},
|
||||
'#btnSubmitMenu': function (row) {
|
||||
var roleId = row.Id;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
events: {
|
||||
'#btn_assignRole': function (row) {
|
||||
$.bc({
|
||||
id: row.Id, url: Role.url, data: { type: "user" }, method: "post",
|
||||
id: row.Id, url: Role.url, query: { type: "user" }, method: "post",
|
||||
callback: function (result) {
|
||||
var htmlTemplate = this.htmlTemplate;
|
||||
var html = $.map(result, function (element, index) {
|
||||
|
@ -35,7 +35,7 @@
|
|||
},
|
||||
'#btn_assignGroup': function (row) {
|
||||
$.bc({
|
||||
id: row.Id, url: Group.url, data: { type: "user" }, method: "post",
|
||||
id: row.Id, url: Group.url, query: { type: "user" }, method: "post",
|
||||
callback: function (result) {
|
||||
var htmlTemplate = this.htmlTemplate;
|
||||
var html = $.map(result, function (element, index) {
|
||||
|
@ -53,15 +53,15 @@
|
|||
var userId = row.Id;
|
||||
var roleIds = $dialogRole.find(':checked').map(function (index, element) {
|
||||
return $(element).val();
|
||||
}).toArray().join(',');
|
||||
$.bc({ id: userId, url: Role.url, method: 'put', data: { type: "user", roleIds: roleIds }, title: Role.title, modal: '#dialogRole' });
|
||||
}).toArray();
|
||||
$.bc({ id: userId, url: Role.url, method: 'put', data: roleIds, query: { type: "user" }, title: Role.title, modal: '#dialogRole' });
|
||||
},
|
||||
'#btnSubmitGroup': function (row) {
|
||||
var userId = row.Id;
|
||||
var groupIds = $dialogGroup.find(':checked').map(function (index, element) {
|
||||
return $(element).val();
|
||||
}).toArray().join(',');
|
||||
$.bc({ id: userId, url: Group.url, method: 'put', data: { type: "user", groupIds: groupIds }, title: Group.title, modal: '#dialogGroup' });
|
||||
}).toArray();
|
||||
$.bc({ id: userId, url: Group.url, method: 'put', data: groupIds, query: { type: "user" }, title: Group.title, modal: '#dialogGroup' });
|
||||
}
|
||||
},
|
||||
callback: function (data) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using Bootstrap.Security;
|
||||
using Longbow.Cache;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -18,13 +17,13 @@ namespace Bootstrap.DataAccess
|
|||
/// <param name="menuIds"></param>
|
||||
/// <param name="dictIds"></param>
|
||||
/// <param name="cacheKey"></param>
|
||||
internal static void ClearCache(string roleIds = null, string userIds = null, string groupIds = null, IEnumerable<int> menuIds = null, string dictIds = null, string cacheKey = null)
|
||||
internal static void ClearCache(IEnumerable<int> roleIds = null, IEnumerable<int> userIds = null, IEnumerable<int> groupIds = null, IEnumerable<int> menuIds = null, string dictIds = null, string cacheKey = null)
|
||||
{
|
||||
var cacheKeys = new List<string>();
|
||||
var corsKeys = new List<string>();
|
||||
if (roleIds != null)
|
||||
{
|
||||
roleIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(id =>
|
||||
roleIds.ToList().ForEach(id =>
|
||||
{
|
||||
cacheKeys.Add(string.Format("{0}-{1}", UserHelper.RetrieveUsersByRoleIdDataKey, id));
|
||||
cacheKeys.Add(string.Format("{0}-{1}", GroupHelper.RetrieveGroupsByRoleIdDataKey, id));
|
||||
|
@ -37,7 +36,7 @@ namespace Bootstrap.DataAccess
|
|||
}
|
||||
if (userIds != null)
|
||||
{
|
||||
userIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(id =>
|
||||
userIds.ToList().ForEach(id =>
|
||||
{
|
||||
cacheKeys.Add(string.Format("{0}-{1}", RoleHelper.RetrieveRolesByUserIdDataKey, id));
|
||||
cacheKeys.Add(string.Format("{0}-{1}", GroupHelper.RetrieveGroupsByUserIdDataKey, id));
|
||||
|
@ -50,7 +49,7 @@ namespace Bootstrap.DataAccess
|
|||
}
|
||||
if (groupIds != null)
|
||||
{
|
||||
groupIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(id =>
|
||||
groupIds.ToList().ForEach(id =>
|
||||
{
|
||||
cacheKeys.Add(string.Format("{0}-{1}", RoleHelper.RetrieveRolesByGroupIdDataKey, id));
|
||||
cacheKeys.Add(string.Format("{0}-{1}", UserHelper.RetrieveUsersByGroupIdDataKey, id));
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace Bootstrap.DataAccess
|
|||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids));
|
||||
ret = DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd) == -1;
|
||||
}
|
||||
CacheCleanUtility.ClearCache(groupIds: ids);
|
||||
CacheCleanUtility.ClearCache(groupIds: value);
|
||||
return ret;
|
||||
}
|
||||
/// <summary>
|
||||
|
@ -82,7 +82,7 @@ namespace Bootstrap.DataAccess
|
|||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Description", DBAccessFactory.ToDBValue(p.Description)));
|
||||
ret = DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd) == 1;
|
||||
}
|
||||
CacheCleanUtility.ClearCache(groupIds: p.Id == 0 ? string.Empty : p.Id.ToString());
|
||||
CacheCleanUtility.ClearCache(groupIds: p.Id == 0 ? new List<int>() : new List<int>() { p.Id });
|
||||
return ret;
|
||||
}
|
||||
/// <summary>
|
||||
|
@ -122,14 +122,14 @@ namespace Bootstrap.DataAccess
|
|||
/// <param name="id"></param>
|
||||
/// <param name="groupIds"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SaveGroupsByUserId(int id, string groupIds)
|
||||
public static bool SaveGroupsByUserId(int id, IEnumerable<int> groupIds)
|
||||
{
|
||||
var ret = false;
|
||||
DataTable dt = new DataTable();
|
||||
dt.Columns.Add("UserID", typeof(int));
|
||||
dt.Columns.Add("GroupID", typeof(int));
|
||||
//判断用户是否选定角色
|
||||
if (!string.IsNullOrEmpty(groupIds)) groupIds.Split(',').ToList().ForEach(groupId => dt.Rows.Add(id, groupId));
|
||||
groupIds.ToList().ForEach(groupId => dt.Rows.Add(id, groupId));
|
||||
using (TransactionPackage transaction = DBAccessManager.SqlDBAccess.BeginTransaction())
|
||||
{
|
||||
try
|
||||
|
@ -152,7 +152,7 @@ namespace Bootstrap.DataAccess
|
|||
transaction.CommitTransaction();
|
||||
}
|
||||
}
|
||||
CacheCleanUtility.ClearCache(groupIds: groupIds, userIds: id.ToString());
|
||||
CacheCleanUtility.ClearCache(groupIds: groupIds, userIds: new List<int>() { id });
|
||||
ret = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -199,13 +199,13 @@ namespace Bootstrap.DataAccess
|
|||
/// <param name="id"></param>
|
||||
/// <param name="groupIds"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SaveGroupsByRoleId(int id, string groupIds)
|
||||
public static bool SaveGroupsByRoleId(int id, IEnumerable<int> groupIds)
|
||||
{
|
||||
bool ret = false;
|
||||
DataTable dt = new DataTable();
|
||||
dt.Columns.Add("GroupID", typeof(int));
|
||||
dt.Columns.Add("RoleID", typeof(int));
|
||||
if (!string.IsNullOrEmpty(groupIds)) groupIds.Split(',').ToList().ForEach(groupId => dt.Rows.Add(groupId, id));
|
||||
groupIds.ToList().ForEach(groupId => dt.Rows.Add(groupId, id));
|
||||
using (TransactionPackage transaction = DBAccessManager.SqlDBAccess.BeginTransaction())
|
||||
{
|
||||
try
|
||||
|
@ -227,7 +227,7 @@ namespace Bootstrap.DataAccess
|
|||
transaction.CommitTransaction();
|
||||
}
|
||||
}
|
||||
CacheCleanUtility.ClearCache(groupIds: groupIds, roleIds: id.ToString());
|
||||
CacheCleanUtility.ClearCache(groupIds: groupIds, roleIds: new List<int>() { id });
|
||||
ret = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -130,7 +130,7 @@ namespace Bootstrap.DataAccess
|
|||
transaction.CommitTransaction();
|
||||
}
|
||||
}
|
||||
CacheCleanUtility.ClearCache(menuIds: menuIds, roleIds: id.ToString());
|
||||
CacheCleanUtility.ClearCache(menuIds: menuIds, roleIds: new List<int>() { id });
|
||||
ret = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -52,14 +52,14 @@ namespace Bootstrap.DataAccess
|
|||
/// <param name="id"></param>
|
||||
/// <param name="roleIds"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SaveRolesByUserId(int id, string roleIds)
|
||||
public static bool SaveRolesByUserId(int id, IEnumerable<int> roleIds)
|
||||
{
|
||||
var ret = false;
|
||||
DataTable dt = new DataTable();
|
||||
dt.Columns.Add("UserID", typeof(int));
|
||||
dt.Columns.Add("RoleID", typeof(int));
|
||||
//判断用户是否选定角色
|
||||
if (!string.IsNullOrEmpty(roleIds)) roleIds.Split(',').ToList().ForEach(roleId => dt.Rows.Add(id, roleId));
|
||||
roleIds.ToList().ForEach(roleId => dt.Rows.Add(id, roleId));
|
||||
using (TransactionPackage transaction = DBAccessManager.SqlDBAccess.BeginTransaction())
|
||||
{
|
||||
try
|
||||
|
@ -83,7 +83,7 @@ namespace Bootstrap.DataAccess
|
|||
}
|
||||
transaction.CommitTransaction();
|
||||
}
|
||||
CacheCleanUtility.ClearCache(userIds: id.ToString(), roleIds: roleIds);
|
||||
CacheCleanUtility.ClearCache(userIds: new List<int>() { id }, roleIds: roleIds);
|
||||
ret = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -136,7 +136,7 @@ namespace Bootstrap.DataAccess
|
|||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids));
|
||||
ret = DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd) == -1;
|
||||
}
|
||||
CacheCleanUtility.ClearCache(roleIds: ids);
|
||||
CacheCleanUtility.ClearCache(roleIds: value);
|
||||
return ret;
|
||||
}
|
||||
/// <summary>
|
||||
|
@ -159,7 +159,7 @@ namespace Bootstrap.DataAccess
|
|||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Description", DBAccessFactory.ToDBValue(p.Description)));
|
||||
ret = DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd) == 1;
|
||||
}
|
||||
CacheCleanUtility.ClearCache(roleIds: p.Id == 0 ? string.Empty : p.Id.ToString());
|
||||
CacheCleanUtility.ClearCache(roleIds: p.Id == 0 ? new List<int>() : new List<int> { p.Id });
|
||||
return ret;
|
||||
}
|
||||
/// <summary>
|
||||
|
@ -193,14 +193,20 @@ namespace Bootstrap.DataAccess
|
|||
}, RetrieveRolesByMenuIdDataKey);
|
||||
return ret;
|
||||
}
|
||||
public static bool SavaRolesByMenuId(int id, string roleIds)
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="roleIds"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SavaRolesByMenuId(int id, IEnumerable<int> roleIds)
|
||||
{
|
||||
var ret = false;
|
||||
DataTable dt = new DataTable();
|
||||
dt.Columns.Add("NavigationID", typeof(int));
|
||||
dt.Columns.Add("RoleID", typeof(int));
|
||||
//判断用户是否选定角色
|
||||
if (!string.IsNullOrEmpty(roleIds)) roleIds.Split(',').ToList().ForEach(roleId => dt.Rows.Add(id, roleId));
|
||||
roleIds.ToList().ForEach(roleId => dt.Rows.Add(id, roleId));
|
||||
using (TransactionPackage transaction = DBAccessManager.SqlDBAccess.BeginTransaction())
|
||||
{
|
||||
try
|
||||
|
@ -271,14 +277,14 @@ namespace Bootstrap.DataAccess
|
|||
/// <param name="id"></param>
|
||||
/// <param name="roleIds"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SaveRolesByGroupId(int id, string roleIds)
|
||||
public static bool SaveRolesByGroupId(int id, IEnumerable<int> roleIds)
|
||||
{
|
||||
var ret = false;
|
||||
//构造表格
|
||||
DataTable dt = new DataTable();
|
||||
dt.Columns.Add("RoleID", typeof(int));
|
||||
dt.Columns.Add("GroupID", typeof(int));
|
||||
if (!string.IsNullOrEmpty(roleIds)) roleIds.Split(',').ToList().ForEach(roleId => dt.Rows.Add(roleId, id));
|
||||
roleIds.ToList().ForEach(roleId => dt.Rows.Add(roleId, id));
|
||||
using (TransactionPackage transaction = DBAccessManager.SqlDBAccess.BeginTransaction())
|
||||
{
|
||||
try
|
||||
|
@ -301,7 +307,7 @@ namespace Bootstrap.DataAccess
|
|||
transaction.CommitTransaction();
|
||||
}
|
||||
}
|
||||
CacheCleanUtility.ClearCache(roleIds: roleIds, groupIds: id.ToString());
|
||||
CacheCleanUtility.ClearCache(roleIds: roleIds, groupIds: new List<int>() { id });
|
||||
ret = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace Bootstrap.DataAccess
|
|||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids));
|
||||
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
|
||||
}
|
||||
CacheCleanUtility.ClearCache(userIds: ids);
|
||||
CacheCleanUtility.ClearCache(userIds: value);
|
||||
ret = true;
|
||||
return ret;
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ namespace Bootstrap.DataAccess
|
|||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@description", p.Description));
|
||||
ret = DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd) == -1;
|
||||
}
|
||||
CacheCleanUtility.ClearCache(userIds: p.Id == 0 ? string.Empty : p.Id.ToString());
|
||||
CacheCleanUtility.ClearCache(userIds: p.Id == 0 ? new List<int>() : new List<int>() { p.Id });
|
||||
return ret;
|
||||
}
|
||||
/// <summary>
|
||||
|
@ -142,7 +142,7 @@ namespace Bootstrap.DataAccess
|
|||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@approvedBy", approvedBy));
|
||||
ret = DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd) == 1;
|
||||
}
|
||||
CacheCleanUtility.ClearCache(userIds: id.ToString());
|
||||
CacheCleanUtility.ClearCache(userIds: new List<int>() { id });
|
||||
return ret;
|
||||
}
|
||||
/// <summary>
|
||||
|
@ -188,7 +188,7 @@ namespace Bootstrap.DataAccess
|
|||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@rejectedReason", "未填写"));
|
||||
ret = DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd) == -1;
|
||||
}
|
||||
CacheCleanUtility.ClearCache(userIds: id.ToString());
|
||||
CacheCleanUtility.ClearCache(userIds: new List<int>() { id });
|
||||
return ret;
|
||||
}
|
||||
/// <summary>
|
||||
|
@ -227,13 +227,13 @@ namespace Bootstrap.DataAccess
|
|||
/// <param name="id">角色ID</param>
|
||||
/// <param name="userIds">用户ID数组</param>
|
||||
/// <returns></returns>
|
||||
public static bool SaveUsersByRoleId(int id, string userIds)
|
||||
public static bool SaveUsersByRoleId(int id, IEnumerable<int> userIds)
|
||||
{
|
||||
bool ret = false;
|
||||
DataTable dt = new DataTable();
|
||||
dt.Columns.Add("RoleID", typeof(int));
|
||||
dt.Columns.Add("UserID", typeof(int));
|
||||
if (!string.IsNullOrEmpty(userIds)) userIds.Split(',').ToList().ForEach(userId => dt.Rows.Add(id, userId));
|
||||
userIds.ToList().ForEach(userId => dt.Rows.Add(id, userId));
|
||||
using (TransactionPackage transaction = DBAccessManager.SqlDBAccess.BeginTransaction())
|
||||
{
|
||||
try
|
||||
|
@ -254,7 +254,7 @@ namespace Bootstrap.DataAccess
|
|||
transaction.CommitTransaction();
|
||||
}
|
||||
}
|
||||
CacheCleanUtility.ClearCache(userIds: userIds, roleIds: id.ToString());
|
||||
CacheCleanUtility.ClearCache(userIds: userIds, roleIds: new List<int>() { id });
|
||||
ret = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -301,13 +301,13 @@ namespace Bootstrap.DataAccess
|
|||
/// <param name="id">GroupID</param>
|
||||
/// <param name="userIds">用户ID数组</param>
|
||||
/// <returns></returns>
|
||||
public static bool SaveUsersByGroupId(int id, string userIds)
|
||||
public static bool SaveUsersByGroupId(int id, IEnumerable<int> userIds)
|
||||
{
|
||||
bool ret = false;
|
||||
DataTable dt = new DataTable();
|
||||
dt.Columns.Add("UserID", typeof(int));
|
||||
dt.Columns.Add("GroupID", typeof(int));
|
||||
if (!string.IsNullOrEmpty(userIds)) userIds.Split(',').ToList().ForEach(userId => dt.Rows.Add(userId, id));
|
||||
userIds.ToList().ForEach(userId => dt.Rows.Add(userId, id));
|
||||
using (TransactionPackage transaction = DBAccessManager.SqlDBAccess.BeginTransaction())
|
||||
{
|
||||
try
|
||||
|
@ -328,7 +328,7 @@ namespace Bootstrap.DataAccess
|
|||
transaction.CommitTransaction();
|
||||
}
|
||||
}
|
||||
CacheCleanUtility.ClearCache(userIds: userIds, groupIds: id.ToString());
|
||||
CacheCleanUtility.ClearCache(userIds: userIds, groupIds: new List<int>() { id });
|
||||
ret = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
Loading…
Reference in New Issue