diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/AbpIMSignalROptions.cs b/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/AbpIMSignalROptions.cs
index e0e0482bb..9203ed491 100644
--- a/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/AbpIMSignalROptions.cs
+++ b/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/AbpIMSignalROptions.cs
@@ -10,10 +10,16 @@
/// 用户上线接收方法名称
///
public string UserOnlineMethod { get; set; }
+ ///
+ /// 用户下线接收方法名称
+ ///
+ public string UserOfflineMethod { get; set; }
+
public AbpIMSignalROptions()
{
GetChatMessageMethod = "get-chat-message";
UserOnlineMethod = "on-user-onlined";
+ UserOfflineMethod = "on-user-offlined";
}
}
}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Hubs/MessagesHub.cs b/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Hubs/MessagesHub.cs
index 421a14941..b357a2660 100644
--- a/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Hubs/MessagesHub.cs
+++ b/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Hubs/MessagesHub.cs
@@ -1,5 +1,5 @@
using LINGYUN.Abp.IM.Contract;
-using LINGYUN.Abp.IM.Group;
+using LINGYUN.Abp.IM.Groups;
using LINGYUN.Abp.IM.Messages;
using LINGYUN.Abp.RealTime.Client;
using LINGYUN.Abp.RealTime.SignalR;
@@ -19,6 +19,8 @@ namespace LINGYUN.Abp.IM.SignalR.Hubs
{
protected IMessageProcessor Processor => LazyServiceProvider.LazyGetRequiredService();
+ protected IUserOnlineChanger OnlineChanger => LazyServiceProvider.LazyGetService();
+
protected AbpIMSignalROptions Options { get; }
protected IFriendStore FriendStore { get; }
protected IMessageStore MessageStore { get; }
@@ -39,21 +41,43 @@ namespace LINGYUN.Abp.IM.SignalR.Hubs
protected override async Task OnClientConnectedAsync(IOnlineClient client)
{
await base.OnClientConnectedAsync(client);
- // 加入通讯组
+
+ // 用户上线
+ await OnlineChanger?.ChangeAsync(client.TenantId, client.UserId.Value, UserOnlineState.Online);
+
+ await SendUserOnlineStateAsync(client);
+ }
+
+ protected override async Task OnClientDisconnectedAsync(IOnlineClient client)
+ {
+ await base.OnClientDisconnectedAsync(client);
+
+ // 用户下线
+ await OnlineChanger?.ChangeAsync(client.TenantId, client.UserId.Value, UserOnlineState.Offline);
+
+ await SendUserOnlineStateAsync(client, false);
+ }
+
+ protected virtual async Task SendUserOnlineStateAsync(IOnlineClient client, bool isOnlined = true)
+ {
+ var methodName = isOnlined ? Options.UserOnlineMethod : Options.UserOfflineMethod;
+
var userGroups = await UserGroupStore.GetUserGroupsAsync(client.TenantId, client.UserId.Value);
foreach (var group in userGroups)
{
- // 应使用群组标识
- await Groups.AddToGroupAsync(client.ConnectionId, group.Id);
+ if (isOnlined)
+ {
+ // 应使用群组标识
+ await Groups.AddToGroupAsync(client.ConnectionId, group.Id);
+ }
var groupClient = Clients.Group(group.Id);
if (groupClient != null)
{
- // 发送用户上线通知
- await groupClient.SendAsync(Options.UserOnlineMethod, client.TenantId, client.UserId.Value);
+ // 发送用户下线通知
+ await groupClient.SendAsync(methodName, client.TenantId, client.UserId.Value);
}
}
- // 发送好友上线通知
var userFriends = await FriendStore.GetListAsync(client.TenantId, client.UserId.Value);
if (userFriends.Count > 0)
{
@@ -61,7 +85,7 @@ namespace LINGYUN.Abp.IM.SignalR.Hubs
var userClients = Clients.Users(friendClientIds);
if (userClients != null)
{
- await userClients.SendAsync(Options.UserOnlineMethod, client.TenantId, client.UserId.Value);
+ await userClients.SendAsync(methodName, client.TenantId, client.UserId.Value);
}
}
}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/UserOnlineChecker.cs b/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/UserOnlineChecker.cs
new file mode 100644
index 000000000..be859e58d
--- /dev/null
+++ b/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/UserOnlineChecker.cs
@@ -0,0 +1,33 @@
+using LINGYUN.Abp.RealTime.Client;
+using System;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Volo.Abp.DependencyInjection;
+
+namespace LINGYUN.Abp.IM.SignalR
+{
+ public class UserOnlineChecker : IUserOnlineChecker, ITransientDependency
+ {
+ private readonly IOnlineClientManager _onlineClientManager;
+
+ public UserOnlineChecker(
+ IOnlineClientManager onlineClientManager)
+ {
+ _onlineClientManager = onlineClientManager;
+ }
+
+ public virtual Task CheckAsync(
+ Guid? tenantId,
+ Guid userId,
+ CancellationToken cancellationToken = default)
+ {
+ var onlineClients = _onlineClientManager
+ .GetAllClients(client => client.UserId.Equals(userId));
+
+ var userOnlined = onlineClients?.Any() == true;
+
+ return Task.FromResult(userOnlined);
+ }
+ }
+}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Group/Group.cs b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/Group.cs
similarity index 80%
rename from aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Group/Group.cs
rename to aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/Group.cs
index 7677f8ca9..abd2ed1ac 100644
--- a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Group/Group.cs
+++ b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/Group.cs
@@ -1,4 +1,4 @@
-namespace LINGYUN.Abp.IM.Group
+namespace LINGYUN.Abp.IM.Groups
{
public class Group
{
@@ -11,6 +11,10 @@
///
public string Name { get; set; }
///
+ /// 群组头像
+ ///
+ public string AvatarUrl { get; set; }
+ ///
/// 允许匿名聊天
///
public bool AllowAnonymous { get; set; }
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Group/GroupUserCard.cs b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/GroupUserCard.cs
similarity index 83%
rename from aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Group/GroupUserCard.cs
rename to aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/GroupUserCard.cs
index f41d84064..f2e48bb92 100644
--- a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Group/GroupUserCard.cs
+++ b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/GroupUserCard.cs
@@ -1,12 +1,12 @@
-namespace LINGYUN.Abp.IM.Group
-{
- public class GroupUserCard : UserCard
- {
- public long GroupId { get; set; }
- public bool IsAdmin { get; set; }
- public bool IsSuperAdmin { get; set; }
- public GroupUserCard()
- {
- }
- }
-}
+namespace LINGYUN.Abp.IM.Groups
+{
+ public class GroupUserCard : UserCard
+ {
+ public long GroupId { get; set; }
+ public bool IsAdmin { get; set; }
+ public bool IsSuperAdmin { get; set; }
+ public GroupUserCard()
+ {
+ }
+ }
+}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/IGroupStore.cs b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/IGroupStore.cs
new file mode 100644
index 000000000..95f86a874
--- /dev/null
+++ b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/IGroupStore.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace LINGYUN.Abp.IM.Groups
+{
+ public interface IGroupStore
+ {
+ ///
+ /// 获取群组信息
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task GetAsync(
+ Guid? tenantId,
+ string groupId,
+ CancellationToken cancellationToken = default);
+ ///
+ /// 获取群组数
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task GetCountAsync(
+ Guid? tenantId,
+ string filter = null,
+ CancellationToken cancellationToken = default);
+ ///
+ /// 获取群组列表
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task> GetListAsync(
+ Guid? tenantId,
+ string filter = null,
+ string sorting = nameof(Group.Name),
+ int skipCount = 0,
+ int maxResultCount = 10,
+ CancellationToken cancellationToken = default);
+ }
+}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Group/IUserGroupStore.cs b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/IUserGroupStore.cs
similarity index 86%
rename from aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Group/IUserGroupStore.cs
rename to aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/IUserGroupStore.cs
index 0cd6f9058..8e104c858 100644
--- a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Group/IUserGroupStore.cs
+++ b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/IUserGroupStore.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
-namespace LINGYUN.Abp.IM.Group
+namespace LINGYUN.Abp.IM.Groups
{
public interface IUserGroupStore
{
@@ -15,7 +15,7 @@ namespace LINGYUN.Abp.IM.Group
///
///
Task MemberHasInGroupAsync(
- Guid? tenantId,
+ Guid? tenantId,
long groupId,
Guid userId,
CancellationToken cancellationToken = default);
@@ -27,8 +27,8 @@ namespace LINGYUN.Abp.IM.Group
///
///
Task GetUserGroupCardAsync(
- Guid? tenantId,
- long groupId,
+ Guid? tenantId,
+ long groupId,
Guid userId,
CancellationToken cancellationToken = default);
///
@@ -48,7 +48,7 @@ namespace LINGYUN.Abp.IM.Group
///
///
Task> GetMembersAsync(
- Guid? tenantId,
+ Guid? tenantId,
long groupId,
CancellationToken cancellationToken = default);
///
@@ -58,7 +58,7 @@ namespace LINGYUN.Abp.IM.Group
///
///
Task GetMembersCountAsync(
- Guid? tenantId,
+ Guid? tenantId,
long groupId,
CancellationToken cancellationToken = default);
///
@@ -71,10 +71,10 @@ namespace LINGYUN.Abp.IM.Group
///
///
Task> GetMembersAsync(
- Guid? tenantId,
+ Guid? tenantId,
long groupId,
- string sorting = nameof(GroupUserCard.UserId),
- int skipCount = 0,
+ string sorting = nameof(GroupUserCard.UserId),
+ int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default);
///
@@ -85,8 +85,8 @@ namespace LINGYUN.Abp.IM.Group
///
///
Task AddUserToGroupAsync(
- Guid? tenantId,
- Guid userId,
+ Guid? tenantId,
+ Guid userId,
long groupId,
Guid acceptUserId,
CancellationToken cancellationToken = default);
@@ -98,8 +98,8 @@ namespace LINGYUN.Abp.IM.Group
///
///
Task RemoveUserFormGroupAsync(
- Guid? tenantId,
- Guid userId,
+ Guid? tenantId,
+ Guid userId,
long groupId,
CancellationToken cancellationToken = default);
}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Group/UserGroup.cs b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/UserGroup.cs
similarity index 86%
rename from aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Group/UserGroup.cs
rename to aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/UserGroup.cs
index 120b13aa0..fe85caad7 100644
--- a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Group/UserGroup.cs
+++ b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/UserGroup.cs
@@ -1,13 +1,13 @@
-using System;
-
-namespace LINGYUN.Abp.IM.Group
-{
- public class UserGroup
- {
- public Guid? TenantId { get; set; }
- public Guid UserId { get; set; }
- public long GroupId { get; set; }
- public bool IsAdmin { get; set; }
- public bool IsSuperAdmin { get; set; }
- }
-}
+using System;
+
+namespace LINGYUN.Abp.IM.Groups
+{
+ public class UserGroup
+ {
+ public Guid? TenantId { get; set; }
+ public Guid UserId { get; set; }
+ public long GroupId { get; set; }
+ public bool IsAdmin { get; set; }
+ public bool IsSuperAdmin { get; set; }
+ }
+}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/IUserOnlineChanger.cs b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/IUserOnlineChanger.cs
new file mode 100644
index 000000000..a9d3b59dd
--- /dev/null
+++ b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/IUserOnlineChanger.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace LINGYUN.Abp.IM
+{
+ public interface IUserOnlineChanger
+ {
+ Task ChangeAsync(
+ Guid? tenantId,
+ Guid userId,
+ UserOnlineState state,
+ CancellationToken cancellationToken = default);
+ }
+}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/IUserOnlineChecker.cs b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/IUserOnlineChecker.cs
new file mode 100644
index 000000000..762ea20f4
--- /dev/null
+++ b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/IUserOnlineChecker.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace LINGYUN.Abp.IM
+{
+ public interface IUserOnlineChecker
+ {
+ Task CheckAsync(
+ Guid? tenantId,
+ Guid userId,
+ CancellationToken cancellationToken = default);
+ }
+}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Messages/IMessageStore.cs b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Messages/IMessageStore.cs
index b6dae836c..87553d921 100644
--- a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Messages/IMessageStore.cs
+++ b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Messages/IMessageStore.cs
@@ -26,10 +26,10 @@ namespace LINGYUN.Abp.IM.Messages
///
///
Task GetGroupMessageCountAsync(
- Guid? tenantId,
- long groupId,
- string filter = "",
+ Guid? tenantId,
+ long groupId,
MessageType? type = null,
+ string filter = "",
CancellationToken cancellationToken = default);
///
/// 获取群组聊天记录
@@ -43,12 +43,12 @@ namespace LINGYUN.Abp.IM.Messages
///
///
Task> GetGroupMessageAsync(
- Guid? tenantId,
- long groupId,
- string filter = "",
+ Guid? tenantId,
+ long groupId,
+ MessageType? type = null,
+ string filter = "",
string sorting = nameof(ChatMessage.MessageId),
- MessageType? type = null,
- int skipCount = 0,
+ int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default);
///
@@ -56,12 +56,14 @@ namespace LINGYUN.Abp.IM.Messages
///
///
///
+ ///
///
///
///
Task> GetLastChatMessagesAsync(
Guid? tenantId,
Guid userId,
+ MessageState? state = null,
string sorting = nameof(LastChatMessage.SendTime),
int maxResultCount = 10,
CancellationToken cancellationToken = default
@@ -76,27 +78,33 @@ namespace LINGYUN.Abp.IM.Messages
///
///
Task GetChatMessageCountAsync(
- Guid? tenantId,
- Guid sendUserId,
- Guid receiveUserId,
- string filter = "",
+ Guid? tenantId,
+ Guid sendUserId,
+ Guid receiveUserId,
MessageType? type = null,
+ string filter = "",
CancellationToken cancellationToken = default);
///
- /// 获取与某个用户的聊天记录
+ /// 获取用户聊天记录
///
///
- ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
///
+ ///
///
Task> GetChatMessageAsync(
Guid? tenantId,
- Guid sendUserId,
- Guid receiveUserId,
- string filter = "",
+ Guid sendUserId,
+ Guid receiveUserId,
+ MessageType? type = null,
+ string filter = "",
string sorting = nameof(ChatMessage.MessageId),
- MessageType? type = null,
- int skipCount = 0,
+ int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default);
}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/UserCard.cs b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/UserCard.cs
index ba243271e..1a5f6bc26 100644
--- a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/UserCard.cs
+++ b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/UserCard.cs
@@ -1,45 +1,47 @@
-using System;
-
-namespace LINGYUN.Abp.IM
-{
- public class UserCard
- {
- public Guid? TenantId { get; set; }
-
- public Guid UserId { get; set; }
-
- #region 细粒度的用户资料
-
- public string UserName { get; set; }
- ///
- /// 头像
- ///
- public string AvatarUrl { get; set; }
- ///
- /// 昵称
- ///
- public string NickName { get; set; }
- ///
- /// 年龄
- ///
- public int Age { get; set; }
- ///
- /// 性别
- ///
- public Sex Sex { get; set; }
- ///
- /// 签名
- ///
- public string Sign { get; set; }
- ///
- /// 说明
- ///
- public string Description { get; set; }
- ///
- /// 生日
- ///
- public DateTime? Birthday { get; set; }
-
- #endregion
- }
-}
+using System;
+
+namespace LINGYUN.Abp.IM
+{
+ public class UserCard
+ {
+ public Guid? TenantId { get; set; }
+
+ public Guid UserId { get; set; }
+
+ #region 细粒度的用户资料
+
+ public string UserName { get; set; }
+ ///
+ /// 头像
+ ///
+ public string AvatarUrl { get; set; }
+ ///
+ /// 昵称
+ ///
+ public string NickName { get; set; }
+ ///
+ /// 年龄
+ ///
+ public int Age { get; set; }
+ ///
+ /// 性别
+ ///
+ public Sex Sex { get; set; }
+ ///
+ /// 签名
+ ///
+ public string Sign { get; set; }
+ ///
+ /// 说明
+ ///
+ public string Description { get; set; }
+ ///
+ /// 生日
+ ///
+ public DateTime? Birthday { get; set; }
+
+ public bool Online { get; set; }
+
+ #endregion
+ }
+}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/UserOnlineState.cs b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/UserOnlineState.cs
new file mode 100644
index 000000000..0e895bdc7
--- /dev/null
+++ b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/UserOnlineState.cs
@@ -0,0 +1,10 @@
+namespace LINGYUN.Abp.IM
+{
+ public enum UserOnlineState
+ {
+ Online,
+ Offline,
+ Busy,
+ Stealth
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN.Abp.MessageService.Application.Contracts.csproj b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN.Abp.MessageService.Application.Contracts.csproj
index 9d27381a6..22b2813b0 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN.Abp.MessageService.Application.Contracts.csproj
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN.Abp.MessageService.Application.Contracts.csproj
@@ -28,8 +28,4 @@
-
-
-
-
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/GetUserLastMessageDto.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/GetUserLastMessageDto.cs
index ede167fd4..ea76d075c 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/GetUserLastMessageDto.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/GetUserLastMessageDto.cs
@@ -1,4 +1,5 @@
-using Volo.Abp.Application.Dtos;
+using LINGYUN.Abp.IM.Messages;
+using Volo.Abp.Application.Dtos;
namespace LINGYUN.Abp.MessageService.Chat
{
@@ -6,5 +7,6 @@ namespace LINGYUN.Abp.MessageService.Chat
{
public int MaxResultCount { get; set; }
public string Sorting { get; set; }
+ public MessageState? State { get; set; }
}
}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/IChatAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/IChatAppService.cs
index 29425cf45..b187e9784 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/IChatAppService.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/IChatAppService.cs
@@ -1,65 +1,36 @@
-using LINGYUN.Abp.IM.Messages;
-using System.Threading.Tasks;
-using Volo.Abp.Application.Dtos;
-using Volo.Abp.Application.Services;
-
-namespace LINGYUN.Abp.MessageService.Chat
-{
- public interface IChatAppService : IApplicationService
- {
- ///
- /// 发送消息
- ///
- ///
- ///
- Task SendMessageAsync(ChatMessage input);
- /////
- ///// 申请加入群组
- /////
- /////
- /////
- //Task ApplyJoinGroupAsync(UserJoinGroupDto input);
- /////
- ///// 获取我的群组
- /////
- /////
- //Task> GetMyGroupsAsync();
- /////
- ///// 获取群组用户
- /////
- /////
- /////
- //Task> GetGroupUsersAsync(GroupUserGetByPagedDto input);
- /////
- ///// 处理用户群组申请
- /////
- /////
- /////
- //Task GroupAcceptUserAsync(GroupAcceptUserDto input);
- /////
- ///// 群组移除用户
- /////
- /////
- /////
- //Task GroupRemoveUserAsync(GroupRemoveUserDto input);
- ///
- /// 获取群组消息
- ///
- ///
- ///
- Task> GetMyGroupMessageAsync(GroupMessageGetByPagedDto input);
- ///
- /// 获取我的消息
- ///
- ///
- ///
- Task> GetMyChatMessageAsync(UserMessageGetByPagedDto input);
- ///
- /// 获取我最近的消息
- ///
- ///
- ///
- Task> GetMyLastChatMessageAsync(GetUserLastMessageDto input);
- //TOTO: 还应该有获取我的未读消息 获取我的未读群组消息
- }
-}
+using LINGYUN.Abp.IM.Messages;
+using System.Threading.Tasks;
+using Volo.Abp.Application.Dtos;
+using Volo.Abp.Application.Services;
+
+namespace LINGYUN.Abp.MessageService.Chat
+{
+ public interface IChatAppService : IApplicationService
+ {
+ ///
+ /// 发送消息
+ ///
+ ///
+ ///
+ Task SendMessageAsync(ChatMessage input);
+ ///
+ /// 获取群组消息
+ ///
+ ///
+ ///
+ Task> GetMyGroupMessageAsync(GroupMessageGetByPagedDto input);
+ ///
+ /// 获取我的消息
+ ///
+ ///
+ ///
+ Task> GetMyChatMessageAsync(UserMessageGetByPagedDto input);
+ ///
+ /// 获取我最近的消息
+ ///
+ ///
+ ///
+ Task> GetMyLastChatMessageAsync(GetUserLastMessageDto input);
+ //TOTO: 还应该有获取我的未读消息 获取我的未读群组消息
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/IMyFriendAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/IMyFriendAppService.cs
index ada5421ad..f1634ec95 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/IMyFriendAppService.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/IMyFriendAppService.cs
@@ -1,20 +1,23 @@
-using LINGYUN.Abp.IM.Contract;
-using System.Threading.Tasks;
-using Volo.Abp.Application.Dtos;
-using Volo.Abp.Application.Services;
-
-namespace LINGYUN.Abp.MessageService.Chat
-{
- public interface IMyFriendAppService : IApplicationService
- {
- Task> GetListAsync(MyFriendGetByPagedDto input);
-
- Task> GetAllListAsync(GetMyFriendsDto input);
-
- Task CreateAsync(MyFriendCreateDto input);
-
- Task DeleteAsync(MyFriendOperationDto input);
-
- Task AddRequestAsync(MyFriendAddRequestDto input);
- }
-}
+using LINGYUN.Abp.IM.Contract;
+using System;
+using System.Threading.Tasks;
+using Volo.Abp.Application.Dtos;
+using Volo.Abp.Application.Services;
+
+namespace LINGYUN.Abp.MessageService.Chat
+{
+ public interface IMyFriendAppService : IApplicationService
+ {
+ Task GetAsync(Guid friendId);
+
+ Task> GetListAsync(MyFriendGetByPagedDto input);
+
+ Task> GetAllListAsync(GetMyFriendsDto input);
+
+ Task CreateAsync(MyFriendCreateDto input);
+
+ Task DeleteAsync(MyFriendOperationDto input);
+
+ Task AddRequestAsync(MyFriendAddRequestDto input);
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/GroupAcceptUserDto.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupAcceptUserDto.cs
similarity index 85%
rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/GroupAcceptUserDto.cs
rename to aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupAcceptUserDto.cs
index 667d2dad8..9ef71590e 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/GroupAcceptUserDto.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupAcceptUserDto.cs
@@ -1,19 +1,19 @@
-using System;
-using System.ComponentModel.DataAnnotations;
-
-namespace LINGYUN.Abp.MessageService.Chat
-{
- public class GroupAcceptUserDto
- {
- [Required]
- public Guid UserId { get; set; }
-
- [Required]
- public long GroupId { get; set; }
-
- public bool AllowAccept { get; set; } = true;
-
- [StringLength(64)]
- public string RejectReason { get; set; }
- }
-}
+using System;
+using System.ComponentModel.DataAnnotations;
+
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ public class GroupAcceptUserDto
+ {
+ [Required]
+ public Guid UserId { get; set; }
+
+ [Required]
+ public long GroupId { get; set; }
+
+ public bool AllowAccept { get; set; } = true;
+
+ [StringLength(64)]
+ public string RejectReason { get; set; }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/GroupRemoveUserDto.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupRemoveUserDto.cs
similarity index 80%
rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/GroupRemoveUserDto.cs
rename to aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupRemoveUserDto.cs
index 3996c4f29..f330f61f1 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/GroupRemoveUserDto.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupRemoveUserDto.cs
@@ -1,14 +1,14 @@
-using System;
-using System.ComponentModel.DataAnnotations;
-
-namespace LINGYUN.Abp.MessageService.Chat
-{
- public class GroupRemoveUserDto
- {
- [Required]
- public Guid UserId { get; set; }
-
- [Required]
- public long GroupId { get; set; }
- }
-}
+using System;
+using System.ComponentModel.DataAnnotations;
+
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ public class GroupRemoveUserDto
+ {
+ [Required]
+ public Guid UserId { get; set; }
+
+ [Required]
+ public long GroupId { get; set; }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupSearchInput.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupSearchInput.cs
new file mode 100644
index 000000000..2246f26bb
--- /dev/null
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupSearchInput.cs
@@ -0,0 +1,9 @@
+using Volo.Abp.Application.Dtos;
+
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ public class GroupSearchInput : PagedAndSortedResultRequestDto
+ {
+ public string Filter { get; set; }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/GroupUserGetByPagedDto.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupUserGetByPagedDto.cs
similarity index 82%
rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/GroupUserGetByPagedDto.cs
rename to aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupUserGetByPagedDto.cs
index d1a77cde7..0446fbb5a 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/GroupUserGetByPagedDto.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupUserGetByPagedDto.cs
@@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Application.Dtos;
-namespace LINGYUN.Abp.MessageService.Chat
+namespace LINGYUN.Abp.MessageService.Groups
{
public class GroupUserGetByPagedDto : PagedAndSortedResultRequestDto
{
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/UserJoinGroupDto.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/UserJoinGroupDto.cs
similarity index 81%
rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/UserJoinGroupDto.cs
rename to aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/UserJoinGroupDto.cs
index a42ec1999..30d2694bd 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/UserJoinGroupDto.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/UserJoinGroupDto.cs
@@ -1,14 +1,14 @@
-using System.ComponentModel.DataAnnotations;
-
-namespace LINGYUN.Abp.MessageService.Chat
-{
- public class UserJoinGroupDto
- {
- [Required]
- public long GroupId { get; set; }
-
- [Required]
- [StringLength(100)]
- public string JoinInfo { get; set; }
- }
-}
+using System.ComponentModel.DataAnnotations;
+
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ public class UserJoinGroupDto
+ {
+ [Required]
+ public long GroupId { get; set; }
+
+ [Required]
+ [StringLength(100)]
+ public string JoinInfo { get; set; }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/IGroupAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/IGroupAppService.cs
new file mode 100644
index 000000000..224490e3e
--- /dev/null
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/IGroupAppService.cs
@@ -0,0 +1,23 @@
+using LINGYUN.Abp.IM.Groups;
+using System.Threading.Tasks;
+using Volo.Abp.Application.Dtos;
+using Volo.Abp.Application.Services;
+
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ public interface IGroupAppService : IApplicationService
+ {
+ ///
+ /// 搜索群组
+ ///
+ ///
+ ///
+ Task> SearchAsync(GroupSearchInput input);
+ ///
+ /// 获取群组信息
+ ///
+ ///
+ ///
+ Task GetAsync(string groupId);
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/IUserGroupAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/IUserGroupAppService.cs
new file mode 100644
index 000000000..79c063437
--- /dev/null
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/IUserGroupAppService.cs
@@ -0,0 +1,40 @@
+using LINGYUN.Abp.IM.Groups;
+using System.Threading.Tasks;
+using Volo.Abp.Application.Dtos;
+using Volo.Abp.Application.Services;
+
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ public interface IUserGroupAppService : IApplicationService
+ {
+ ///
+ /// 申请加入群组
+ ///
+ ///
+ ///
+ Task ApplyJoinGroupAsync(UserJoinGroupDto input);
+ ///
+ /// 获取我的群组
+ ///
+ ///
+ Task> GetMyGroupsAsync();
+ ///
+ /// 获取群组用户
+ ///
+ ///
+ ///
+ Task> GetGroupUsersAsync(GroupUserGetByPagedDto input);
+ ///
+ /// 处理用户群组申请
+ ///
+ ///
+ ///
+ Task GroupAcceptUserAsync(GroupAcceptUserDto input);
+ ///
+ /// 群组移除用户
+ ///
+ ///
+ ///
+ Task GroupRemoveUserAsync(GroupRemoveUserDto input);
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationServiceBase.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationServiceBase.cs
new file mode 100644
index 000000000..c430904ab
--- /dev/null
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationServiceBase.cs
@@ -0,0 +1,14 @@
+using LINGYUN.Abp.MessageService.Localization;
+using Volo.Abp.Application.Services;
+
+namespace LINGYUN.Abp.MessageService
+{
+ public abstract class AbpMessageServiceApplicationServiceBase : ApplicationService
+ {
+ protected AbpMessageServiceApplicationServiceBase()
+ {
+ LocalizationResource = typeof(MessageServiceResource);
+ ObjectMapperContext = typeof(AbpMessageServiceApplicationModule);
+ }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Chat/ChatAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Chat/ChatAppService.cs
index 0f37e2044..ec84089b3 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Chat/ChatAppService.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Chat/ChatAppService.cs
@@ -1,4 +1,4 @@
-using LINGYUN.Abp.IM.Group;
+using LINGYUN.Abp.IM.Groups;
using LINGYUN.Abp.IM.Messages;
using Microsoft.AspNetCore.Authorization;
using System.Threading.Tasks;
@@ -28,13 +28,23 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task> GetMyChatMessageAsync(UserMessageGetByPagedDto input)
{
var chatMessageCount = await _messageStore
- .GetChatMessageCountAsync(CurrentTenant.Id, CurrentUser.GetId(), input.ReceiveUserId,
- input.Filter, input.MessageType);
+ .GetChatMessageCountAsync(
+ CurrentTenant.Id,
+ CurrentUser.GetId(),
+ input.ReceiveUserId,
+ input.MessageType,
+ input.Filter);
var chatMessages = await _messageStore
- .GetChatMessageAsync(CurrentTenant.Id, CurrentUser.GetId(), input.ReceiveUserId,
- input.Filter, input.Sorting,
- input.MessageType, input.SkipCount, input.MaxResultCount);
+ .GetChatMessageAsync(
+ CurrentTenant.Id,
+ CurrentUser.GetId(),
+ input.ReceiveUserId,
+ input.MessageType,
+ input.Filter,
+ input.Sorting,
+ input.SkipCount,
+ input.MaxResultCount);
return new PagedResultDto(chatMessageCount, chatMessages);
}
@@ -42,86 +52,43 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task> GetMyLastChatMessageAsync(GetUserLastMessageDto input)
{
var chatMessages = await _messageStore
- .GetLastChatMessagesAsync(CurrentTenant.Id, CurrentUser.GetId(),
- input.Sorting, input.MaxResultCount);
+ .GetLastChatMessagesAsync(
+ CurrentTenant.Id,
+ CurrentUser.GetId(),
+ input.State,
+ input.Sorting,
+ input.MaxResultCount);
return new ListResultDto(chatMessages);
}
public virtual async Task> GetMyGroupMessageAsync(GroupMessageGetByPagedDto input)
{
- if (! await _userGroupStore.MemberHasInGroupAsync(CurrentTenant.Id, input.GroupId, CurrentUser.GetId()))
+ if (!await _userGroupStore.MemberHasInGroupAsync(CurrentTenant.Id, input.GroupId, CurrentUser.GetId()))
{
throw new BusinessException(MessageServiceErrorCodes.YouHaveNotJoinedGroup);
}
var groupMessageCount = await _messageStore
- .GetGroupMessageCountAsync(CurrentTenant.Id, input.GroupId,
- input.Filter, input.MessageType);
+ .GetGroupMessageCountAsync(
+ CurrentTenant.Id,
+ input.GroupId,
+ input.MessageType,
+ input.Filter);
var groupMessages = await _messageStore
- .GetGroupMessageAsync(CurrentTenant.Id, input.GroupId,
- input.Filter, input.Sorting,
- input.MessageType, input.SkipCount, input.MaxResultCount);
+ .GetGroupMessageAsync(
+ CurrentTenant.Id,
+ input.GroupId,
+ input.MessageType,
+ input.Filter,
+ input.Sorting,
+ input.SkipCount,
+ input.MaxResultCount);
return new PagedResultDto(groupMessageCount, groupMessages);
}
- //public virtual async Task> GetGroupUsersAsync(GroupUserGetByPagedDto input)
- //{
- // var groupUserCardCount = await _userGroupStore
- // .GetMembersCountAsync(CurrentTenant.Id, input.GroupId);
-
- // var groupUserCards = await _userGroupStore.GetMembersAsync(CurrentTenant.Id,
- // input.GroupId, input.Sorting, input.Reverse,
- // input.SkipCount, input.MaxResultCount);
-
- // return new PagedResultDto(groupUserCardCount, groupUserCards);
- //}
-
- //[Authorize]
- //public virtual async Task> GetMyGroupsAsync()
- //{
- // var myGroups = await _userGroupStore.GetUserGroupsAsync(CurrentTenant.Id, CurrentUser.GetId());
-
- // return new ListResultDto(myGroups.ToImmutableList());
- //}
-
- //public virtual async Task GroupAcceptUserAsync(GroupAcceptUserDto input)
- //{
- // var myGroupCard = await _userGroupStore
- // .GetUserGroupCardAsync(CurrentTenant.Id, input.GroupId, CurrentUser.GetId());
- // if (myGroupCard == null)
- // {
- // // 当前登录用户不再用户组
- // throw new UserFriendlyException("");
- // }
- // if (!myGroupCard.IsAdmin)
- // {
- // // 当前登录用户没有加人权限
- // throw new UserFriendlyException("");
- // }
- // await _userGroupStore
- // .AddUserToGroupAsync(CurrentTenant.Id, input.UserId, input.GroupId, CurrentUser.GetId());
- //}
-
- //public virtual async Task GroupRemoveUserAsync(GroupRemoveUserDto input)
- //{
- // var myGroupCard = await _userGroupStore
- // .GetUserGroupCardAsync(CurrentTenant.Id, input.GroupId, CurrentUser.GetId());
- // if (myGroupCard == null)
- // {
- // // 当前登录用户不再用户组
- // throw new UserFriendlyException("");
- // }
- // if (!myGroupCard.IsAdmin)
- // {
- // // 当前登录用户没有踢人权限
- // throw new UserFriendlyException("");
- // }
- // await _userGroupStore
- // .RemoveUserFormGroupAsync(CurrentTenant.Id, input.UserId, input.GroupId);
- //}
public virtual async Task SendMessageAsync(ChatMessage input)
{
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Chat/MyFriendAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Chat/MyFriendAppService.cs
index 101dccaec..079e8da3e 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Chat/MyFriendAppService.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Chat/MyFriendAppService.cs
@@ -1,6 +1,7 @@
using LINGYUN.Abp.IM.Contract;
using LINGYUN.Abp.MessageService.Localization;
using Microsoft.AspNetCore.Authorization;
+using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
@@ -25,6 +26,11 @@ namespace LINGYUN.Abp.MessageService.Chat
LocalizationResource = typeof(MessageServiceResource);
}
+ public virtual async Task GetAsync(Guid friendId)
+ {
+ return await FriendStore.GetMemberAsync(CurrentTenant.Id, CurrentUser.GetId(), friendId);
+ }
+
public virtual async Task CreateAsync(MyFriendCreateDto input)
{
var friendCard = await UserChatCardRepository.GetMemberAsync(input.FriendId);
@@ -59,7 +65,7 @@ namespace LINGYUN.Abp.MessageService.Chat
var myFriends = await FriendStore
.GetPagedListAsync(CurrentTenant.Id, CurrentUser.GetId(),
- input.Filter, input.Sorting,
+ input.Filter, input.Sorting,
input.SkipCount, input.MaxResultCount);
return new PagedResultDto(myFrientCount, myFriends);
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Groups/GroupAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Groups/GroupAppService.cs
new file mode 100644
index 000000000..a06e295f4
--- /dev/null
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Groups/GroupAppService.cs
@@ -0,0 +1,40 @@
+using LINGYUN.Abp.IM.Groups;
+using Microsoft.AspNetCore.Authorization;
+using System.Threading.Tasks;
+using Volo.Abp.Application.Dtos;
+
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ [AllowAnonymous]
+ public class GroupAppService : AbpMessageServiceApplicationServiceBase, IGroupAppService
+ {
+ private readonly IGroupStore _groupStore;
+
+ public GroupAppService(
+ IGroupStore groupStore)
+ {
+ _groupStore = groupStore;
+ }
+
+ public virtual async Task GetAsync(string groupId)
+ {
+ return await _groupStore.GetAsync(CurrentTenant.Id, groupId);
+ }
+
+ public virtual async Task> SearchAsync(GroupSearchInput input)
+ {
+ var count = await _groupStore.GetCountAsync(
+ CurrentTenant.Id,
+ input.Filter);
+
+ var groups = await _groupStore.GetListAsync(
+ CurrentTenant.Id,
+ input.Filter,
+ input.Sorting,
+ input.SkipCount,
+ input.MaxResultCount);
+
+ return new PagedResultDto(count, groups);
+ }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Groups/UserGroupAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Groups/UserGroupAppService.cs
new file mode 100644
index 000000000..cd7353697
--- /dev/null
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Groups/UserGroupAppService.cs
@@ -0,0 +1,86 @@
+using LINGYUN.Abp.IM.Groups;
+using Microsoft.AspNetCore.Authorization;
+using System;
+using System.Collections.Immutable;
+using System.Threading.Tasks;
+using Volo.Abp;
+using Volo.Abp.Application.Dtos;
+using Volo.Abp.Users;
+
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ [Authorize]
+ public class UserGroupAppService : AbpMessageServiceApplicationServiceBase, IUserGroupAppService
+ {
+ private readonly IUserGroupStore _userGroupStore;
+
+ public UserGroupAppService(
+ IUserGroupStore userGroupStore)
+ {
+ _userGroupStore = userGroupStore;
+ }
+
+ public virtual Task ApplyJoinGroupAsync(UserJoinGroupDto input)
+ {
+ throw new NotImplementedException();
+ }
+
+ public virtual async Task> GetGroupUsersAsync(GroupUserGetByPagedDto input)
+ {
+ var groupUserCardCount = await _userGroupStore
+ .GetMembersCountAsync(CurrentTenant.Id, input.GroupId);
+
+ var groupUserCards = await _userGroupStore.GetMembersAsync(
+ CurrentTenant.Id,
+ input.GroupId,
+ input.Sorting,
+ input.SkipCount,
+ input.MaxResultCount);
+
+ return new PagedResultDto(groupUserCardCount, groupUserCards);
+ }
+
+ public virtual async Task> GetMyGroupsAsync()
+ {
+ var myGroups = await _userGroupStore.GetUserGroupsAsync(CurrentTenant.Id, CurrentUser.GetId());
+
+ return new ListResultDto(myGroups.ToImmutableList());
+ }
+
+ public virtual async Task GroupAcceptUserAsync(GroupAcceptUserDto input)
+ {
+ var myGroupCard = await _userGroupStore
+ .GetUserGroupCardAsync(CurrentTenant.Id, input.GroupId, CurrentUser.GetId());
+ if (myGroupCard == null)
+ {
+ // 当前登录用户不再用户组
+ throw new UserFriendlyException("");
+ }
+ if (!myGroupCard.IsAdmin)
+ {
+ // 当前登录用户没有加人权限
+ throw new UserFriendlyException("");
+ }
+ await _userGroupStore
+ .AddUserToGroupAsync(CurrentTenant.Id, input.UserId, input.GroupId, CurrentUser.GetId());
+ }
+
+ public virtual async Task GroupRemoveUserAsync(GroupRemoveUserDto input)
+ {
+ var myGroupCard = await _userGroupStore
+ .GetUserGroupCardAsync(CurrentTenant.Id, input.GroupId, CurrentUser.GetId());
+ if (myGroupCard == null)
+ {
+ // 当前登录用户不再用户组
+ throw new UserFriendlyException("");
+ }
+ if (!myGroupCard.IsAdmin)
+ {
+ // 当前登录用户没有踢人权限
+ throw new UserFriendlyException("");
+ }
+ await _userGroupStore
+ .RemoveUserFormGroupAsync(CurrentTenant.Id, input.UserId, input.GroupId);
+ }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Group/ChatGroupConsts.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Groups/ChatGroupConsts.cs
similarity index 71%
rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Group/ChatGroupConsts.cs
rename to aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Groups/ChatGroupConsts.cs
index 1cb2174a4..1e9433f87 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Group/ChatGroupConsts.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Groups/ChatGroupConsts.cs
@@ -1,15 +1,17 @@
-namespace LINGYUN.Abp.MessageService.Group
-{
- public class ChatGroupConsts
- {
- public const int MaxNameLength = 20;
-
- public const int MaxTagLength = 512;
-
- public const int MaxAddressLength = 256;
-
- public const int MaxNoticeLength = 64;
-
- public const int MaxDescriptionLength = 128;
- }
-}
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ public class ChatGroupConsts
+ {
+ public const int MaxNameLength = 20;
+
+ public const int MaxTagLength = 512;
+
+ public const int MaxAddressLength = 256;
+
+ public const int MaxNoticeLength = 64;
+
+ public const int MaxDescriptionLength = 128;
+
+ public const int MaxAvatarUrlLength = 128;
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/IMessageRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/IMessageRepository.cs
index 920209bd5..cfee7374a 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/IMessageRepository.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/IMessageRepository.cs
@@ -1,5 +1,5 @@
using LINGYUN.Abp.IM.Messages;
-using LINGYUN.Abp.MessageService.Group;
+using LINGYUN.Abp.MessageService.Groups;
using System;
using System.Collections.Generic;
using System.Threading;
@@ -26,35 +26,36 @@ namespace LINGYUN.Abp.MessageService.Chat
CancellationToken cancellationToken = default);
Task GetUserMessageAsync(
- long id,
+ long id,
CancellationToken cancellationToken = default);
Task GetGroupMessageAsync(
- long id,
+ long id,
CancellationToken cancellationToken = default);
Task GetUserMessagesCountAsync(
- Guid sendUserId,
- Guid receiveUserId,
- string filter = "",
- MessageType? type = null,
+ Guid sendUserId,
+ Guid receiveUserId,
+ MessageType? type = null,
+ string filter = "",
CancellationToken cancellationToken = default);
Task GetCountAsync(
long groupId,
- string filter = "",
MessageType? type = null,
+ string filter = "",
CancellationToken cancellationToken = default);
Task GetCountAsync(
Guid sendUserId,
Guid receiveUserId,
- string filter = "",
MessageType? type = null,
+ string filter = "",
CancellationToken cancellationToken = default);
- Task> GetLastMessagesByOneFriendAsync(
+ Task> GetLastMessagesAsync(
Guid userId,
+ MessageState? state = null,
string sorting = nameof(LastChatMessage.SendTime),
int maxResultCount = 10,
CancellationToken cancellationToken = default);
@@ -62,42 +63,42 @@ namespace LINGYUN.Abp.MessageService.Chat
Task> GetUserMessagesAsync(
Guid sendUserId,
Guid receiveUserId,
- string filter = "",
- string sorting = nameof(UserMessage.MessageId),
- MessageType? type = null,
- int skipCount = 0,
+ MessageType? type = null,
+ string filter = "",
+ string sorting = nameof(UserMessage.MessageId),
+ int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default);
Task GetGroupMessagesCountAsync(
- long groupId,
- string filter = "",
+ long groupId,
MessageType? type = null,
+ string filter = "",
CancellationToken cancellationToken = default);
Task> GetGroupMessagesAsync(
long groupId,
+ MessageType? type = null,
string filter = "",
string sorting = nameof(UserMessage.MessageId),
- MessageType? type = null,
- int skipCount = 0,
+ int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default);
Task GetUserGroupMessagesCountAsync(
- Guid sendUserId,
- long groupId,
- string filter = "",
+ Guid sendUserId,
+ long groupId,
MessageType? type = null,
+ string filter = "",
CancellationToken cancellationToken = default);
Task> GetUserGroupMessagesAsync(
- Guid sendUserId,
- long groupId,
+ Guid sendUserId,
+ long groupId,
+ MessageType? type = null,
string filter = "",
string sorting = nameof(UserMessage.MessageId),
- MessageType? type = null,
- int skipCount = 0,
+ int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default);
}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/IUserChatCardRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/IUserChatCardRepository.cs
index 9cbbbd0d2..da4805e1e 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/IUserChatCardRepository.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/IUserChatCardRepository.cs
@@ -9,6 +9,10 @@ namespace LINGYUN.Abp.MessageService.Chat
{
public interface IUserChatCardRepository : IBasicRepository
{
+ Task FindByUserIdAsync(
+ Guid userId,
+ CancellationToken cancellationToken = default);
+
Task CheckUserIdExistsAsync(
Guid userId,
CancellationToken cancellationToken = default);
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/MessageStore.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/MessageStore.cs
index 5254d8ae6..1d3726f82 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/MessageStore.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/MessageStore.cs
@@ -1,6 +1,6 @@
using LINGYUN.Abp.IM.Contract;
using LINGYUN.Abp.IM.Messages;
-using LINGYUN.Abp.MessageService.Group;
+using LINGYUN.Abp.MessageService.Groups;
using System;
using System.Collections.Generic;
using System.Threading;
@@ -70,19 +70,26 @@ namespace LINGYUN.Abp.MessageService.Chat
}
public virtual async Task> GetGroupMessageAsync(
- Guid? tenantId,
+ Guid? tenantId,
long groupId,
+ MessageType? type = null,
string filter = "",
string sorting = nameof(ChatMessage.MessageId),
- MessageType? type = null,
- int skipCount = 0,
+ int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
using (_currentTenant.Change(tenantId))
{
var groupMessages = await _messageRepository
- .GetGroupMessagesAsync(groupId, filter, sorting, type, skipCount, maxResultCount, cancellationToken);
+ .GetGroupMessagesAsync(
+ groupId,
+ type,
+ filter,
+ sorting,
+ skipCount,
+ maxResultCount,
+ cancellationToken);
var chatMessages = _objectMapper.Map, List>(groupMessages);
@@ -91,20 +98,28 @@ namespace LINGYUN.Abp.MessageService.Chat
}
public virtual async Task> GetChatMessageAsync(
- Guid? tenantId,
- Guid sendUserId,
- Guid receiveUserId,
+ Guid? tenantId,
+ Guid sendUserId,
+ Guid receiveUserId,
+ MessageType? type = null,
string filter = "",
string sorting = nameof(ChatMessage.MessageId),
- MessageType? type = null,
- int skipCount = 0,
+ int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
using (_currentTenant.Change(tenantId))
{
var userMessages = await _messageRepository
- .GetUserMessagesAsync(sendUserId, receiveUserId, filter, sorting, type, skipCount, maxResultCount, cancellationToken);
+ .GetUserMessagesAsync(
+ sendUserId,
+ receiveUserId,
+ type,
+ filter,
+ sorting,
+ skipCount,
+ maxResultCount,
+ cancellationToken);
var chatMessages = _objectMapper.Map, List>(userMessages);
@@ -115,6 +130,7 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task> GetLastChatMessagesAsync(
Guid? tenantId,
Guid userId,
+ MessageState? state = null,
string sorting = nameof(LastChatMessage.SendTime),
int maxResultCount = 10,
CancellationToken cancellationToken = default
@@ -123,34 +139,34 @@ namespace LINGYUN.Abp.MessageService.Chat
using (_currentTenant.Change(tenantId))
{
return await _messageRepository
- .GetLastMessagesByOneFriendAsync(userId, sorting, maxResultCount, cancellationToken);
+ .GetLastMessagesAsync(userId, state, sorting, maxResultCount, cancellationToken);
}
}
public virtual async Task GetGroupMessageCountAsync(
- Guid? tenantId,
- long groupId,
- string filter = "",
+ Guid? tenantId,
+ long groupId,
MessageType? type = null,
+ string filter = "",
CancellationToken cancellationToken = default)
{
using (_currentTenant.Change(tenantId))
{
- return await _messageRepository.GetCountAsync(groupId, filter, type, cancellationToken);
+ return await _messageRepository.GetCountAsync(groupId, type, filter, cancellationToken);
}
}
public virtual async Task GetChatMessageCountAsync(
Guid? tenantId,
- Guid sendUserId,
- Guid receiveUserId,
- string filter = "",
+ Guid sendUserId,
+ Guid receiveUserId,
MessageType? type = null,
+ string filter = "",
CancellationToken cancellationToken = default)
{
using (_currentTenant.Change(tenantId))
{
- return await _messageRepository.GetCountAsync(sendUserId, receiveUserId, filter, type, cancellationToken);
+ return await _messageRepository.GetCountAsync(sendUserId, receiveUserId, type, filter, cancellationToken);
}
}
@@ -202,10 +218,10 @@ namespace LINGYUN.Abp.MessageService.Chat
}
var message = new UserMessage(
- long.Parse(chatMessage.MessageId),
- chatMessage.FormUserId,
- chatMessage.FormUserName,
- chatMessage.Content,
+ long.Parse(chatMessage.MessageId),
+ chatMessage.FormUserId,
+ chatMessage.FormUserName,
+ chatMessage.Content,
chatMessage.MessageType);
message.SendToUser(chatMessage.ToUserId.Value);
@@ -215,7 +231,7 @@ namespace LINGYUN.Abp.MessageService.Chat
}
protected virtual async Task StoreGroupMessageAsync(
- ChatMessage chatMessage,
+ ChatMessage chatMessage,
long groupId,
CancellationToken cancellationToken = default)
{
@@ -239,10 +255,10 @@ namespace LINGYUN.Abp.MessageService.Chat
}
var message = new GroupMessage(
- long.Parse(chatMessage.MessageId),
- chatMessage.FormUserId,
- chatMessage.FormUserName,
- chatMessage.Content,
+ long.Parse(chatMessage.MessageId),
+ chatMessage.FormUserId,
+ chatMessage.FormUserName,
+ chatMessage.Content,
chatMessage.MessageType);
message.SendToGroup(groupId);
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/UserChatCard.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/UserChatCard.cs
index 46c4eb463..0a64fdf73 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/UserChatCard.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/UserChatCard.cs
@@ -1,105 +1,119 @@
-using LINGYUN.Abp.IM;
-using LINGYUN.Abp.MessageService.Utils;
-using System;
-using Volo.Abp.Domain.Entities.Auditing;
-using Volo.Abp.MultiTenancy;
-using Volo.Abp.Timing;
-
-namespace LINGYUN.Abp.MessageService.Chat
-{
- ///
- /// 用户卡片
- ///
- public class UserChatCard : AuditedAggregateRoot, IMultiTenant
- {
- ///
- /// 租户
- ///
- public virtual Guid? TenantId { get; protected set; }
- ///
- /// 用户标识
- ///
- public virtual Guid UserId { get; protected set; }
- ///
- /// 用户名
- ///
- public virtual string UserName { get; protected set; }
- ///
- /// 性别
- ///
- public virtual Sex Sex { get; set; }
- ///
- /// 签名
- ///
- public virtual string Sign { get; set; }
- ///
- /// 昵称
- ///
- public virtual string NickName { get; set; }
- ///
- /// 说明
- ///
- public virtual string Description { get; set; }
- ///
- /// 头像地址
- ///
- public virtual string AvatarUrl { get; protected set; }
- ///
- /// 生日
- ///
- public virtual DateTime? Birthday { get; protected set; }
- ///
- /// 年龄
- ///
- public virtual int Age { get; protected set; }
-
- protected UserChatCard()
- {
- }
-
- public UserChatCard(
- Guid userId,
- string userName,
- Sex sex,
- string nickName = null,
- string avatarUrl = "",
- Guid? tenantId = null)
- {
- Sex = sex;
- UserId = userId;
- UserName = userName;
- NickName = nickName ?? userName;
- AvatarUrl = avatarUrl;
- TenantId = tenantId;
- }
-
- public void SetBirthday(DateTime birthday, IClock clock)
- {
- Birthday = birthday;
-
- Age = DateTimeHelper.CalcAgrByBirthdate(birthday, clock.Now);
- }
-
- public void SetAvatarUrl(string url)
- {
- AvatarUrl = url;
- }
-
- public UserCard ToUserCard()
- {
- return new UserCard
- {
- Age = Age,
- AvatarUrl = AvatarUrl,
- Birthday = Birthday,
- Description = Description,
- NickName = NickName,
- Sex = Sex,
- Sign = Sign,
- UserId = UserId,
- UserName = UserName,
- TenantId = TenantId
- };
- }
- }
-}
+using LINGYUN.Abp.IM;
+using LINGYUN.Abp.MessageService.Utils;
+using System;
+using Volo.Abp.Domain.Entities.Auditing;
+using Volo.Abp.MultiTenancy;
+using Volo.Abp.Timing;
+
+namespace LINGYUN.Abp.MessageService.Chat
+{
+ ///
+ /// 用户卡片
+ ///
+ public class UserChatCard : AuditedAggregateRoot, IMultiTenant
+ {
+ ///
+ /// 租户
+ ///
+ public virtual Guid? TenantId { get; protected set; }
+ ///
+ /// 用户标识
+ ///
+ public virtual Guid UserId { get; protected set; }
+ ///
+ /// 用户名
+ ///
+ public virtual string UserName { get; protected set; }
+ ///
+ /// 性别
+ ///
+ public virtual Sex Sex { get; set; }
+ ///
+ /// 签名
+ ///
+ public virtual string Sign { get; set; }
+ ///
+ /// 昵称
+ ///
+ public virtual string NickName { get; set; }
+ ///
+ /// 说明
+ ///
+ public virtual string Description { get; set; }
+ ///
+ /// 头像地址
+ ///
+ public virtual string AvatarUrl { get; protected set; }
+ ///
+ /// 生日
+ ///
+ public virtual DateTime? Birthday { get; protected set; }
+ ///
+ /// 年龄
+ ///
+ public virtual int Age { get; protected set; }
+
+ public virtual DateTime? LastOnlineTime { get; protected set; }
+
+ public virtual UserOnlineState State { get; protected set; }
+
+ protected UserChatCard()
+ {
+ }
+
+ public UserChatCard(
+ Guid userId,
+ string userName,
+ Sex sex,
+ string nickName = null,
+ string avatarUrl = "",
+ Guid? tenantId = null)
+ {
+ Sex = sex;
+ UserId = userId;
+ UserName = userName;
+ NickName = nickName ?? userName;
+ AvatarUrl = avatarUrl;
+ TenantId = tenantId;
+ }
+
+ public void SetBirthday(DateTime birthday, IClock clock)
+ {
+ Birthday = birthday;
+
+ Age = DateTimeHelper.CalcAgrByBirthdate(birthday, clock.Now);
+ }
+
+ public void SetAvatarUrl(string url)
+ {
+ AvatarUrl = url;
+ }
+
+ public void ChangeState(IClock clock, UserOnlineState state)
+ {
+ State = state;
+ if (State == UserOnlineState.Online)
+ {
+ LastOnlineTime = clock.Now;
+ }
+ }
+
+ public UserCard ToUserCard()
+ {
+ return new UserCard
+ {
+ Age = Age,
+ AvatarUrl = AvatarUrl,
+ Birthday = Birthday,
+ Description = Description,
+ NickName = NickName,
+ Sex = Sex,
+ Sign = Sign,
+ UserId = UserId,
+ UserName = UserName,
+ TenantId = TenantId,
+ Online = State == UserOnlineState.Online,
+ };
+ }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/IGroupRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/IGroupRepository.cs
deleted file mode 100644
index 58fa823e6..000000000
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/IGroupRepository.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using Volo.Abp.Domain.Repositories;
-
-namespace LINGYUN.Abp.MessageService.Group
-{
- public interface IGroupRepository : IBasicRepository
- {
- ///
- /// 用户是否已被拉黑
- ///
- ///
- ///
- ///
- Task UserHasBlackedAsync(
- long id,
- Guid formUserId,
- CancellationToken cancellationToken = default);
-
- Task FindByIdAsync(
- long id,
- CancellationToken cancellationToken = default);
-
- Task> GetGroupAdminAsync(
- long id,
- CancellationToken cancellationToken = default);
-
- }
-}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/ChatGroup.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/ChatGroup.cs
similarity index 84%
rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/ChatGroup.cs
rename to aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/ChatGroup.cs
index 66f9382e4..531786ce7 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/ChatGroup.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/ChatGroup.cs
@@ -1,75 +1,79 @@
-using System;
-using Volo.Abp.Domain.Entities.Auditing;
-using Volo.Abp.MultiTenancy;
-
-namespace LINGYUN.Abp.MessageService.Group
-{
- ///
- /// 聊天群组
- ///
- public class ChatGroup : AuditedEntity, IMultiTenant
- {
- ///
- /// 租户
- ///
- public virtual Guid? TenantId { get; protected set; }
- ///
- /// 群主
- ///
- public virtual Guid AdminUserId { get; protected set; }
- ///
- /// 群组标识
- ///
- public virtual long GroupId { get; protected set; }
- ///
- /// 群组名称
- ///
- public virtual string Name { get; protected set; }
- ///
- /// 群组标记
- ///
- public virtual string Tag { get; protected set; }
- ///
- /// 群组地址
- ///
- public virtual string Address { get; set; }
- ///
- /// 群组公告
- ///
- public virtual string Notice { get; set; }
- ///
- /// 最大用户数量
- ///
- public virtual int MaxUserCount { get; protected set; }
- ///
- /// 允许匿名聊天
- ///
- public virtual bool AllowAnonymous { get; set; }
- ///
- /// 允许发送消息
- ///
- public virtual bool AllowSendMessage { get; set; }
- ///
- /// 群组说明
- ///
- public virtual string Description { get; set; }
- protected ChatGroup()
- {
- }
- public ChatGroup(
- long id,
- Guid adminUserId,
- string name,
- string tag = "",
- string address = "",
- int maxUserCount = 200)
- {
- GroupId = id;
- AdminUserId = adminUserId;
- Name = name;
- Tag = tag;
- Address = address;
- MaxUserCount = maxUserCount;
- }
- }
-}
+using System;
+using Volo.Abp.Domain.Entities.Auditing;
+using Volo.Abp.MultiTenancy;
+
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ ///
+ /// 聊天群组
+ ///
+ public class ChatGroup : AuditedEntity, IMultiTenant
+ {
+ ///
+ /// 租户
+ ///
+ public virtual Guid? TenantId { get; protected set; }
+ ///
+ /// 群主
+ ///
+ public virtual Guid AdminUserId { get; protected set; }
+ ///
+ /// 群组标识
+ ///
+ public virtual long GroupId { get; protected set; }
+ ///
+ /// 群组名称
+ ///
+ public virtual string Name { get; protected set; }
+ ///
+ /// 群组标记
+ ///
+ public virtual string Tag { get; protected set; }
+ ///
+ /// 群组地址
+ ///
+ public virtual string Address { get; set; }
+ ///
+ /// 群组公告
+ ///
+ public virtual string Notice { get; set; }
+ ///
+ /// 最大用户数量
+ ///
+ public virtual int MaxUserCount { get; protected set; }
+ ///
+ /// 允许匿名聊天
+ ///
+ public virtual bool AllowAnonymous { get; set; }
+ ///
+ /// 允许发送消息
+ ///
+ public virtual bool AllowSendMessage { get; set; }
+ ///
+ /// 群组说明
+ ///
+ public virtual string Description { get; set; }
+ ///
+ /// 群组头像地址
+ ///
+ public virtual string AvatarUrl { get; set; }
+ protected ChatGroup()
+ {
+ }
+ public ChatGroup(
+ long id,
+ Guid adminUserId,
+ string name,
+ string tag = "",
+ string address = "",
+ int maxUserCount = 200)
+ {
+ GroupId = id;
+ AdminUserId = adminUserId;
+ Name = name;
+ Tag = tag;
+ Address = address;
+ MaxUserCount = maxUserCount;
+ }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/GroupChatBlack.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/GroupChatBlack.cs
similarity index 92%
rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/GroupChatBlack.cs
rename to aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/GroupChatBlack.cs
index 8d07295c8..7a40e2b28 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/GroupChatBlack.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/GroupChatBlack.cs
@@ -1,32 +1,32 @@
-using System;
-using Volo.Abp.Domain.Entities.Auditing;
-using Volo.Abp.MultiTenancy;
-
-namespace LINGYUN.Abp.MessageService.Group
-{
- ///
- /// 用户黑名单
- ///
- public class GroupChatBlack : CreationAuditedEntity, IMultiTenant
- {
- ///
- /// 租户
- ///
- public virtual Guid? TenantId { get; protected set; }
- ///
- /// 群组标识
- ///
- public virtual long GroupId { get; protected set; }
- ///
- /// 拉黑的用户
- ///
- public virtual Guid ShieldUserId { get; protected set; }
- protected GroupChatBlack() { }
- public GroupChatBlack(long groupId, Guid shieldUserId, Guid? tenantId)
- {
- GroupId = groupId;
- ShieldUserId = shieldUserId;
- TenantId = tenantId;
- }
- }
-}
+using System;
+using Volo.Abp.Domain.Entities.Auditing;
+using Volo.Abp.MultiTenancy;
+
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ ///
+ /// 用户黑名单
+ ///
+ public class GroupChatBlack : CreationAuditedEntity, IMultiTenant
+ {
+ ///
+ /// 租户
+ ///
+ public virtual Guid? TenantId { get; protected set; }
+ ///
+ /// 群组标识
+ ///
+ public virtual long GroupId { get; protected set; }
+ ///
+ /// 拉黑的用户
+ ///
+ public virtual Guid ShieldUserId { get; protected set; }
+ protected GroupChatBlack() { }
+ public GroupChatBlack(long groupId, Guid shieldUserId, Guid? tenantId)
+ {
+ GroupId = groupId;
+ ShieldUserId = shieldUserId;
+ TenantId = tenantId;
+ }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/GroupMessage.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/GroupMessage.cs
similarity index 90%
rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/GroupMessage.cs
rename to aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/GroupMessage.cs
index b38cd50a3..329840676 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/GroupMessage.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/GroupMessage.cs
@@ -1,25 +1,25 @@
-using LINGYUN.Abp.IM.Messages;
-using LINGYUN.Abp.MessageService.Chat;
-using System;
-
-namespace LINGYUN.Abp.MessageService.Group
-{
- public class GroupMessage : Message
- {
- ///
- /// 群组标识
- ///
- public virtual long GroupId { get; protected set; }
-
- protected GroupMessage() { }
- public GroupMessage(long id, Guid sendUserId, string sendUserName, string content, MessageType type = MessageType.Text)
- : base(id, sendUserId, sendUserName, content, type)
- {
-
- }
- public void SendToGroup(long groupId)
- {
- GroupId = groupId;
- }
- }
-}
+using LINGYUN.Abp.IM.Messages;
+using LINGYUN.Abp.MessageService.Chat;
+using System;
+
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ public class GroupMessage : Message
+ {
+ ///
+ /// 群组标识
+ ///
+ public virtual long GroupId { get; protected set; }
+
+ protected GroupMessage() { }
+ public GroupMessage(long id, Guid sendUserId, string sendUserName, string content, MessageType type = MessageType.Text)
+ : base(id, sendUserId, sendUserName, content, type)
+ {
+
+ }
+ public void SendToGroup(long groupId)
+ {
+ GroupId = groupId;
+ }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/GroupStore.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/GroupStore.cs
new file mode 100644
index 000000000..1c4d99f07
--- /dev/null
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/GroupStore.cs
@@ -0,0 +1,72 @@
+using LINGYUN.Abp.IM.Groups;
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.MultiTenancy;
+using Volo.Abp.ObjectMapping;
+
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ public class GroupStore : IGroupStore, ITransientDependency
+ {
+ private readonly IObjectMapper _objectMapper;
+ private readonly ICurrentTenant _currentTenant;
+ private readonly IGroupRepository _groupRepository;
+
+ public GroupStore(
+ IObjectMapper objectMapper,
+ ICurrentTenant currentTenant,
+ IGroupRepository groupRepository)
+ {
+ _objectMapper = objectMapper;
+ _currentTenant = currentTenant;
+ _groupRepository = groupRepository;
+ }
+
+ public virtual async Task GetAsync(
+ Guid? tenantId,
+ string groupId,
+ CancellationToken cancellationToken = default)
+ {
+ using (_currentTenant.Change(tenantId))
+ {
+ var group = await _groupRepository.FindByIdAsync(long.Parse(groupId), cancellationToken);
+ return _objectMapper.Map(group);
+ }
+ }
+
+ public virtual async Task GetCountAsync(
+ Guid? tenantId,
+ string filter = null,
+ CancellationToken cancellationToken = default)
+ {
+ using (_currentTenant.Change(tenantId))
+ {
+ return await _groupRepository.GetCountAsync(filter, cancellationToken);
+ }
+ }
+
+ public virtual async Task> GetListAsync(
+ Guid? tenantId,
+ string filter = null,
+ string sorting = nameof(Group.Name),
+ int skipCount = 0,
+ int maxResultCount = 10,
+ CancellationToken cancellationToken = default)
+ {
+ using (_currentTenant.Change(tenantId))
+ {
+ var groups = await _groupRepository.GetListAsync(
+ filter,
+ sorting,
+ skipCount,
+ maxResultCount,
+ cancellationToken);
+
+ return _objectMapper.Map, List>(groups);
+ }
+ }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/IGroupRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/IGroupRepository.cs
new file mode 100644
index 000000000..96fc50c92
--- /dev/null
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/IGroupRepository.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using Volo.Abp.Domain.Repositories;
+
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ public interface IGroupRepository : IBasicRepository
+ {
+ ///
+ /// 用户是否已被拉黑
+ ///
+ ///
+ ///
+ ///
+ Task UserHasBlackedAsync(
+ long id,
+ Guid formUserId,
+ CancellationToken cancellationToken = default);
+
+ Task FindByIdAsync(
+ long id,
+ CancellationToken cancellationToken = default);
+
+ Task> GetGroupAdminAsync(
+ long id,
+ CancellationToken cancellationToken = default);
+
+ ///
+ /// 获取群组数
+ ///
+ ///
+ ///
+ ///
+ Task GetCountAsync(
+ string filter = null,
+ CancellationToken cancellationToken = default);
+ ///
+ /// 获取群组列表
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task> GetListAsync(
+ string filter = null,
+ string sorting = nameof(ChatGroup.Name),
+ int skipCount = 0,
+ int maxResultCount = 10,
+ CancellationToken cancellationToken = default);
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/IGroupRepositoryExtensions.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/IGroupRepositoryExtensions.cs
similarity index 89%
rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/IGroupRepositoryExtensions.cs
rename to aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/IGroupRepositoryExtensions.cs
index b33056b57..d2a4c7f24 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/IGroupRepositoryExtensions.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/IGroupRepositoryExtensions.cs
@@ -1,19 +1,19 @@
-using System.Threading;
-using System.Threading.Tasks;
-using Volo.Abp;
-
-namespace LINGYUN.Abp.MessageService.Group
-{
- public static class IGroupRepositoryExtensions
- {
- public static async Task GetByIdAsync(
- this IGroupRepository repository,
- long id,
- CancellationToken cancellationToken = default)
- {
- var group = await repository.FindByIdAsync(id, cancellationToken);
-
- return group ?? throw new BusinessException(MessageServiceErrorCodes.GroupNotFount);
- }
- }
-}
+using System.Threading;
+using System.Threading.Tasks;
+using Volo.Abp;
+
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ public static class IGroupRepositoryExtensions
+ {
+ public static async Task GetByIdAsync(
+ this IGroupRepository repository,
+ long id,
+ CancellationToken cancellationToken = default)
+ {
+ var group = await repository.FindByIdAsync(id, cancellationToken);
+
+ return group ?? throw new BusinessException(MessageServiceErrorCodes.GroupNotFount);
+ }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/IUserChatGroupRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/IUserChatGroupRepository.cs
similarity index 88%
rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/IUserChatGroupRepository.cs
rename to aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/IUserChatGroupRepository.cs
index 13dfd3495..629c2f024 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/IUserChatGroupRepository.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/IUserChatGroupRepository.cs
@@ -1,11 +1,11 @@
-using LINGYUN.Abp.IM.Group;
+using LINGYUN.Abp.IM.Groups;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
-namespace LINGYUN.Abp.MessageService.Group
+namespace LINGYUN.Abp.MessageService.Groups
{
public interface IUserChatGroupRepository : IBasicRepository
{
@@ -16,7 +16,7 @@ namespace LINGYUN.Abp.MessageService.Group
///
///
Task MemberHasInGroupAsync(
- long groupId,
+ long groupId,
Guid userId,
CancellationToken cancellationToken = default);
///
@@ -27,7 +27,7 @@ namespace LINGYUN.Abp.MessageService.Group
///
///
Task GetMemberAsync(
- long groupId,
+ long groupId,
Guid userId,
CancellationToken cancellationToken = default);
///
@@ -49,9 +49,9 @@ namespace LINGYUN.Abp.MessageService.Group
///
///
Task> GetMembersAsync(
- long groupId,
+ long groupId,
string sorting = nameof(GroupUserCard.UserId),
- int skipCount = 0,
+ int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default);
///
@@ -60,7 +60,7 @@ namespace LINGYUN.Abp.MessageService.Group
///
///
///
- Task> GetMemberGroupsAsync(
+ Task> GetMemberGroupsAsync(
Guid userId,
CancellationToken cancellationToken = default);
///
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/UserChatGroup.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/UserChatGroup.cs
similarity index 91%
rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/UserChatGroup.cs
rename to aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/UserChatGroup.cs
index 1208e03c7..3a44f385d 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/UserChatGroup.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/UserChatGroup.cs
@@ -1,27 +1,27 @@
-using System;
-using Volo.Abp.Domain.Entities.Auditing;
-using Volo.Abp.MultiTenancy;
-
-namespace LINGYUN.Abp.MessageService.Group
-{
- ///
- /// 用户群组
- ///
- public class UserChatGroup : CreationAuditedEntity, IMultiTenant
- {
- ///
- /// 租户
- ///
- public virtual Guid? TenantId { get; protected set; }
- public virtual Guid UserId { get; protected set; }
- public virtual long GroupId { get; protected set; }
- protected UserChatGroup() { }
- public UserChatGroup(long groupId, Guid userId, Guid acceptUserId, Guid? tenantId = null)
- {
- UserId = userId;
- GroupId = groupId;
- CreatorId = acceptUserId;
- TenantId = tenantId;
- }
- }
-}
+using System;
+using Volo.Abp.Domain.Entities.Auditing;
+using Volo.Abp.MultiTenancy;
+
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ ///
+ /// 用户群组
+ ///
+ public class UserChatGroup : CreationAuditedEntity, IMultiTenant
+ {
+ ///
+ /// 租户
+ ///
+ public virtual Guid? TenantId { get; protected set; }
+ public virtual Guid UserId { get; protected set; }
+ public virtual long GroupId { get; protected set; }
+ protected UserChatGroup() { }
+ public UserChatGroup(long groupId, Guid userId, Guid acceptUserId, Guid? tenantId = null)
+ {
+ UserId = userId;
+ GroupId = groupId;
+ CreatorId = acceptUserId;
+ TenantId = tenantId;
+ }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/UserGroupCard.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/UserGroupCard.cs
similarity index 94%
rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/UserGroupCard.cs
rename to aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/UserGroupCard.cs
index 63ec38b92..4aa0c665a 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/UserGroupCard.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/UserGroupCard.cs
@@ -1,74 +1,74 @@
-using System;
-using Volo.Abp.Domain.Entities.Auditing;
-using Volo.Abp.MultiTenancy;
-using Volo.Abp.Timing;
-
-namespace LINGYUN.Abp.MessageService.Group
-{
- ///
- /// 用户群组卡片
- ///
- public class UserGroupCard : AuditedAggregateRoot, IMultiTenant
- {
- ///
- /// 租户
- ///
- public virtual Guid? TenantId { get; protected set; }
- ///
- /// 用户标识
- ///
- public virtual Guid UserId { get; protected set; }
- ///
- /// 昵称
- ///
- public virtual string NickName { get; set; }
- ///
- /// 是否管理员
- ///
- public virtual bool IsAdmin { get; protected set; }
- ///
- /// 禁言期止
- ///
- public virtual DateTime? SilenceEnd { get; protected set; }
- protected UserGroupCard()
- {
- }
- public UserGroupCard(
- Guid userId,
- string nickName = "",
- bool isAdmin = false,
- DateTime? silenceEnd = null,
- Guid? tenantId = null)
- {
- UserId = userId;
- NickName = nickName;
- IsAdmin = isAdmin;
- SilenceEnd = silenceEnd;
- TenantId = tenantId;
- }
- ///
- /// 设置管理员
- ///
- ///
- public void SetAdmin(bool admin)
- {
- IsAdmin = admin;
- }
- ///
- /// 禁言
- ///
- ///
- ///
- public void Silence(IClock clock, double seconds)
- {
- SilenceEnd = clock.Now.AddSeconds(seconds);
- }
- ///
- /// 解除禁言
- ///
- public void UnSilence()
- {
- SilenceEnd = null;
- }
- }
-}
+using System;
+using Volo.Abp.Domain.Entities.Auditing;
+using Volo.Abp.MultiTenancy;
+using Volo.Abp.Timing;
+
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ ///
+ /// 用户群组卡片
+ ///
+ public class UserGroupCard : AuditedAggregateRoot, IMultiTenant
+ {
+ ///
+ /// 租户
+ ///
+ public virtual Guid? TenantId { get; protected set; }
+ ///
+ /// 用户标识
+ ///
+ public virtual Guid UserId { get; protected set; }
+ ///
+ /// 昵称
+ ///
+ public virtual string NickName { get; set; }
+ ///
+ /// 是否管理员
+ ///
+ public virtual bool IsAdmin { get; protected set; }
+ ///
+ /// 禁言期止
+ ///
+ public virtual DateTime? SilenceEnd { get; protected set; }
+ protected UserGroupCard()
+ {
+ }
+ public UserGroupCard(
+ Guid userId,
+ string nickName = "",
+ bool isAdmin = false,
+ DateTime? silenceEnd = null,
+ Guid? tenantId = null)
+ {
+ UserId = userId;
+ NickName = nickName;
+ IsAdmin = isAdmin;
+ SilenceEnd = silenceEnd;
+ TenantId = tenantId;
+ }
+ ///
+ /// 设置管理员
+ ///
+ ///
+ public void SetAdmin(bool admin)
+ {
+ IsAdmin = admin;
+ }
+ ///
+ /// 禁言
+ ///
+ ///
+ ///
+ public void Silence(IClock clock, double seconds)
+ {
+ SilenceEnd = clock.Now.AddSeconds(seconds);
+ }
+ ///
+ /// 解除禁言
+ ///
+ public void UnSilence()
+ {
+ SilenceEnd = null;
+ }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/UserGroupStore.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/UserGroupStore.cs
similarity index 84%
rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/UserGroupStore.cs
rename to aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/UserGroupStore.cs
index f186e7d0a..bee83976f 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/UserGroupStore.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/UserGroupStore.cs
@@ -1,29 +1,25 @@
-using LINGYUN.Abp.IM.Group;
+using LINGYUN.Abp.IM.Groups;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.MultiTenancy;
-using Volo.Abp.ObjectMapping;
using Volo.Abp.Uow;
-namespace LINGYUN.Abp.MessageService.Group
+namespace LINGYUN.Abp.MessageService.Groups
{
public class UserGroupStore : IUserGroupStore, ITransientDependency
{
- private readonly IObjectMapper _objectMapper;
private readonly ICurrentTenant _currentTenant;
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IUserChatGroupRepository _userChatGroupRepository;
public UserGroupStore(
- IObjectMapper objectMapper,
ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager,
IUserChatGroupRepository userChatGroupRepository)
{
- _objectMapper = objectMapper;
_currentTenant = currentTenant;
_unitOfWorkManager = unitOfWorkManager;
_userChatGroupRepository = userChatGroupRepository;
@@ -42,9 +38,9 @@ namespace LINGYUN.Abp.MessageService.Group
}
public virtual async Task AddUserToGroupAsync(
- Guid? tenantId,
- Guid userId,
- long groupId,
+ Guid? tenantId,
+ Guid userId,
+ long groupId,
Guid acceptUserId,
CancellationToken cancellationToken = default)
{
@@ -66,8 +62,8 @@ namespace LINGYUN.Abp.MessageService.Group
}
public async Task GetUserGroupCardAsync(
- Guid? tenantId,
- long groupId,
+ Guid? tenantId,
+ long groupId,
Guid userId,
CancellationToken cancellationToken = default)
{
@@ -80,7 +76,7 @@ namespace LINGYUN.Abp.MessageService.Group
}
public async Task> GetMembersAsync(
- Guid? tenantId,
+ Guid? tenantId,
long groupId,
CancellationToken cancellationToken = default)
{
@@ -90,8 +86,8 @@ namespace LINGYUN.Abp.MessageService.Group
}
}
- public async Task> GetUserGroupsAsync(
- Guid? tenantId,
+ public async Task> GetUserGroupsAsync(
+ Guid? tenantId,
Guid userId,
CancellationToken cancellationToken = default)
{
@@ -102,8 +98,8 @@ namespace LINGYUN.Abp.MessageService.Group
}
public async Task RemoveUserFormGroupAsync(
- Guid? tenantId,
- Guid userId,
+ Guid? tenantId,
+ Guid userId,
long groupId,
CancellationToken cancellationToken = default)
{
@@ -130,10 +126,10 @@ namespace LINGYUN.Abp.MessageService.Group
}
public async Task> GetMembersAsync(
- Guid? tenantId,
+ Guid? tenantId,
long groupId,
- string sorting = nameof(GroupUserCard.UserId),
- int skipCount = 0,
+ string sorting = nameof(GroupUserCard.UserId),
+ int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs
index 3e2068b0b..0ef8cd319 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs
@@ -1,77 +1,81 @@
-using AutoMapper;
-using LINGYUN.Abp.IM.Messages;
-using LINGYUN.Abp.MessageService.Chat;
-using LINGYUN.Abp.MessageService.Group;
-using LINGYUN.Abp.MessageService.Notifications;
-using LINGYUN.Abp.MessageService.Subscriptions;
-using LINGYUN.Abp.Notifications;
-using Newtonsoft.Json;
-using System;
-using Volo.Abp.AutoMapper;
-using Volo.Abp.Data;
-
-namespace LINGYUN.Abp.MessageService.Mapper
-{
- public class MessageServiceDomainAutoMapperProfile : Profile
- {
- public MessageServiceDomainAutoMapperProfile()
- {
- //CreateMap()
- // .ForMember(dto => dto.Id, map => map.MapFrom(src => src.NotificationId))
- // .ForMember(dto => dto.Name, map => map.MapFrom(src => src.NotificationName))
- // .ForMember(dto => dto.Lifetime, map => map.Ignore())
- // .ForMember(dto => dto.Type, map => map.MapFrom(src => src.Type))
- // .ForMember(dto => dto.Severity, map => map.MapFrom(src => src.Severity))
- // .ForMember(dto => dto.Data, map => map.MapFrom((src, nfi) =>
- // {
- // var dataType = Type.GetType(src.NotificationTypeName);
- // var data = JsonConvert.DeserializeObject(src.NotificationData, dataType);
- // if(data != null && data is NotificationData notificationData)
- // {
- // if (notificationData.NeedLocalizer())
- // {
- // var title = JsonConvert.DeserializeObject(notificationData.TryGetData("title").ToString());
- // var message = JsonConvert.DeserializeObject(notificationData.TryGetData("message").ToString());
- // notificationData.TrySetData("title", title);
- // notificationData.TrySetData("message", message);
- // }
- // return notificationData;
- // }
- // return new NotificationData();
- // }));
-
- CreateMap()
- .ConvertUsing();
-
- CreateMap();
-
- CreateMessageMap()
- .ForMember(dto => dto.Content, map => map.MapFrom(src => src.Content))
- .ForMember(dto => dto.GroupId, map => map.MapFrom(src => src.GroupId.ToString()))
- .Ignore(dto => dto.ToUserId);
-
- CreateMessageMap()
- .ForMember(dto => dto.ToUserId, map => map.MapFrom(src => src.ReceiveUserId))
- .Ignore(dto => dto.GroupId);
-
- CreateMessageMap()
- .ForMember(dto => dto.ToUserId, map => map.MapFrom(src => src.ReceiveUserId))
- .Ignore(dto => dto.GroupId);
- }
-
- protected IMappingExpression CreateMessageMap()
- where TSource : Message
- where TDestination : ChatMessage
- {
- return CreateMap()
- .ForMember(dto => dto.Content, map => map.MapFrom(src => src.Content))
- .ForMember(dto => dto.MessageId, map => map.MapFrom(src => src.MessageId.ToString()))
- .ForMember(dto => dto.FormUserId, map => map.MapFrom(src => src.CreatorId))
- .ForMember(dto => dto.FormUserName, map => map.MapFrom(src => src.SendUserName))
- .ForMember(dto => dto.SendTime, map => map.MapFrom(src => src.CreationTime))
- .ForMember(dto => dto.MessageType, map => map.MapFrom(src => src.Type))
- .ForMember(dto => dto.IsAnonymous, map => map.MapFrom(src => src.GetProperty(nameof(ChatMessage.IsAnonymous), false)))
- .MapExtraProperties();
- }
- }
-}
+using AutoMapper;
+using LINGYUN.Abp.IM.Groups;
+using LINGYUN.Abp.IM.Messages;
+using LINGYUN.Abp.MessageService.Chat;
+using LINGYUN.Abp.MessageService.Groups;
+using LINGYUN.Abp.MessageService.Notifications;
+using LINGYUN.Abp.MessageService.Subscriptions;
+using LINGYUN.Abp.Notifications;
+using Volo.Abp.AutoMapper;
+using Volo.Abp.Data;
+
+namespace LINGYUN.Abp.MessageService.Mapper
+{
+ public class MessageServiceDomainAutoMapperProfile : Profile
+ {
+ public MessageServiceDomainAutoMapperProfile()
+ {
+ //CreateMap()
+ // .ForMember(dto => dto.Id, map => map.MapFrom(src => src.NotificationId))
+ // .ForMember(dto => dto.Name, map => map.MapFrom(src => src.NotificationName))
+ // .ForMember(dto => dto.Lifetime, map => map.Ignore())
+ // .ForMember(dto => dto.Type, map => map.MapFrom(src => src.Type))
+ // .ForMember(dto => dto.Severity, map => map.MapFrom(src => src.Severity))
+ // .ForMember(dto => dto.Data, map => map.MapFrom((src, nfi) =>
+ // {
+ // var dataType = Type.GetType(src.NotificationTypeName);
+ // var data = JsonConvert.DeserializeObject(src.NotificationData, dataType);
+ // if(data != null && data is NotificationData notificationData)
+ // {
+ // if (notificationData.NeedLocalizer())
+ // {
+ // var title = JsonConvert.DeserializeObject(notificationData.TryGetData("title").ToString());
+ // var message = JsonConvert.DeserializeObject(notificationData.TryGetData("message").ToString());
+ // notificationData.TrySetData("title", title);
+ // notificationData.TrySetData("message", message);
+ // }
+ // return notificationData;
+ // }
+ // return new NotificationData();
+ // }));
+
+ CreateMap()
+ .ConvertUsing();
+
+ CreateMap();
+
+ CreateMessageMap()
+ .ForMember(dto => dto.Content, map => map.MapFrom(src => src.Content))
+ .ForMember(dto => dto.GroupId, map => map.MapFrom(src => src.GroupId.ToString()))
+ .Ignore(dto => dto.ToUserId);
+
+ CreateMessageMap()
+ .ForMember(dto => dto.ToUserId, map => map.MapFrom(src => src.ReceiveUserId))
+ .Ignore(dto => dto.GroupId);
+
+ CreateMessageMap()
+ .ForMember(dto => dto.ToUserId, map => map.MapFrom(src => src.ReceiveUserId))
+ .Ignore(dto => dto.GroupId);
+
+ CreateMap()
+ .ForMember(g => g.Id, map => map.MapFrom(src => src.GroupId.ToString()))
+ .ForMember(g => g.MaxUserLength, map => map.MapFrom(src => src.MaxUserCount))
+ .Ignore(g => g.GroupUserCount);
+ }
+
+ protected IMappingExpression CreateMessageMap()
+ where TSource : Message
+ where TDestination : ChatMessage
+ {
+ return CreateMap()
+ .ForMember(dto => dto.Content, map => map.MapFrom(src => src.Content))
+ .ForMember(dto => dto.MessageId, map => map.MapFrom(src => src.MessageId.ToString()))
+ .ForMember(dto => dto.FormUserId, map => map.MapFrom(src => src.CreatorId))
+ .ForMember(dto => dto.FormUserName, map => map.MapFrom(src => src.SendUserName))
+ .ForMember(dto => dto.SendTime, map => map.MapFrom(src => src.CreationTime))
+ .ForMember(dto => dto.MessageType, map => map.MapFrom(src => src.Type))
+ .ForMember(dto => dto.IsAnonymous, map => map.MapFrom(src => src.GetProperty(nameof(ChatMessage.IsAnonymous), false)))
+ .MapExtraProperties();
+ }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreMessageRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreMessageRepository.cs
index eac37b464..cfc8e5b41 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreMessageRepository.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreMessageRepository.cs
@@ -1,6 +1,6 @@
using LINGYUN.Abp.IM.Messages;
using LINGYUN.Abp.MessageService.EntityFrameworkCore;
-using LINGYUN.Abp.MessageService.Group;
+using LINGYUN.Abp.MessageService.Groups;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
@@ -18,7 +18,7 @@ namespace LINGYUN.Abp.MessageService.Chat
IMessageRepository, ITransientDependency
{
public EfCoreMessageRepository(
- IDbContextProvider dbContextProvider)
+ IDbContextProvider dbContextProvider)
: base(dbContextProvider)
{
}
@@ -34,11 +34,11 @@ namespace LINGYUN.Abp.MessageService.Chat
}
public virtual async Task> GetGroupMessagesAsync(
- long groupId,
+ long groupId,
+ MessageType? type = null,
string filter = "",
string sorting = nameof(UserMessage.MessageId),
- MessageType? type = null,
- int skipCount = 0,
+ int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
@@ -57,8 +57,8 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task GetGroupMessagesCountAsync(
long groupId,
- string filter = "",
MessageType? type = null,
+ string filter = "",
CancellationToken cancellationToken = default)
{
var groupMessagesCount = await (await GetDbContextAsync()).Set()
@@ -71,12 +71,12 @@ namespace LINGYUN.Abp.MessageService.Chat
}
public virtual async Task> GetUserGroupMessagesAsync(
- Guid sendUserId,
+ Guid sendUserId,
long groupId,
+ MessageType? type = null,
string filter = "",
string sorting = nameof(UserMessage.MessageId),
- MessageType? type = null,
- int skipCount = 0,
+ int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
@@ -94,10 +94,10 @@ namespace LINGYUN.Abp.MessageService.Chat
}
public virtual async Task GetUserGroupMessagesCountAsync(
- Guid sendUserId,
- long groupId,
- string filter = "",
+ Guid sendUserId,
+ long groupId,
MessageType? type = null,
+ string filter = "",
CancellationToken cancellationToken = default)
{
var groupMessagesCount = await (await GetDbContextAsync()).Set()
@@ -110,8 +110,8 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task GetCountAsync(
long groupId,
- string filter = "",
MessageType? type = null,
+ string filter = "",
CancellationToken cancellationToken = default)
{
return await (await GetDbContextAsync()).Set()
@@ -124,8 +124,8 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task GetCountAsync(
Guid sendUserId,
Guid receiveUserId,
- string filter = "",
MessageType? type = null,
+ string filter = "",
CancellationToken cancellationToken = default)
{
return await (await GetDbContextAsync()).Set()
@@ -146,15 +146,17 @@ namespace LINGYUN.Abp.MessageService.Chat
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
}
- public virtual async Task> GetLastMessagesByOneFriendAsync(
+ public virtual async Task> GetLastMessagesAsync(
Guid userId,
+ MessageState? state = null,
string sorting = nameof(LastChatMessage.SendTime),
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
var dbContext = await GetDbContextAsync();
var groupMsgQuery = dbContext.Set()
- .Where(msg => msg.ReceiveUserId == userId || msg.CreatorId == userId)
+ .Where(msg => msg.ReceiveUserId == userId)
+ .WhereIf(state.HasValue, x => x.SendState == state)
.GroupBy(msg => new { msg.CreatorId, msg.ReceiveUserId })
.Select(msg => new
{
@@ -187,10 +189,10 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task> GetUserMessagesAsync(
Guid sendUserId,
Guid receiveUserId,
+ MessageType? type = null,
string filter = "",
string sorting = nameof(UserMessage.MessageId),
- MessageType? type = null,
- int skipCount = 0,
+ int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
@@ -208,10 +210,10 @@ namespace LINGYUN.Abp.MessageService.Chat
}
public virtual async Task GetUserMessagesCountAsync(
- Guid sendUserId,
+ Guid sendUserId,
Guid receiveUserId,
- string filter = "",
MessageType? type = null,
+ string filter = "",
CancellationToken cancellationToken = default)
{
var userMessagesCount = await (await GetDbContextAsync()).Set()
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatCardRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatCardRepository.cs
index 52e22f3c9..02dbc5869 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatCardRepository.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatCardRepository.cs
@@ -15,11 +15,20 @@ namespace LINGYUN.Abp.MessageService.Chat
public class EfCoreUserChatCardRepository : EfCoreRepository, IUserChatCardRepository
{
public EfCoreUserChatCardRepository(
- IDbContextProvider dbContextProvider)
+ IDbContextProvider dbContextProvider)
: base(dbContextProvider)
{
}
+ public virtual async Task FindByUserIdAsync(
+ Guid userId,
+ CancellationToken cancellationToken = default)
+ {
+ return await (await GetDbSetAsync())
+ .Where(ucc => ucc.UserId == userId)
+ .FirstAsync(GetCancellationToken(cancellationToken));
+ }
+
public virtual async Task CheckUserIdExistsAsync(Guid userId, CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
@@ -36,8 +45,8 @@ namespace LINGYUN.Abp.MessageService.Chat
}
public virtual async Task GetMemberCountAsync(
- string findUserName = "",
- int? startAge = null,
+ string findUserName = "",
+ int? startAge = null,
int? endAge = null,
Sex? sex = null,
CancellationToken cancellationToken = default)
@@ -46,18 +55,18 @@ namespace LINGYUN.Abp.MessageService.Chat
.WhereIf(!findUserName.IsNullOrWhiteSpace(), ucc => ucc.UserName.Contains(findUserName))
.WhereIf(startAge.HasValue, ucc => ucc.Age >= startAge.Value)
.WhereIf(endAge.HasValue, ucc => ucc.Age <= endAge.Value)
- .WhereIf(sex.HasValue, ucc => ucc.Sex == sex)
+ .WhereIf(sex.HasValue, ucc => ucc.Sex == sex)
.CountAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task> GetMembersAsync(
- string findUserName = "",
+ string findUserName = "",
int? startAge = null,
- int? endAge = null,
- Sex? sex = null,
+ int? endAge = null,
+ Sex? sex = null,
string sorting = nameof(UserChatCard.UserId),
- int skipCount = 0,
- int maxResultCount = 10,
+ int skipCount = 0,
+ int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatFriendRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatFriendRepository.cs
index 27bb479bc..ce9d4b7af 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatFriendRepository.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatFriendRepository.cs
@@ -1,4 +1,5 @@
-using LINGYUN.Abp.IM.Contract;
+using LINGYUN.Abp.IM;
+using LINGYUN.Abp.IM.Contract;
using LINGYUN.Abp.MessageService.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
@@ -15,7 +16,7 @@ namespace LINGYUN.Abp.MessageService.Chat
public class EfCoreUserChatFriendRepository : EfCoreRepository, IUserChatFriendRepository
{
public EfCoreUserChatFriendRepository(
- IDbContextProvider dbContextProvider)
+ IDbContextProvider dbContextProvider)
: base(dbContextProvider)
{
}
@@ -54,7 +55,8 @@ namespace LINGYUN.Abp.MessageService.Chat
SpecialFocus = ucf.SpecialFocus,
TenantId = ucf.TenantId,
UserId = ucf.UserId,
- UserName = ucc.UserName
+ UserName = ucc.UserName,
+ Online = ucc.State == UserOnlineState.Online,
};
return await userFriendQuery
@@ -85,7 +87,8 @@ namespace LINGYUN.Abp.MessageService.Chat
SpecialFocus = ucf.SpecialFocus,
TenantId = ucf.TenantId,
UserId = ucf.UserId,
- UserName = ucc.UserName
+ UserName = ucc.UserName,
+ Online = ucc.State == UserOnlineState.Online,
};
return await userFriendQuery
@@ -93,11 +96,11 @@ namespace LINGYUN.Abp.MessageService.Chat
}
public virtual async Task> GetMembersAsync(
- Guid userId,
- string filter = "",
- string sorting = nameof(UserChatFriend.UserId),
- int skipCount = 0,
- int maxResultCount = 10,
+ Guid userId,
+ string filter = "",
+ string sorting = nameof(UserChatFriend.UserId),
+ int skipCount = 0,
+ int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
var dbContext = await GetDbContextAsync();
@@ -131,7 +134,8 @@ namespace LINGYUN.Abp.MessageService.Chat
SpecialFocus = ucf.SpecialFocus,
TenantId = ucf.TenantId,
UserId = ucf.UserId,
- UserName = ucc.UserName
+ UserName = ucc.UserName,
+ Online = ucc.State == UserOnlineState.Online,
};
return await userFriendQuery
@@ -173,7 +177,8 @@ namespace LINGYUN.Abp.MessageService.Chat
SpecialFocus = ucf.SpecialFocus,
TenantId = ucf.TenantId,
UserId = ucf.UserId,
- UserName = ucc.UserName
+ UserName = ucc.UserName,
+ Online = ucc.State == UserOnlineState.Online,
};
return await userFriendQuery
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreModule.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreModule.cs
index 1d70260b7..13175a1a1 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreModule.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreModule.cs
@@ -1,35 +1,35 @@
-using LINGYUN.Abp.MessageService.Chat;
-using LINGYUN.Abp.MessageService.Group;
-using LINGYUN.Abp.MessageService.Notifications;
-using LINGYUN.Abp.MessageService.Subscriptions;
-using Microsoft.Extensions.DependencyInjection;
-using Volo.Abp.EntityFrameworkCore;
-using Volo.Abp.Modularity;
-
-namespace LINGYUN.Abp.MessageService.EntityFrameworkCore
-{
- [DependsOn(
- typeof(AbpMessageServiceDomainModule),
- typeof(AbpEntityFrameworkCoreModule))]
- public class AbpMessageServiceEntityFrameworkCoreModule : AbpModule
- {
- public override void ConfigureServices(ServiceConfigurationContext context)
- {
- context.Services.AddAbpDbContext(options =>
- {
- options.AddRepository();
- options.AddRepository();
- options.AddRepository();
-
- options.AddRepository();
- options.AddRepository();
- options.AddRepository();
- options.AddRepository();
-
- options.AddRepository();
-
- options.AddDefaultRepositories(includeAllEntities: true);
- });
- }
- }
-}
+using LINGYUN.Abp.MessageService.Chat;
+using LINGYUN.Abp.MessageService.Groups;
+using LINGYUN.Abp.MessageService.Notifications;
+using LINGYUN.Abp.MessageService.Subscriptions;
+using Microsoft.Extensions.DependencyInjection;
+using Volo.Abp.EntityFrameworkCore;
+using Volo.Abp.Modularity;
+
+namespace LINGYUN.Abp.MessageService.EntityFrameworkCore
+{
+ [DependsOn(
+ typeof(AbpMessageServiceDomainModule),
+ typeof(AbpEntityFrameworkCoreModule))]
+ public class AbpMessageServiceEntityFrameworkCoreModule : AbpModule
+ {
+ public override void ConfigureServices(ServiceConfigurationContext context)
+ {
+ context.Services.AddAbpDbContext(options =>
+ {
+ options.AddRepository();
+ options.AddRepository();
+ options.AddRepository();
+
+ options.AddRepository();
+ options.AddRepository();
+ options.AddRepository();
+ options.AddRepository();
+
+ options.AddRepository();
+
+ options.AddDefaultRepositories(includeAllEntities: true);
+ });
+ }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/IMessageServiceDbContext.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/IMessageServiceDbContext.cs
index 070434a73..075e8af18 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/IMessageServiceDbContext.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/IMessageServiceDbContext.cs
@@ -1,15 +1,15 @@
-using LINGYUN.Abp.MessageService.Chat;
-using LINGYUN.Abp.MessageService.Group;
-using Microsoft.EntityFrameworkCore;
-using Volo.Abp.Data;
-using Volo.Abp.EntityFrameworkCore;
-
-namespace LINGYUN.Abp.MessageService.EntityFrameworkCore
-{
- [ConnectionStringName(AbpMessageServiceDbProperties.ConnectionStringName)]
- public interface IMessageServiceDbContext : IEfCoreDbContext
- {
- DbSet UserChatCards { get; set; }
- DbSet UserGroupCards { get; set; }
- }
-}
+using LINGYUN.Abp.MessageService.Chat;
+using LINGYUN.Abp.MessageService.Groups;
+using Microsoft.EntityFrameworkCore;
+using Volo.Abp.Data;
+using Volo.Abp.EntityFrameworkCore;
+
+namespace LINGYUN.Abp.MessageService.EntityFrameworkCore
+{
+ [ConnectionStringName(AbpMessageServiceDbProperties.ConnectionStringName)]
+ public interface IMessageServiceDbContext : IEfCoreDbContext
+ {
+ DbSet UserChatCards { get; set; }
+ DbSet UserGroupCards { get; set; }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContext.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContext.cs
index bd333d642..183315046 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContext.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContext.cs
@@ -1,30 +1,30 @@
-using LINGYUN.Abp.MessageService.Chat;
-using LINGYUN.Abp.MessageService.Group;
-using Microsoft.EntityFrameworkCore;
-using Volo.Abp.Data;
-using Volo.Abp.EntityFrameworkCore;
-
-namespace LINGYUN.Abp.MessageService.EntityFrameworkCore
-{
- [ConnectionStringName(AbpMessageServiceDbProperties.ConnectionStringName)]
- public class MessageServiceDbContext : AbpDbContext, IMessageServiceDbContext
- {
- public DbSet UserChatCards { get; set; }
- public DbSet UserGroupCards { get; set; }
-
- public MessageServiceDbContext(DbContextOptions options)
- : base(options)
- {
- }
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.ConfigureMessageService(options =>
- {
- options.TablePrefix = AbpMessageServiceDbProperties.DefaultTablePrefix;
- options.Schema = AbpMessageServiceDbProperties.DefaultSchema;
- });
-
- base.OnModelCreating(modelBuilder);
- }
- }
-}
+using LINGYUN.Abp.MessageService.Chat;
+using LINGYUN.Abp.MessageService.Groups;
+using Microsoft.EntityFrameworkCore;
+using Volo.Abp.Data;
+using Volo.Abp.EntityFrameworkCore;
+
+namespace LINGYUN.Abp.MessageService.EntityFrameworkCore
+{
+ [ConnectionStringName(AbpMessageServiceDbProperties.ConnectionStringName)]
+ public class MessageServiceDbContext : AbpDbContext, IMessageServiceDbContext
+ {
+ public DbSet UserChatCards { get; set; }
+ public DbSet UserGroupCards { get; set; }
+
+ public MessageServiceDbContext(DbContextOptions options)
+ : base(options)
+ {
+ }
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ modelBuilder.ConfigureMessageService(options =>
+ {
+ options.TablePrefix = AbpMessageServiceDbProperties.DefaultTablePrefix;
+ options.Schema = AbpMessageServiceDbProperties.DefaultSchema;
+ });
+
+ base.OnModelCreating(modelBuilder);
+ }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs
index 9c589e5b2..8620e0080 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs
@@ -1,190 +1,191 @@
-using LINGYUN.Abp.MessageService.Chat;
-using LINGYUN.Abp.MessageService.Group;
-using LINGYUN.Abp.MessageService.Notifications;
-using LINGYUN.Abp.MessageService.Subscriptions;
-using Microsoft.EntityFrameworkCore;
-using System;
-using Volo.Abp;
-using Volo.Abp.EntityFrameworkCore.Modeling;
-
-namespace LINGYUN.Abp.MessageService.EntityFrameworkCore
-{
- public static class MessageServiceDbContextModelCreatingExtensions
- {
- public static void ConfigureMessageService(
- this ModelBuilder builder,
- Action optionsAction = null)
- {
- Check.NotNull(builder, nameof(builder));
-
- var options = new MessageServiceModelBuilderConfigurationOptions();
-
- optionsAction?.Invoke(options);
-
- builder.Entity(b =>
- {
- b.ToTable(options.TablePrefix + "Notifications", options.Schema);
-
- b.Property(p => p.NotificationName).HasMaxLength(NotificationConsts.MaxNameLength).IsRequired();
- b.Property(p => p.NotificationTypeName).HasMaxLength(NotificationConsts.MaxTypeNameLength).IsRequired();
- b.Property(p => p.NotificationData).HasMaxLength(NotificationConsts.MaxDataLength).IsRequired();
-
- b.ConfigureByConvention();
-
- b.HasIndex(p => new { p.TenantId, p.NotificationName });
- });
-
- builder.Entity(b =>
- {
- b.ToTable(options.TablePrefix + "UserNotifications", options.Schema);
-
- b.ConfigureByConvention();
-
- b.HasIndex(p => new { p.TenantId, p.UserId, p.NotificationId })
- .HasName("IX_Tenant_User_Notification_Id");
- });
-
- builder.Entity(b =>
- {
- b.ToTable(options.TablePrefix + "UserSubscribes", options.Schema);
-
- b.Property(p => p.NotificationName).HasMaxLength(SubscribeConsts.MaxNotificationNameLength).IsRequired();
- b.Property(p => p.UserName)
- .HasMaxLength(SubscribeConsts.MaxUserNameLength)
- .HasDefaultValue("/")// 不是必须的
- .IsRequired();
-
- b.ConfigureByConvention();
-
- b.HasIndex(p => new { p.TenantId, p.UserId, p.NotificationName })
- .HasName("IX_Tenant_User_Notification_Name")
- .IsUnique();
- });
-
- builder.Entity(b =>
- {
- b.ToTable(options.TablePrefix + "UserMessages", options.Schema);
-
- b.Property(p => p.SendUserName).HasMaxLength(MessageConsts.MaxSendUserNameLength).IsRequired();
- b.Property(p => p.Content).HasMaxLength(MessageConsts.MaxContentLength).IsRequired();
-
- b.ConfigureByConvention();
-
- b.HasIndex(p => new { p.TenantId, p.ReceiveUserId });
- });
-
- builder.Entity(b =>
- {
- b.ToTable(options.TablePrefix + "GroupMessages", options.Schema);
-
- b.Property(p => p.SendUserName).HasMaxLength(MessageConsts.MaxSendUserNameLength).IsRequired();
- b.Property(p => p.Content).HasMaxLength(MessageConsts.MaxContentLength).IsRequired();
-
- b.ConfigureByConvention();
-
- b.HasIndex(p => new { p.TenantId, p.GroupId });
- });
-
- builder.Entity(b =>
- {
- b.ToTable(options.TablePrefix + "UserChatFriends", options.Schema);
-
- b.Property(p => p.RemarkName).HasMaxLength(UserChatFriendConsts.MaxRemarkNameLength);
- b.Property(p => p.Description).HasMaxLength(UserChatFriendConsts.MaxDescriptionLength);
-
- b.ConfigureByConvention();
-
- b.HasIndex(p => new { p.TenantId, p.UserId, p.FrientId });
- });
-
- builder.Entity(b =>
- {
- b.ToTable(options.TablePrefix + "UserChatCards", options.Schema);
-
- b.Property(p => p.UserName).HasMaxLength(UserChatCardConsts.MaxUserNameLength).IsRequired();
-
- b.Property(p => p.AvatarUrl).HasMaxLength(UserChatCardConsts.MaxAvatarUrlLength);
- b.Property(p => p.Description).HasMaxLength(UserChatCardConsts.MaxDescriptionLength);
- b.Property(p => p.NickName).HasMaxLength(UserChatCardConsts.MaxNickNameLength);
- b.Property(p => p.Sign).HasMaxLength(UserChatCardConsts.MaxSignLength);
-
- b.ConfigureByConvention();
-
- b.HasIndex(p => new { p.TenantId, p.UserId });
- });
-
- builder.Entity(b =>
- {
- b.ToTable(options.TablePrefix + "UserGroupCards", options.Schema);
-
- b.Property(p => p.NickName).HasMaxLength(UserChatCardConsts.MaxNickNameLength);
-
- b.ConfigureByConvention();
-
- b.HasIndex(p => new { p.TenantId, p.UserId });
- });
-
-
- builder.Entity(b =>
- {
- b.ToTable(options.TablePrefix + "UserChatSettings", options.Schema);
-
- b.ConfigureByConvention();
-
- b.HasIndex(p => new { p.TenantId, p.UserId });
- });
-
- //builder.Entity(b =>
- //{
- // b.ToTable(options.TablePrefix + "UserSpecialFocuss", options.Schema);
-
- // b.ConfigureMultiTenant();
-
- // b.HasIndex(p => new { p.TenantId, p.UserId });
- //});
-
- //builder.Entity(b =>
- //{
- // b.ToTable(options.TablePrefix + "UserChatBlacks", options.Schema);
-
- // b.ConfigureMultiTenant();
-
- // b.HasIndex(p => new { p.TenantId, p.UserId });
- //});
-
- builder.Entity(b =>
- {
- b.ToTable(options.TablePrefix + "GroupChatBlacks", options.Schema);
-
- b.ConfigureByConvention();
-
- b.HasIndex(p => new { p.TenantId, p.GroupId });
- });
-
- builder.Entity(b =>
- {
- b.ToTable(options.TablePrefix + "ChatGroups", options.Schema);
-
- b.Property(p => p.Name).HasMaxLength(ChatGroupConsts.MaxNameLength).IsRequired();
-
- b.Property(p => p.Tag).HasMaxLength(ChatGroupConsts.MaxTagLength);
- b.Property(p => p.Notice).HasMaxLength(ChatGroupConsts.MaxNoticeLength);
- b.Property(p => p.Address).HasMaxLength(ChatGroupConsts.MaxAddressLength);
- b.Property(p => p.Description).HasMaxLength(ChatGroupConsts.MaxDescriptionLength);
-
- b.ConfigureByConvention();
-
- b.HasIndex(p => new { p.TenantId, p.Name });
- });
-
- builder.Entity(b =>
- {
- b.ToTable(options.TablePrefix + "UserChatGroups", options.Schema);
-
- b.ConfigureByConvention();
-
- b.HasIndex(p => new { p.TenantId, p.GroupId, p.UserId });
- });
- }
- }
-}
+using LINGYUN.Abp.MessageService.Chat;
+using LINGYUN.Abp.MessageService.Groups;
+using LINGYUN.Abp.MessageService.Notifications;
+using LINGYUN.Abp.MessageService.Subscriptions;
+using Microsoft.EntityFrameworkCore;
+using System;
+using Volo.Abp;
+using Volo.Abp.EntityFrameworkCore.Modeling;
+
+namespace LINGYUN.Abp.MessageService.EntityFrameworkCore
+{
+ public static class MessageServiceDbContextModelCreatingExtensions
+ {
+ public static void ConfigureMessageService(
+ this ModelBuilder builder,
+ Action optionsAction = null)
+ {
+ Check.NotNull(builder, nameof(builder));
+
+ var options = new MessageServiceModelBuilderConfigurationOptions();
+
+ optionsAction?.Invoke(options);
+
+ builder.Entity(b =>
+ {
+ b.ToTable(options.TablePrefix + "Notifications", options.Schema);
+
+ b.Property(p => p.NotificationName).HasMaxLength(NotificationConsts.MaxNameLength).IsRequired();
+ b.Property(p => p.NotificationTypeName).HasMaxLength(NotificationConsts.MaxTypeNameLength).IsRequired();
+ b.Property(p => p.NotificationData).HasMaxLength(NotificationConsts.MaxDataLength).IsRequired();
+
+ b.ConfigureByConvention();
+
+ b.HasIndex(p => new { p.TenantId, p.NotificationName });
+ });
+
+ builder.Entity(b =>
+ {
+ b.ToTable(options.TablePrefix + "UserNotifications", options.Schema);
+
+ b.ConfigureByConvention();
+
+ b.HasIndex(p => new { p.TenantId, p.UserId, p.NotificationId })
+ .HasDatabaseName("IX_Tenant_User_Notification_Id");
+ });
+
+ builder.Entity(b =>
+ {
+ b.ToTable(options.TablePrefix + "UserSubscribes", options.Schema);
+
+ b.Property(p => p.NotificationName).HasMaxLength(SubscribeConsts.MaxNotificationNameLength).IsRequired();
+ b.Property(p => p.UserName)
+ .HasMaxLength(SubscribeConsts.MaxUserNameLength)
+ .HasDefaultValue("/")// 不是必须的
+ .IsRequired();
+
+ b.ConfigureByConvention();
+
+ b.HasIndex(p => new { p.TenantId, p.UserId, p.NotificationName })
+ .HasDatabaseName("IX_Tenant_User_Notification_Name")
+ .IsUnique();
+ });
+
+ builder.Entity(b =>
+ {
+ b.ToTable(options.TablePrefix + "UserMessages", options.Schema);
+
+ b.Property(p => p.SendUserName).HasMaxLength(MessageConsts.MaxSendUserNameLength).IsRequired();
+ b.Property(p => p.Content).HasMaxLength(MessageConsts.MaxContentLength).IsRequired();
+
+ b.ConfigureByConvention();
+
+ b.HasIndex(p => new { p.TenantId, p.ReceiveUserId });
+ });
+
+ builder.Entity(b =>
+ {
+ b.ToTable(options.TablePrefix + "GroupMessages", options.Schema);
+
+ b.Property(p => p.SendUserName).HasMaxLength(MessageConsts.MaxSendUserNameLength).IsRequired();
+ b.Property(p => p.Content).HasMaxLength(MessageConsts.MaxContentLength).IsRequired();
+
+ b.ConfigureByConvention();
+
+ b.HasIndex(p => new { p.TenantId, p.GroupId });
+ });
+
+ builder.Entity(b =>
+ {
+ b.ToTable(options.TablePrefix + "UserChatFriends", options.Schema);
+
+ b.Property(p => p.RemarkName).HasMaxLength(UserChatFriendConsts.MaxRemarkNameLength);
+ b.Property(p => p.Description).HasMaxLength(UserChatFriendConsts.MaxDescriptionLength);
+
+ b.ConfigureByConvention();
+
+ b.HasIndex(p => new { p.TenantId, p.UserId, p.FrientId });
+ });
+
+ builder.Entity(b =>
+ {
+ b.ToTable(options.TablePrefix + "UserChatCards", options.Schema);
+
+ b.Property(p => p.UserName).HasMaxLength(UserChatCardConsts.MaxUserNameLength).IsRequired();
+
+ b.Property(p => p.AvatarUrl).HasMaxLength(UserChatCardConsts.MaxAvatarUrlLength);
+ b.Property(p => p.Description).HasMaxLength(UserChatCardConsts.MaxDescriptionLength);
+ b.Property(p => p.NickName).HasMaxLength(UserChatCardConsts.MaxNickNameLength);
+ b.Property(p => p.Sign).HasMaxLength(UserChatCardConsts.MaxSignLength);
+
+ b.ConfigureByConvention();
+
+ b.HasIndex(p => new { p.TenantId, p.UserId });
+ });
+
+ builder.Entity(b =>
+ {
+ b.ToTable(options.TablePrefix + "UserGroupCards", options.Schema);
+
+ b.Property(p => p.NickName).HasMaxLength(UserChatCardConsts.MaxNickNameLength);
+
+ b.ConfigureByConvention();
+
+ b.HasIndex(p => new { p.TenantId, p.UserId });
+ });
+
+
+ builder.Entity(b =>
+ {
+ b.ToTable(options.TablePrefix + "UserChatSettings", options.Schema);
+
+ b.ConfigureByConvention();
+
+ b.HasIndex(p => new { p.TenantId, p.UserId });
+ });
+
+ //builder.Entity(b =>
+ //{
+ // b.ToTable(options.TablePrefix + "UserSpecialFocuss", options.Schema);
+
+ // b.ConfigureMultiTenant();
+
+ // b.HasIndex(p => new { p.TenantId, p.UserId });
+ //});
+
+ //builder.Entity(b =>
+ //{
+ // b.ToTable(options.TablePrefix + "UserChatBlacks", options.Schema);
+
+ // b.ConfigureMultiTenant();
+
+ // b.HasIndex(p => new { p.TenantId, p.UserId });
+ //});
+
+ builder.Entity(b =>
+ {
+ b.ToTable(options.TablePrefix + "GroupChatBlacks", options.Schema);
+
+ b.ConfigureByConvention();
+
+ b.HasIndex(p => new { p.TenantId, p.GroupId });
+ });
+
+ builder.Entity(b =>
+ {
+ b.ToTable(options.TablePrefix + "ChatGroups", options.Schema);
+
+ b.Property(p => p.Name).HasMaxLength(ChatGroupConsts.MaxNameLength).IsRequired();
+
+ b.Property(p => p.Tag).HasMaxLength(ChatGroupConsts.MaxTagLength);
+ b.Property(p => p.Notice).HasMaxLength(ChatGroupConsts.MaxNoticeLength);
+ b.Property(p => p.Address).HasMaxLength(ChatGroupConsts.MaxAddressLength);
+ b.Property(p => p.Description).HasMaxLength(ChatGroupConsts.MaxDescriptionLength);
+ b.Property(p => p.AvatarUrl).HasMaxLength(ChatGroupConsts.MaxAvatarUrlLength);
+
+ b.ConfigureByConvention();
+
+ b.HasIndex(p => new { p.TenantId, p.Name });
+ });
+
+ builder.Entity(b =>
+ {
+ b.ToTable(options.TablePrefix + "UserChatGroups", options.Schema);
+
+ b.ConfigureByConvention();
+
+ b.HasIndex(p => new { p.TenantId, p.GroupId, p.UserId });
+ });
+ }
+ }
+}
diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Group/EfCoreGroupRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Groups/EfCoreGroupRepository.cs
similarity index 64%
rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Group/EfCoreGroupRepository.cs
rename to aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Groups/EfCoreGroupRepository.cs
index dc1fac73a..5e288274b 100644
--- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Group/EfCoreGroupRepository.cs
+++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Groups/EfCoreGroupRepository.cs
@@ -1,58 +1,84 @@
-using LINGYUN.Abp.MessageService.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Volo.Abp.DependencyInjection;
-using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
-using Volo.Abp.EntityFrameworkCore;
-
-namespace LINGYUN.Abp.MessageService.Group
-{
- public class EfCoreGroupRepository : EfCoreRepository,
- IGroupRepository, ITransientDependency
- {
- public EfCoreGroupRepository(
- IDbContextProvider dbContextProvider)
- : base(dbContextProvider)
- {
- }
-
- public virtual async Task FindByIdAsync(
- long id,
- CancellationToken cancellationToken = default)
- {
- return await (await GetDbSetAsync())
- .Where(x => x.GroupId.Equals(id))
- .FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
- }
-
- public virtual async Task> GetGroupAdminAsync(
- long id,
- CancellationToken cancellationToken = default)
- {
- var dbContext = await GetDbContextAsync();
- var groupAdmins = await (from gp in dbContext.Set()
- join ucg in dbContext.Set()
- on gp.GroupId equals ucg.GroupId
- join ugc in dbContext.Set()
- on ucg.UserId equals ugc.UserId
- where ugc.IsAdmin
- select ugc)
- .ToListAsync(GetCancellationToken(cancellationToken));
- return groupAdmins;
- }
-
- public virtual async Task UserHasBlackedAsync(
- long id,
- Guid formUserId,
- CancellationToken cancellationToken = default)
- {
- var userHasBlack = await (await GetDbContextAsync()).Set()
- .AnyAsync(x => x.GroupId.Equals(id) && x.ShieldUserId.Equals(formUserId), GetCancellationToken(cancellationToken));
- return userHasBlack;
- }
- }
-}
+using LINGYUN.Abp.MessageService.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Dynamic.Core;
+using System.Threading;
+using System.Threading.Tasks;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
+using Volo.Abp.EntityFrameworkCore;
+
+namespace LINGYUN.Abp.MessageService.Groups
+{
+ public class EfCoreGroupRepository : EfCoreRepository,
+ IGroupRepository, ITransientDependency
+ {
+ public EfCoreGroupRepository(
+ IDbContextProvider dbContextProvider)
+ : base(dbContextProvider)
+ {
+ }
+
+ public virtual async Task GetCountAsync(
+ string filter = null,
+ CancellationToken cancellationToken = default)
+ {
+ return await (await GetDbSetAsync())
+ .WhereIf(!filter.IsNullOrWhiteSpace(), x =>
+ x.Name.Contains(filter) || x.Tag.Contains(filter))
+ .CountAsync(GetCancellationToken(cancellationToken));
+ }
+
+ public virtual async Task