feat: 添加分类名称更新功能,支持在交易记录中同步更新分类名称
This commit is contained in:
@@ -178,6 +178,15 @@ public interface ITransactionRecordRepository : IBaseRepository<TransactionRecor
|
||||
/// <param name="currentType">当前交易类型</param>
|
||||
/// <returns>候选交易列表</returns>
|
||||
Task<List<TransactionRecord>> GetCandidatesForOffsetAsync(long currentId, decimal amount, TransactionType currentType);
|
||||
|
||||
/// <summary>
|
||||
/// 更新分类名称
|
||||
/// </summary>
|
||||
/// <param name="oldName">旧分类名称</param>
|
||||
/// <param name="newName">新分类名称</param>
|
||||
/// <param name="type">交易类型</param>
|
||||
/// <returns>影响行数</returns>
|
||||
Task<int> UpdateCategoryNameAsync(string oldName, string newName, TransactionType type);
|
||||
}
|
||||
|
||||
public class TransactionRecordRepository(IFreeSql freeSql) : BaseRepository<TransactionRecord>(freeSql), ITransactionRecordRepository
|
||||
@@ -661,6 +670,14 @@ public class TransactionRecordRepository(IFreeSql freeSql) : BaseRepository<Tran
|
||||
|
||||
return list.OrderBy(t => Math.Abs(Math.Abs(t.Amount) - absAmount)).ToList();
|
||||
}
|
||||
|
||||
public async Task<int> UpdateCategoryNameAsync(string oldName, string newName, TransactionType type)
|
||||
{
|
||||
return await FreeSql.Update<TransactionRecord>()
|
||||
.Set(a => a.Classify, newName)
|
||||
.Where(a => a.Classify == oldName && a.Type == type)
|
||||
.ExecuteAffrowsAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user