refactor:删除不必要的方法

This commit is contained in:
2025-10-21 13:01:27 +08:00
parent 6872631933
commit 3116e4ce92
27 changed files with 105 additions and 608 deletions

View File

@@ -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);
// }
// }
}