大量的代码格式化
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 38s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 2s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s

This commit is contained in:
SunCheng
2026-01-18 22:25:59 +08:00
parent 9611ff2088
commit 435efbcb90
18 changed files with 200 additions and 226 deletions

View File

@@ -268,9 +268,9 @@ public class TransactionRecordController(
var statistics = await transactionRepository.GetDailyStatisticsAsync(year, month, savingClassify);
var result = statistics.Select(s => new DailyStatisticsDto(
s.Key,
s.Value.count,
s.Value.expense,
s.Key,
s.Value.count,
s.Value.expense,
s.Value.income,
s.Value.saving
)).ToList();
@@ -303,13 +303,13 @@ public class TransactionRecordController(
var savingClassify = await configService.GetConfigByKeyAsync<string>("SavingsCategories");
var statistics = await transactionRepository.GetDailyStatisticsByRangeAsync(
effectiveStartDate,
effectiveStartDate,
effectiveEndDate,
savingClassify);
var result = statistics.Select(s => new DailyStatisticsDto(
s.Key,
s.Value.count,
s.Value.expense,
s.Key,
s.Value.count,
s.Value.expense,
s.Value.income,
s.Value.income - s.Value.expense
)).ToList();
@@ -383,7 +383,8 @@ public class TransactionRecordController(
}
catch (Exception ex)
{
logger.LogError(ex, "获取趋势统计数据失败,开始年份: {Year}, 开始月份: {Month}, 月份数: {Count}", startYear, startMonth, monthCount);
logger.LogError(ex, "获取趋势统计数据失败,开始年份: {Year}, 开始月份: {Month}, 月份数: {Count}", startYear, startMonth,
monthCount);
return $"获取趋势统计数据失败: {ex.Message}".Fail<List<TrendStatistics>>();
}
}
@@ -403,9 +404,16 @@ public class TransactionRecordController(
return;
}
await smartHandleService.AnalyzeBillAsync(request.UserInput, async chunk =>
await smartHandleService.AnalyzeBillAsync(request.UserInput, async void (chunk) =>
{
await WriteEventAsync(chunk);
try
{
await WriteEventAsync(chunk);
}
catch (Exception e)
{
logger.LogError(e, "流式写入账单分析结果失败");
}
});
}
@@ -490,11 +498,18 @@ public class TransactionRecordController(
return;
}
await smartHandleService.SmartClassifyAsync(request.TransactionIds.ToArray(), async chunk =>
await smartHandleService.SmartClassifyAsync(request.TransactionIds.ToArray(), async void (chunk) =>
{
var (eventType, content) = chunk;
await TrySetUnconfirmedAsync(eventType, content);
await WriteEventAsync(eventType, content);
try
{
var (eventType, content) = chunk;
await TrySetUnconfirmedAsync(eventType, content);
await WriteEventAsync(eventType, content);
}
catch (Exception e)
{
logger.LogError(e, "流式写入智能分类结果失败");
}
});
await Response.Body.FlushAsync();
@@ -514,7 +529,7 @@ public class TransactionRecordController(
var classify = jsonObject?["Classify"]?.GetValue<string>() ?? string.Empty;
var typeValue = jsonObject?["Type"]?.GetValue<int>() ?? -1;
if(id == 0 || typeValue == -1 || string.IsNullOrEmpty(classify))
if (id == 0 || typeValue == -1 || string.IsNullOrEmpty(classify))
{
logger.LogWarning("解析智能分类结果时,发现无效数据,内容: {Content}", content);
return;
@@ -565,14 +580,17 @@ public class TransactionRecordController(
{
record.Type = item.Type.Value;
}
if(!string.IsNullOrEmpty(record.Classify))
if (!string.IsNullOrEmpty(record.Classify))
{
record.UnconfirmedClassify = null;
}
if(record.Type == item.Type)
if (record.Type == item.Type)
{
record.UnconfirmedType = TransactionType.None;
}
var success = await transactionRepository.UpdateAsync(record);
if (success)
successCount++;
@@ -735,18 +753,7 @@ public record CreateTransactionDto(
decimal Amount,
TransactionType Type,
string? Classify
)
{
public string OccurredAt { get; init; } = OccurredAt;
public string? Reason { get; init; } = Reason;
public decimal Amount { get; init; } = Amount;
public TransactionType Type { get; init; } = Type;
public string? Classify { get; init; } = Classify;
}
);
/// <summary>
/// 更新交易记录DTO
@@ -758,20 +765,7 @@ public record UpdateTransactionDto(
decimal Balance,
TransactionType Type,
string? Classify
)
{
public long Id { get; init; } = Id;
public string? Reason { get; init; } = Reason;
public decimal Amount { get; init; } = Amount;
public decimal Balance { get; init; } = Balance;
public TransactionType Type { get; init; } = Type;
public string? Classify { get; init; } = Classify;
}
);
/// <summary>
/// 日历统计响应DTO
@@ -782,28 +776,14 @@ public record DailyStatisticsDto(
decimal Expense,
decimal Income,
decimal Balance
)
{
public string Date { get; init; } = Date;
public int Count { get; init; } = Count;
public decimal Expense { get; init; } = Expense;
public decimal Income { get; init; } = Income;
public decimal Balance { get; init; } = Balance;
}
);
/// <summary>
/// 智能分类请求DTO
/// </summary>
public record SmartClassifyRequest(
List<long>? TransactionIds = null
)
{
public List<long>? TransactionIds { get; init; } = TransactionIds;
}
);
/// <summary>
/// 批量更新分类项DTO
@@ -812,14 +792,7 @@ public record BatchUpdateClassifyItem(
long Id,
string? Classify,
TransactionType? Type = null
)
{
public long Id { get; init; } = Id;
public string? Classify { get; init; } = Classify;
public TransactionType? Type { get; init; } = Type;
}
);
/// <summary>
/// 按摘要批量更新DTO
@@ -828,24 +801,14 @@ public record BatchUpdateByReasonDto(
string Reason,
TransactionType Type,
string Classify
)
{
public string Reason { get; init; } = Reason;
public TransactionType Type { get; init; } = Type;
public string Classify { get; init; } = Classify;
}
);
/// <summary>
/// 账单分析请求DTO
/// </summary>
public record BillAnalysisRequest(
string UserInput
)
{
public string UserInput { get; init; } = UserInput;
}
);
/// <summary>
/// 抵账请求DTO
@@ -853,23 +816,12 @@ public record BillAnalysisRequest(
public record OffsetTransactionDto(
long Id1,
long Id2
)
{
public long Id1 { get; init; } = Id1;
public long Id2 { get; init; } = Id2;
}
);
public record ParseOneLineRequestDto(
string Text
)
{
public string Text { get; init; } = Text;
}
);
public record ConfirmAllUnconfirmedRequestDto(
long[] Ids
)
{
public long[] Ids { get; init; } = Ids;
}
);