重构代码:Group类移除存储过程Proc_DeleteGroups
This commit is contained in:
parent
575adc78aa
commit
cbafbebc1f
|
@ -12,41 +12,6 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Group : DataAccess.Group
|
public class Group : DataAccess.Group
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// <summary>
|
|
||||||
/// 删除群组信息
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ids"></param>
|
|
||||||
public override bool DeleteGroup(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 UserGroup where GroupID in ({ids})"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
|
||||||
|
|
||||||
cmd.CommandText = $"delete from RoleGroup where GroupID in ({ids})";
|
|
||||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
|
||||||
|
|
||||||
cmd.CommandText = $"delete from Groups 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>
|
||||||
|
|
|
@ -61,10 +61,29 @@ 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_DeleteGroups"))
|
using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
|
||||||
{
|
{
|
||||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@ids", ids));
|
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, $"delete from UserGroup where GroupID in ({ids})"))
|
||||||
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == -1;
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
||||||
|
|
||||||
|
cmd.CommandText = $"delete from RoleGroup where GroupID in ({ids})";
|
||||||
|
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
||||||
|
|
||||||
|
cmd.CommandText = $"delete from Groups 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