大量的代码格式化
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 1m10s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 1m10s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
namespace WebApi.Controllers;
|
||||
namespace WebApi.Controllers;
|
||||
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
@@ -9,7 +9,8 @@ using Repository;
|
||||
public class TransactionRecordController(
|
||||
ITransactionRecordRepository transactionRepository,
|
||||
ISmartHandleService smartHandleService,
|
||||
ILogger<TransactionRecordController> logger
|
||||
ILogger<TransactionRecordController> logger,
|
||||
IConfigService configService
|
||||
) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
@@ -272,13 +273,16 @@ public class TransactionRecordController(
|
||||
{
|
||||
try
|
||||
{
|
||||
var statistics = await transactionRepository.GetDailyStatisticsAsync(year, month);
|
||||
// 获取存款分类
|
||||
var savingClassify = await configService.GetConfigByKeyAsync<string>("SavingsCategories");
|
||||
|
||||
var statistics = await transactionRepository.GetDailyStatisticsAsync(year, month, savingClassify);
|
||||
var result = statistics.Select(s => new DailyStatisticsDto(
|
||||
s.Key,
|
||||
s.Value.count,
|
||||
s.Value.expense,
|
||||
s.Value.income,
|
||||
s.Value.income - s.Value.expense // Balance = Income - Expense
|
||||
s.Value.saving
|
||||
)).ToList();
|
||||
|
||||
return result.Ok();
|
||||
@@ -305,7 +309,13 @@ public class TransactionRecordController(
|
||||
var effectiveEndDate = endDate.Date.AddDays(1);
|
||||
var effectiveStartDate = startDate.Date;
|
||||
|
||||
var statistics = await transactionRepository.GetDailyStatisticsByRangeAsync(effectiveStartDate, effectiveEndDate);
|
||||
// 获取存款分类
|
||||
var savingClassify = await configService.GetConfigByKeyAsync<string>("SavingsCategories");
|
||||
|
||||
var statistics = await transactionRepository.GetDailyStatisticsByRangeAsync(
|
||||
effectiveStartDate,
|
||||
effectiveEndDate,
|
||||
savingClassify);
|
||||
var result = statistics.Select(s => new DailyStatisticsDto(
|
||||
s.Key,
|
||||
s.Value.count,
|
||||
@@ -725,17 +735,6 @@ public class TransactionRecordController(
|
||||
await Response.WriteAsync(message);
|
||||
await Response.Body.FlushAsync();
|
||||
}
|
||||
|
||||
private static string GetTypeName(TransactionType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
TransactionType.Expense => "支出",
|
||||
TransactionType.Income => "收入",
|
||||
TransactionType.None => "不计入收支",
|
||||
_ => "未知"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user