Skip to content

Commit

Permalink
feat: 消息查询添加消息级别
Browse files Browse the repository at this point in the history
  • Loading branch information
WangJunZzz committed Nov 20, 2024
1 parent 9db3b95 commit 1d0d45b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,10 @@ public class PagingNotificationInput : PagingBase
/// 消息类型
/// </summary>
public MessageType? MessageType { get; set; }

/// <summary>
/// 消息等级
/// </summary>
public MessageLevel? MessageLevel { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public virtual async Task SetReadAsync(SetReadInput input)
/// </summary>
public virtual async Task<PagedResultDto<PagingNotificationOutput>> PageNotificationAsync(PagingNotificationInput input)
{
var totalCount = await _notificationManager.GetPagingCountAsync(input.Title, input.Content, input.SenderUserId, input.SenderUserName, input.ReceiverUserId, input.ReceiverUserName, input.Read, input.StartReadTime, input.EndReadTime, input.MessageType);
var list = await _notificationManager.GetPagingListAsync(input.Title, input.Content, input.SenderUserId, input.SenderUserName, input.ReceiverUserId, input.ReceiverUserName, input.Read, input.StartReadTime, input.EndReadTime, input.MessageType, input.PageSize, input.SkipCount);
var totalCount = await _notificationManager.GetPagingCountAsync(input.Title, input.Content, input.SenderUserId, input.SenderUserName, input.ReceiverUserId, input.ReceiverUserName, input.Read, input.StartReadTime, input.EndReadTime, input.MessageType,input.MessageLevel);
var list = await _notificationManager.GetPagingListAsync(input.Title, input.Content, input.SenderUserId, input.SenderUserName, input.ReceiverUserId, input.ReceiverUserName, input.Read, input.StartReadTime, input.EndReadTime, input.MessageType,input.MessageLevel, input.PageSize, input.SkipCount);
return new PagedResultDto<PagingNotificationOutput>(totalCount, ObjectMapper.Map<List<NotificationDto>, List<PagingNotificationOutput>>(list));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Task<List<NotificationDto>> GetPagingListAsync(
DateTime? startReadTime,
DateTime? endReadTime,
MessageType? messageType,
MessageLevel? messageLevel,
int maxResultCount = 10,
int skipCount = 0);

Expand All @@ -35,7 +36,8 @@ Task<long> GetPagingCountAsync(
bool? read,
DateTime? startReadTime,
DateTime? endReadTime,
MessageType? messageType);
MessageType? messageType,
MessageLevel? messageLevel);

/// <summary>
/// 发送警告文本消息
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Task<List<Notification>> GetPagingListAsync(
DateTime? startReadTime,
DateTime? endReadTime,
MessageType? messageType,
MessageLevel? messageLevel,
int maxResultCount = 10,
int skipCount = 0,
CancellationToken cancellationToken = default);
Expand All @@ -37,6 +38,7 @@ Task<long> GetPagingCountAsync(
DateTime? startReadTime,
DateTime? endReadTime,
MessageType? messageType,
MessageLevel? messageLevel,
CancellationToken cancellationToken = default);

Task<List<Notification>> GetListAsync(List<Guid> ids);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ public async Task<List<NotificationDto>> GetPagingListAsync(
DateTime? startReadTime,
DateTime? endReadTime,
MessageType? messageType,
MessageLevel? messageLevel,
int maxResultCount = 10,
int skipCount = 0)
{
var list = await _notificationRepository.GetPagingListAsync(title, content, senderUserId, senderUserName, receiverUserId, receiverUserName, read, startReadTime, endReadTime, messageType, maxResultCount, skipCount);
var list = await _notificationRepository.GetPagingListAsync(title, content, senderUserId, senderUserName, receiverUserId, receiverUserName, read, startReadTime, endReadTime, messageType,messageLevel, maxResultCount, skipCount);
return ObjectMapper.Map<List<Notification>, List<NotificationDto>>(list);
}

Expand All @@ -49,9 +50,10 @@ public async Task<long> GetPagingCountAsync(
bool? read,
DateTime? startReadTime,
DateTime? endReadTime,
MessageType? messageType)
MessageType? messageType,
MessageLevel? messageLevel)
{
return await _notificationRepository.GetPagingCountAsync(title, content, senderUserId, senderUserName, receiverUserId, receiverUserName, read, startReadTime, endReadTime, messageType);
return await _notificationRepository.GetPagingCountAsync(title, content, senderUserId, senderUserName, receiverUserId, receiverUserName, read, startReadTime, endReadTime, messageType, messageLevel);
}

public async Task SendCommonWarningMessageAsync(string title, string content, MessageLevel level, Guid receiveUserId, string receiveUserName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public async Task<List<Notification>> GetPagingListAsync(
DateTime? startReadTime,
DateTime? endReadTime,
MessageType? messageType,
MessageLevel? messageLevel,
int maxResultCount = 10,
int skipCount = 0,
CancellationToken cancellationToken = default)
Expand All @@ -38,6 +39,7 @@ public async Task<List<Notification>> GetPagingListAsync(
.WhereIf(startReadTime.HasValue, e => e.ReadTime >= startReadTime.Value)
.WhereIf(endReadTime.HasValue, e => e.ReadTime <= endReadTime.Value)
.WhereIf(messageType.HasValue, e => e.MessageType == messageType.Value)
.WhereIf(messageLevel.HasValue, e => e.MessageLevel == messageLevel.Value)
.OrderByDescending(e => e.CreationTime)
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
Expand All @@ -54,6 +56,7 @@ public async Task<long> GetPagingCountAsync(
DateTime? startReadTime,
DateTime? endReadTime,
MessageType? messageType,
MessageLevel? messageLevel,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
Expand All @@ -67,6 +70,7 @@ public async Task<long> GetPagingCountAsync(
.WhereIf(startReadTime.HasValue, e => e.ReadTime >= startReadTime.Value)
.WhereIf(endReadTime.HasValue, e => e.ReadTime <= endReadTime.Value)
.WhereIf(messageType.HasValue, e => e.MessageType == messageType.Value)
.WhereIf(messageLevel.HasValue, e => e.MessageLevel == messageLevel.Value)
.CountAsync(cancellationToken);
}

Expand Down

0 comments on commit 1d0d45b

Please sign in to comment.