重构代码:Menu移除存储过程Proc_DeleteMenus
This commit is contained in:
parent
cbafbebc1f
commit
ab6d78eb20
|
@ -51,38 +51,6 @@ namespace Bootstrap.DataAccess.MySQL
|
|||
return menus;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除菜单信息
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public override bool DeleteMenu(IEnumerable<string> value)
|
||||
{
|
||||
bool ret = false;
|
||||
var ids = string.Join(",", value);
|
||||
using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
|
||||
{
|
||||
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, $"delete from NavigationRole where NavigationID in ({ids})"))
|
||||
{
|
||||
try
|
||||
{
|
||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
||||
|
||||
cmd.CommandText = $"delete from Navigations where ID in ({ids})";
|
||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
||||
|
||||
transaction.CommitTransaction();
|
||||
ret = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
transaction.RollbackTransaction();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// 通过角色ID保存当前授权菜单
|
||||
|
|
|
@ -12,38 +12,6 @@ namespace Bootstrap.DataAccess.SQLite
|
|||
/// </summary>
|
||||
public class Menu : DataAccess.Menu
|
||||
{
|
||||
/// <summary>
|
||||
/// 删除菜单信息
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public override bool DeleteMenu(IEnumerable<string> value)
|
||||
{
|
||||
bool ret = false;
|
||||
var ids = string.Join(",", value);
|
||||
using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
|
||||
{
|
||||
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, $"delete from NavigationRole where NavigationID in ({ids})"))
|
||||
{
|
||||
try
|
||||
{
|
||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
||||
|
||||
cmd.CommandText = $"delete from Navigations where ID in ({ids})";
|
||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
||||
|
||||
transaction.CommitTransaction();
|
||||
ret = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
transaction.RollbackTransaction();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// 通过角色ID保存当前授权菜单
|
||||
|
|
|
@ -23,10 +23,26 @@ namespace Bootstrap.DataAccess
|
|||
{
|
||||
bool ret = false;
|
||||
var ids = string.Join(",", value);
|
||||
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_DeleteMenus"))
|
||||
using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
|
||||
{
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@ids", ids));
|
||||
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == -1;
|
||||
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, $"delete from NavigationRole where NavigationID in ({ids})"))
|
||||
{
|
||||
try
|
||||
{
|
||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
||||
|
||||
cmd.CommandText = $"delete from Navigations where ID in ({ids})";
|
||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
||||
|
||||
transaction.CommitTransaction();
|
||||
ret = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
transaction.RollbackTransaction();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue