This commit is contained in:
SunCheng
2026-02-15 10:10:28 +08:00
parent e51a3edd50
commit a88556c784
92 changed files with 6751 additions and 776 deletions

View File

@@ -17,6 +17,7 @@ public interface ITransactionCategoryApplication
Task<int> BatchCreateAsync(List<CreateCategoryRequest> requests);
Task<string> GenerateIconAsync(GenerateIconRequest request);
Task UpdateSelectedIconAsync(UpdateSelectedIconRequest request);
Task DeleteIconAsync(long classificationId);
}
/// <summary>
@@ -215,6 +216,25 @@ public class TransactionCategoryApplication(
}
}
public async Task DeleteIconAsync(long classificationId)
{
var category = await categoryRepository.GetByIdAsync(classificationId);
if (category == null)
{
throw new NotFoundException("分类不存在");
}
// 将 Icon 字段设置为 null
category.Icon = null;
category.UpdateTime = DateTime.Now;
var success = await categoryRepository.UpdateAsync(category);
if (!success)
{
throw new BusinessException("删除图标失败");
}
}
private static CategoryResponse MapToResponse(TransactionCategory category)
{
return new CategoryResponse