feat: 移除预算同步相关功能,简化预算管理逻辑
This commit is contained in:
@@ -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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user