From 2e2d8c78e2c1241bb34b04ce143fbae139608fe9 Mon Sep 17 00:00:00 2001 From: Argo-MacBookPro Date: Fri, 8 Jun 2018 12:54:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9BUG=EF=BC=9A=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/Controllers/Api/DictsController.cs | 3 ++- Bootstrap.Admin/Controllers/Api/GroupsController.cs | 2 +- Bootstrap.Admin/Controllers/Api/MenusController.cs | 2 +- Bootstrap.Admin/Controllers/Api/RolesController.cs | 2 +- Bootstrap.Admin/Controllers/Api/UsersController.cs | 2 +- Bootstrap.DataAccess/DictHelper.cs | 6 +++--- Bootstrap.DataAccess/GroupHelper.cs | 4 ++-- Bootstrap.DataAccess/LogHelper.cs | 6 +++--- Bootstrap.DataAccess/MenuHelper.cs | 6 +++--- Bootstrap.DataAccess/RoleHelper.cs | 6 +++--- Bootstrap.DataAccess/UserHelper.cs | 6 +++--- 11 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Bootstrap.Admin/Controllers/Api/DictsController.cs b/Bootstrap.Admin/Controllers/Api/DictsController.cs index f870aee7..bc9dc27a 100644 --- a/Bootstrap.Admin/Controllers/Api/DictsController.cs +++ b/Bootstrap.Admin/Controllers/Api/DictsController.cs @@ -4,6 +4,7 @@ using Bootstrap.Security; using Longbow.Web.Mvc; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; namespace Bootstrap.Admin.Controllers.Api { @@ -38,7 +39,7 @@ namespace Bootstrap.Admin.Controllers.Api /// [HttpDelete] [Authorize(Roles = "Administrators")] - public object Delete(string value) + public object Delete(IEnumerable value) { var result = DictHelper.DeleteDict(value); return new { result, msg = result ? "成功!" : "失败" }; diff --git a/Bootstrap.Admin/Controllers/Api/GroupsController.cs b/Bootstrap.Admin/Controllers/Api/GroupsController.cs index 0dbaa032..9e69d2f2 100644 --- a/Bootstrap.Admin/Controllers/Api/GroupsController.cs +++ b/Bootstrap.Admin/Controllers/Api/GroupsController.cs @@ -48,7 +48,7 @@ namespace Bootstrap.Admin.Controllers.Api /// /// [HttpDelete] - public bool Delete(string value) + public bool Delete([FromBody]IEnumerable value) { return GroupHelper.DeleteGroup(value); } diff --git a/Bootstrap.Admin/Controllers/Api/MenusController.cs b/Bootstrap.Admin/Controllers/Api/MenusController.cs index b1eee41b..2028df2f 100644 --- a/Bootstrap.Admin/Controllers/Api/MenusController.cs +++ b/Bootstrap.Admin/Controllers/Api/MenusController.cs @@ -39,7 +39,7 @@ namespace Bootstrap.Admin.Controllers.Api /// /// [HttpDelete] - public bool Delete(string value) + public bool Delete([FromBody]IEnumerable value) { return MenuHelper.DeleteMenu(value); } diff --git a/Bootstrap.Admin/Controllers/Api/RolesController.cs b/Bootstrap.Admin/Controllers/Api/RolesController.cs index 396dad82..dc7e600d 100644 --- a/Bootstrap.Admin/Controllers/Api/RolesController.cs +++ b/Bootstrap.Admin/Controllers/Api/RolesController.cs @@ -94,7 +94,7 @@ namespace Bootstrap.Admin.Controllers.Api /// /// [HttpDelete] - public bool Delete(string value) + public bool Delete([FromBody]IEnumerable value) { return RoleHelper.DeleteRole(value); } diff --git a/Bootstrap.Admin/Controllers/Api/UsersController.cs b/Bootstrap.Admin/Controllers/Api/UsersController.cs index 91707967..b7477cf8 100644 --- a/Bootstrap.Admin/Controllers/Api/UsersController.cs +++ b/Bootstrap.Admin/Controllers/Api/UsersController.cs @@ -131,7 +131,7 @@ namespace Bootstrap.Admin.Controllers.Api /// /// [HttpDelete] - public bool Delete(string value) + public bool Delete([FromBody]IEnumerable value) { return UserHelper.DeleteUser(value); } diff --git a/Bootstrap.DataAccess/DictHelper.cs b/Bootstrap.DataAccess/DictHelper.cs index 556d3322..34e06283 100644 --- a/Bootstrap.DataAccess/DictHelper.cs +++ b/Bootstrap.DataAccess/DictHelper.cs @@ -30,14 +30,14 @@ namespace Bootstrap.DataAccess /// /// 删除字典中的数据 /// - /// 需要删除的IDs + /// 需要删除的IDs /// - public static bool DeleteDict(string ids) + public static bool DeleteDict(IEnumerable value) { - if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return false; var ret = false; try { + var ids = string.Join(",", value); string sql = string.Format(CultureInfo.InvariantCulture, "Delete from Dicts where ID in ({0})", ids); using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) { diff --git a/Bootstrap.DataAccess/GroupHelper.cs b/Bootstrap.DataAccess/GroupHelper.cs index 25674040..12fe449b 100644 --- a/Bootstrap.DataAccess/GroupHelper.cs +++ b/Bootstrap.DataAccess/GroupHelper.cs @@ -55,12 +55,12 @@ namespace Bootstrap.DataAccess /// 删除群组信息 /// /// - public static bool DeleteGroup(string ids) + public static bool DeleteGroup(IEnumerable value) { - if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return false; bool ret = false; try { + var ids = string.Join(",", value); using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_DeleteGroups")) { cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids)); diff --git a/Bootstrap.DataAccess/LogHelper.cs b/Bootstrap.DataAccess/LogHelper.cs index 38700eed..c4c572ec 100644 --- a/Bootstrap.DataAccess/LogHelper.cs +++ b/Bootstrap.DataAccess/LogHelper.cs @@ -51,14 +51,14 @@ namespace Bootstrap.DataAccess /// /// 删除日志信息 /// - /// + /// /// - public static bool DeleteLog(string ids) + public static bool DeleteLog(IEnumerable value) { - if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return false; bool ret = false; try { + var ids = string.Join(",", value); string sql = string.Format(CultureInfo.InvariantCulture, "Delete from Logs where ID in ({0})", ids); using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) { diff --git a/Bootstrap.DataAccess/MenuHelper.cs b/Bootstrap.DataAccess/MenuHelper.cs index 64b98047..48b83043 100644 --- a/Bootstrap.DataAccess/MenuHelper.cs +++ b/Bootstrap.DataAccess/MenuHelper.cs @@ -23,13 +23,13 @@ namespace Bootstrap.DataAccess /// /// 删除菜单信息 /// - /// - public static bool DeleteMenu(string ids) + /// + public static bool DeleteMenu(IEnumerable value) { - if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return false; bool ret = false; try { + var ids = string.Join(",", value); using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_DeleteMenus")) { cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids)); diff --git a/Bootstrap.DataAccess/RoleHelper.cs b/Bootstrap.DataAccess/RoleHelper.cs index 5cd38617..ebd5aed7 100644 --- a/Bootstrap.DataAccess/RoleHelper.cs +++ b/Bootstrap.DataAccess/RoleHelper.cs @@ -135,13 +135,13 @@ namespace Bootstrap.DataAccess /// /// 删除角色表 /// - /// - public static bool DeleteRole(string ids) + /// + public static bool DeleteRole(IEnumerable value) { - if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return false; bool ret = false; try { + var ids = string.Join(",", value); using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_DeleteRoles")) { cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids)); diff --git a/Bootstrap.DataAccess/UserHelper.cs b/Bootstrap.DataAccess/UserHelper.cs index b922892a..3396b47e 100644 --- a/Bootstrap.DataAccess/UserHelper.cs +++ b/Bootstrap.DataAccess/UserHelper.cs @@ -91,13 +91,13 @@ namespace Bootstrap.DataAccess /// /// 删除用户 /// - /// - public static bool DeleteUser(string ids) + /// + public static bool DeleteUser(IEnumerable value) { - if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return false; bool ret = false; try { + var ids = string.Join(",", value); using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_DeleteUsers")) { cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids));