feat: 添加待确认分类功能,支持获取和确认未分类交易记录;优化相关组件和服务
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 24s
Docker Build & Deploy / Deploy to Production (push) Successful in 10s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 24s
Docker Build & Deploy / Deploy to Production (push) Successful in 10s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
This commit is contained in:
@@ -102,9 +102,7 @@ public class EmailHandleService(
|
||||
records.Add(record);
|
||||
}
|
||||
|
||||
// var analysisResult = await AnalyzeClassifyAsync(records.ToArray());
|
||||
// TODO 不应该直接保存 应该保存在备用字段上,前端确认后再更新到正式字段
|
||||
|
||||
_ = AutoClassifyAsync(records.ToArray());
|
||||
|
||||
return allSuccess;
|
||||
}
|
||||
@@ -173,11 +171,34 @@ public class EmailHandleService(
|
||||
records.Add(record);
|
||||
}
|
||||
|
||||
_ = await AnalyzeClassifyAsync(records.ToArray());
|
||||
_ = AutoClassifyAsync(records.ToArray());
|
||||
|
||||
return allSuccess;
|
||||
}
|
||||
|
||||
private async Task AutoClassifyAsync(TransactionRecord[] records)
|
||||
{
|
||||
await AnalyzeClassifyAsync(records.ToArray());
|
||||
|
||||
foreach (var record in records)
|
||||
{
|
||||
record.UnconfirmedClassify = record.Classify;
|
||||
record.UnconfirmedType = record.Type;
|
||||
|
||||
record.Classify = ""; // 重置为未分类,等待手动确认
|
||||
}
|
||||
|
||||
await trxRepo.UpdateRangeAsync(records);
|
||||
|
||||
// 消息
|
||||
await messageRecordService.AddAsync(
|
||||
"交易记录待确认分类",
|
||||
$"共有 {records.Length} 条交易记录待确认分类,请点击前往确认。",
|
||||
MessageType.Url,
|
||||
"/unconfirmed-classification"
|
||||
);
|
||||
}
|
||||
|
||||
private string GetEmailByName(string to)
|
||||
{
|
||||
return emailSettings.Value.SmtpList.FirstOrDefault(s => s.Email == to)?.Name ?? to;
|
||||
|
||||
@@ -5,7 +5,7 @@ public interface IMessageRecordService
|
||||
Task<(IEnumerable<MessageRecord> List, long Total)> GetPagedListAsync(int pageIndex, int pageSize);
|
||||
Task<MessageRecord?> GetByIdAsync(long id);
|
||||
Task<bool> AddAsync(MessageRecord message);
|
||||
Task<bool> AddAsync(string title, string content, MessageType type = MessageType.Text);
|
||||
Task<bool> AddAsync(string title, string content, MessageType type = MessageType.Text, string? url = null);
|
||||
Task<bool> MarkAsReadAsync(long id);
|
||||
Task<bool> MarkAllAsReadAsync();
|
||||
Task<bool> DeleteAsync(long id);
|
||||
@@ -29,19 +29,20 @@ public class MessageRecordService(IMessageRecordRepository messageRepo, INotific
|
||||
return await messageRepo.AddAsync(message);
|
||||
}
|
||||
|
||||
public async Task<bool> AddAsync(string title, string content, MessageType type = MessageType.Text)
|
||||
public async Task<bool> AddAsync(string title, string content, MessageType type = MessageType.Text, string? url = null)
|
||||
{
|
||||
var message = new MessageRecord
|
||||
{
|
||||
Title = title,
|
||||
Content = content,
|
||||
MessageType = type,
|
||||
Url = url,
|
||||
IsRead = false
|
||||
};
|
||||
var result = await messageRepo.AddAsync(message);
|
||||
if (result)
|
||||
{
|
||||
await notificationService.SendNotificationAsync(title);
|
||||
await notificationService.SendNotificationAsync(title, url);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user