feat: 移除预算同步相关功能,简化预算管理逻辑
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 22s
Docker Build & Deploy / Deploy to Production (push) Successful in 6s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 2s

This commit is contained in:
孙诚
2026-01-07 16:23:50 +08:00
parent c95aa6b17b
commit 60fb0e0d8f
5 changed files with 3 additions and 72 deletions

View File

@@ -68,8 +68,7 @@ public class BudgetController(
Limit = dto.Limit,
Category = dto.Category,
SelectedCategories = dto.SelectedCategories != null ? string.Join(",", dto.SelectedCategories) : string.Empty,
StartDate = dto.StartDate ?? DateTime.Now,
LastSync = DateTime.Now
StartDate = dto.StartDate ?? DateTime.Now
};
var success = await budgetService.AddAsync(budget);
@@ -122,30 +121,4 @@ public class BudgetController(
}
}
/// <summary>
/// 同步预算数据
/// </summary>
[HttpPost]
public async Task<BaseResponse<BudgetDto>> SyncAsync([FromQuery] long id, [FromQuery] DateTime? referenceDate = null)
{
try
{
var budget = await budgetService.GetByIdAsync(id);
if (budget == null)
{
return "预算不存在".Fail<BudgetDto>();
}
budget.LastSync = DateTime.Now;
await budgetService.UpdateAsync(budget);
var currentAmount = await budgetService.CalculateCurrentAmountAsync(budget, referenceDate);
return BudgetDto.FromEntity(budget, currentAmount, referenceDate).Ok();
}
catch (Exception ex)
{
logger.LogError(ex, "同步预算失败, Id: {Id}", id);
return $"同步失败: {ex.Message}".Fail<BudgetDto>();
}
}
}

View File

@@ -12,7 +12,6 @@ public class BudgetDto
public bool IsStopped { get; set; }
public string StartDate { get; set; } = string.Empty;
public string Period { get; set; } = string.Empty;
public string LastSync { get; set; } = string.Empty;
public static BudgetDto FromEntity(BudgetRecord entity, decimal currentAmount = 0, DateTime? referenceDate = null)
{
@@ -32,8 +31,7 @@ public class BudgetDto
: entity.SelectedCategories.Split(','),
IsStopped = entity.IsStopped,
StartDate = entity.StartDate.ToString("yyyy-MM-dd"),
Period = entity.Type == BudgetPeriodType.Longterm ? "长期" : $"{start:yyyy-MM-dd} ~ {end:yyyy-MM-dd}",
LastSync = entity.LastSync?.ToString("yyyy-MM-dd HH:mm") ?? "未同步"
Period = entity.Type == BudgetPeriodType.Longterm ? "长期" : $"{start:yyyy-MM-dd} ~ {end:yyyy-MM-dd}"
};
}
}