重构代码:Role移除Proc_DeleteRoles
This commit is contained in:
parent
ab6d78eb20
commit
2edaf9b961
|
@ -94,44 +94,6 @@ namespace Bootstrap.DataAccess.MySQL
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 删除角色表
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value"></param>
|
|
||||||
public override bool DeleteRole(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 UserRole where RoleID in ({ids})"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
|
||||||
|
|
||||||
cmd.CommandText = $"delete from RoleGroup where RoleID in ({ids})";
|
|
||||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
|
||||||
|
|
||||||
cmd.CommandText = $"delete from NavigationRole where RoleID in ({ids})";
|
|
||||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
|
||||||
|
|
||||||
cmd.CommandText = $"delete from Roles where ID in ({ids})";
|
|
||||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
|
||||||
|
|
||||||
transaction.CommitTransaction();
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
transaction.RollbackTransaction();
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -50,44 +50,6 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 删除角色表
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value"></param>
|
|
||||||
public override bool DeleteRole(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 UserRole where RoleID in ({ids})"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
|
||||||
|
|
||||||
cmd.CommandText = $"delete from RoleGroup where RoleID in ({ids})";
|
|
||||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
|
||||||
|
|
||||||
cmd.CommandText = $"delete from NavigationRole where RoleID in ({ids})";
|
|
||||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
|
||||||
|
|
||||||
cmd.CommandText = $"delete from Roles where ID in ({ids})";
|
|
||||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
|
||||||
|
|
||||||
transaction.CommitTransaction();
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
transaction.RollbackTransaction();
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -139,10 +139,32 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
var ids = string.Join(",", value);
|
var ids = string.Join(",", value);
|
||||||
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_DeleteRoles"))
|
using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
|
||||||
{
|
{
|
||||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@ids", ids));
|
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, $"delete from UserRole where RoleID in ({ids})"))
|
||||||
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == -1;
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
||||||
|
|
||||||
|
cmd.CommandText = $"delete from RoleGroup where RoleID in ({ids})";
|
||||||
|
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
||||||
|
|
||||||
|
cmd.CommandText = $"delete from NavigationRole where RoleID in ({ids})";
|
||||||
|
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
||||||
|
|
||||||
|
cmd.CommandText = $"delete from Roles where ID in ({ids})";
|
||||||
|
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
||||||
|
|
||||||
|
transaction.CommitTransaction();
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
transaction.RollbackTransaction();
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue