修改BUG:完善删除功能

This commit is contained in:
Argo-MacBookPro 2018-06-08 12:54:05 +08:00
parent df8e4d9517
commit 2e2d8c78e2
11 changed files with 23 additions and 22 deletions

View File

@ -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
/// <param name="value"></param>
[HttpDelete]
[Authorize(Roles = "Administrators")]
public object Delete(string value)
public object Delete(IEnumerable<int> value)
{
var result = DictHelper.DeleteDict(value);
return new { result, msg = result ? "成功!" : "失败" };

View File

@ -48,7 +48,7 @@ namespace Bootstrap.Admin.Controllers.Api
/// </summary>
/// <param name="value"></param>
[HttpDelete]
public bool Delete(string value)
public bool Delete([FromBody]IEnumerable<int> value)
{
return GroupHelper.DeleteGroup(value);
}

View File

@ -39,7 +39,7 @@ namespace Bootstrap.Admin.Controllers.Api
/// </summary>
/// <param name="value"></param>
[HttpDelete]
public bool Delete(string value)
public bool Delete([FromBody]IEnumerable<int> value)
{
return MenuHelper.DeleteMenu(value);
}

View File

@ -94,7 +94,7 @@ namespace Bootstrap.Admin.Controllers.Api
/// </summary>
/// <param name="value"></param>
[HttpDelete]
public bool Delete(string value)
public bool Delete([FromBody]IEnumerable<int> value)
{
return RoleHelper.DeleteRole(value);
}

View File

@ -131,7 +131,7 @@ namespace Bootstrap.Admin.Controllers.Api
/// </summary>
/// <param name="value"></param>
[HttpDelete]
public bool Delete(string value)
public bool Delete([FromBody]IEnumerable<int> value)
{
return UserHelper.DeleteUser(value);
}

View File

@ -30,14 +30,14 @@ namespace Bootstrap.DataAccess
/// <summary>
/// 删除字典中的数据
/// </summary>
/// <param name="ids">需要删除的IDs</param>
/// <param name="value">需要删除的IDs</param>
/// <returns></returns>
public static bool DeleteDict(string ids)
public static bool DeleteDict(IEnumerable<int> 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))
{

View File

@ -55,12 +55,12 @@ namespace Bootstrap.DataAccess
/// 删除群组信息
/// </summary>
/// <param name="ids"></param>
public static bool DeleteGroup(string ids)
public static bool DeleteGroup(IEnumerable<int> 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));

View File

@ -51,14 +51,14 @@ namespace Bootstrap.DataAccess
/// <summary>
/// 删除日志信息
/// </summary>
/// <param name="ids"></param>
/// <param name="value"></param>
/// <returns></returns>
public static bool DeleteLog(string ids)
public static bool DeleteLog(IEnumerable<int> 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))
{

View File

@ -23,13 +23,13 @@ namespace Bootstrap.DataAccess
/// <summary>
/// 删除菜单信息
/// </summary>
/// <param name="ids"></param>
public static bool DeleteMenu(string ids)
/// <param name="value"></param>
public static bool DeleteMenu(IEnumerable<int> 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));

View File

@ -135,13 +135,13 @@ namespace Bootstrap.DataAccess
/// <summary>
/// 删除角色表
/// </summary>
/// <param name="ids"></param>
public static bool DeleteRole(string ids)
/// <param name="value"></param>
public static bool DeleteRole(IEnumerable<int> 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));

View File

@ -91,13 +91,13 @@ namespace Bootstrap.DataAccess
/// <summary>
/// 删除用户
/// </summary>
/// <param name="ids"></param>
public static bool DeleteUser(string ids)
/// <param name="value"></param>
public static bool DeleteUser(IEnumerable<int> 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));