This commit is contained in:
SunCheng
2026-02-10 17:49:19 +08:00
parent 3e18283e52
commit d052ae5197
104 changed files with 10369 additions and 3000 deletions

View File

@@ -0,0 +1,97 @@
using Application.Dto.Message;
using Service.Message;
namespace Application;
/// <summary>
/// 消息记录应用服务接口
/// </summary>
public interface IMessageRecordApplication
{
/// <summary>
/// 获取消息列表(分页)
/// </summary>
Task<MessagePagedResult> GetListAsync(int pageIndex = 1, int pageSize = 20);
/// <summary>
/// 获取未读消息数量
/// </summary>
Task<long> GetUnreadCountAsync();
/// <summary>
/// 标记为已读
/// </summary>
Task<bool> MarkAsReadAsync(long id);
/// <summary>
/// 全部标记为已读
/// </summary>
Task<bool> MarkAllAsReadAsync();
/// <summary>
/// 删除消息
/// </summary>
Task<bool> DeleteAsync(long id);
/// <summary>
/// 新增消息
/// </summary>
Task<bool> AddAsync(MessageRecord message);
}
/// <summary>
/// 消息记录应用服务实现
/// </summary>
public class MessageRecordApplication(
IMessageService messageService,
ILogger<MessageRecordApplication> logger
) : IMessageRecordApplication
{
public async Task<MessagePagedResult> GetListAsync(int pageIndex = 1, int pageSize = 20)
{
var (list, total) = await messageService.GetPagedListAsync(pageIndex, pageSize);
return new MessagePagedResult
{
Data = list.Select(MapToResponse).ToArray(),
Total = (int)total
};
}
public async Task<long> GetUnreadCountAsync()
{
return await messageService.GetUnreadCountAsync();
}
public async Task<bool> MarkAsReadAsync(long id)
{
return await messageService.MarkAsReadAsync(id);
}
public async Task<bool> MarkAllAsReadAsync()
{
return await messageService.MarkAllAsReadAsync();
}
public async Task<bool> DeleteAsync(long id)
{
return await messageService.DeleteAsync(id);
}
public async Task<bool> AddAsync(MessageRecord message)
{
return await messageService.AddAsync(message);
}
private static MessageRecordResponse MapToResponse(MessageRecord record)
{
return new MessageRecordResponse
{
Id = record.Id,
Title = record.Title,
Content = record.Content,
IsRead = record.IsRead,
CreateTime = record.CreateTime
};
}
}