优化代码
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 23s
Docker Build & Deploy / Deploy to Production (push) Successful in 6s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s

This commit is contained in:
孙诚
2026-01-04 16:43:32 +08:00
parent ab22325ca7
commit 557d44aed8
11 changed files with 200 additions and 460 deletions

View File

@@ -34,12 +34,12 @@ public class MessageRecordController(IMessageRecordService messageService, ILogg
try
{
var count = await messageService.GetUnreadCountAsync();
return BaseResponse<long>.Done(count);
return count.Ok();
}
catch (Exception ex)
{
logger.LogError(ex, "获取未读消息数量失败");
return BaseResponse<long>.Fail($"获取未读消息数量失败: {ex.Message}");
return $"获取未读消息数量失败: {ex.Message}".Fail<long>();
}
}
@@ -52,12 +52,12 @@ public class MessageRecordController(IMessageRecordService messageService, ILogg
try
{
var result = await messageService.MarkAsReadAsync(id);
return BaseResponse<bool>.Done(result);
return result.Ok();
}
catch (Exception ex)
{
logger.LogError(ex, "标记消息已读失败ID: {Id}", id);
return BaseResponse<bool>.Fail($"标记消息已读失败: {ex.Message}");
return $"标记消息已读失败: {ex.Message}".Fail<bool>();
}
}
@@ -70,12 +70,12 @@ public class MessageRecordController(IMessageRecordService messageService, ILogg
try
{
var result = await messageService.MarkAllAsReadAsync();
return BaseResponse<bool>.Done(result);
return result.Ok();
}
catch (Exception ex)
{
logger.LogError(ex, "全部标记已读失败");
return BaseResponse<bool>.Fail($"全部标记已读失败: {ex.Message}");
return $"全部标记已读失败: {ex.Message}".Fail<bool>();
}
}
@@ -88,12 +88,12 @@ public class MessageRecordController(IMessageRecordService messageService, ILogg
try
{
var result = await messageService.DeleteAsync(id);
return BaseResponse<bool>.Done(result);
return result.Ok();
}
catch (Exception ex)
{
logger.LogError(ex, "删除消息失败ID: {Id}", id);
return BaseResponse<bool>.Fail($"删除消息失败: {ex.Message}");
return $"删除消息失败: {ex.Message}".Fail<bool>();
}
}
@@ -106,12 +106,12 @@ public class MessageRecordController(IMessageRecordService messageService, ILogg
try
{
var result = await messageService.AddAsync(message);
return BaseResponse<bool>.Done(result);
return result.Ok();
}
catch (Exception ex)
{
logger.LogError(ex, "新增消息失败");
return BaseResponse<bool>.Fail($"新增消息失败: {ex.Message}");
return $"新增消息失败: {ex.Message}".Fail<bool>();
}
}
}