refactor:删除不必要的方法
This commit is contained in:
@@ -116,7 +116,12 @@ public class MqttAppService : IMqttAppService
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _repoManager.MqttServers.DeleteByIdAsync(id);
|
||||
var mqttServer = await _repoManager.MqttServers.GetByIdAsync(id);
|
||||
if (mqttServer == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return await _repoManager.MqttServers.DeleteAsync(mqttServer);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -171,27 +176,27 @@ public class MqttAppService : IMqttAppService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步批量删除MQTT服务器(事务性操作)。
|
||||
/// </summary>
|
||||
/// <param name="ids">要删除的MQTT服务器ID列表。</param>
|
||||
/// <returns>如果删除成功则为 true,否则为 false。</returns>
|
||||
/// <exception cref="ApplicationException">如果批量删除MQTT服务器时发生错误。</exception>
|
||||
public async Task<bool> DeleteMqttServersAsync(List<int> ids)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ids == null || !ids.Any()) return true;
|
||||
|
||||
await _repoManager.BeginTranAsync();
|
||||
var result = await _repoManager.MqttServers.DeleteByIdsAsync(ids);
|
||||
await _repoManager.CommitAsync();
|
||||
return result > 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _repoManager.RollbackAsync();
|
||||
throw new ApplicationException($"批量删除MQTT服务器时发生错误,操作已回滚,错误信息:{ex.Message}", ex);
|
||||
}
|
||||
}
|
||||
// /// <summary>
|
||||
// /// 异步批量删除MQTT服务器(事务性操作)。
|
||||
// /// </summary>
|
||||
// /// <param name="ids">要删除的MQTT服务器ID列表。</param>
|
||||
// /// <returns>如果删除成功则为 true,否则为 false。</returns>
|
||||
// /// <exception cref="ApplicationException">如果批量删除MQTT服务器时发生错误。</exception>
|
||||
// public async Task<bool> DeleteMqttServersAsync(List<int> ids)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (ids == null || !ids.Any()) return true;
|
||||
//
|
||||
// await _repoManager.BeginTranAsync();
|
||||
// var result = await _repoManager.MqttServers.DeleteByIdsAsync(ids);
|
||||
// await _repoManager.CommitAsync();
|
||||
// return result > 0;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await _repoManager.RollbackAsync();
|
||||
// throw new ApplicationException($"批量删除MQTT服务器时发生错误,操作已回滚,错误信息:{ex.Message}", ex);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user