Browse Source

Merge pull request #378 from colinin/4.4.1

调整消息服务分组命名空间
pull/396/head
yx lin 4 years ago
committed by GitHub
parent
commit
302e04b68b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/AbpIMSignalROptions.cs
  2. 40
      aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Hubs/MessagesHub.cs
  3. 33
      aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/UserOnlineChecker.cs
  4. 6
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/Group.cs
  5. 2
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/GroupUserCard.cs
  6. 50
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/IGroupStore.cs
  7. 2
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/IUserGroupStore.cs
  8. 2
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/UserGroup.cs
  9. 15
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/IUserOnlineChanger.cs
  10. 14
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/IUserOnlineChecker.cs
  11. 20
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Messages/IMessageStore.cs
  12. 2
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/UserCard.cs
  13. 10
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/UserOnlineState.cs
  14. 4
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN.Abp.MessageService.Application.Contracts.csproj
  15. 4
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/GetUserLastMessageDto.cs
  16. 29
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/IChatAppService.cs
  17. 3
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/IMyFriendAppService.cs
  18. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupAcceptUserDto.cs
  19. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupRemoveUserDto.cs
  20. 9
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupSearchInput.cs
  21. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupUserGetByPagedDto.cs
  22. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/UserJoinGroupDto.cs
  23. 23
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/IGroupAppService.cs
  24. 40
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/IUserGroupAppService.cs
  25. 14
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationServiceBase.cs
  26. 105
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Chat/ChatAppService.cs
  27. 6
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Chat/MyFriendAppService.cs
  28. 40
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Groups/GroupAppService.cs
  29. 86
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Groups/UserGroupAppService.cs
  30. 4
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Groups/ChatGroupConsts.cs
  31. 21
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/IMessageRepository.cs
  32. 4
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/IUserChatCardRepository.cs
  33. 36
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/MessageStore.cs
  34. 16
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/UserChatCard.cs
  35. 31
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/IGroupRepository.cs
  36. 6
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/ChatGroup.cs
  37. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/GroupChatBlack.cs
  38. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/GroupMessage.cs
  39. 72
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/GroupStore.cs
  40. 55
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/IGroupRepository.cs
  41. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/IGroupRepositoryExtensions.cs
  42. 6
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/IUserChatGroupRepository.cs
  43. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/UserChatGroup.cs
  44. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/UserGroupCard.cs
  45. 10
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/UserGroupStore.cs
  46. 10
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs
  47. 24
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreMessageRepository.cs
  48. 11
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatCardRepository.cs
  49. 15
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatFriendRepository.cs
  50. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreModule.cs
  51. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/IMessageServiceDbContext.cs
  52. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContext.cs
  53. 9
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs
  54. 28
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Groups/EfCoreGroupRepository.cs
  55. 103
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Groups/EfCoreUserChatGroupRepository.cs
  56. 11
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/AbpMessageServiceHttpApiModule.cs
  57. 8
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Chat/MyFriendController.cs
  58. 35
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Groups/GroupController.cs
  59. 55
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Groups/UserGroupController.cs
  60. 622
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211110144233_Add-Field-Online-Avatar.Designer.cs
  61. 47
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211110144233_Add-Field-Online-Avatar.cs
  62. 22
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/MessageServiceHostMigrationsDbContextModelSnapshot.cs
  63. 16
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/appsettings.Development.json

6
aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/AbpIMSignalROptions.cs

@ -10,10 +10,16 @@
/// 用户上线接收方法名称 /// 用户上线接收方法名称
/// </summary> /// </summary>
public string UserOnlineMethod { get; set; } public string UserOnlineMethod { get; set; }
/// <summary>
/// 用户下线接收方法名称
/// </summary>
public string UserOfflineMethod { get; set; }
public AbpIMSignalROptions() public AbpIMSignalROptions()
{ {
GetChatMessageMethod = "get-chat-message"; GetChatMessageMethod = "get-chat-message";
UserOnlineMethod = "on-user-onlined"; UserOnlineMethod = "on-user-onlined";
UserOfflineMethod = "on-user-offlined";
} }
} }
} }

40
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.Contract;
using LINGYUN.Abp.IM.Group; using LINGYUN.Abp.IM.Groups;
using LINGYUN.Abp.IM.Messages; using LINGYUN.Abp.IM.Messages;
using LINGYUN.Abp.RealTime.Client; using LINGYUN.Abp.RealTime.Client;
using LINGYUN.Abp.RealTime.SignalR; using LINGYUN.Abp.RealTime.SignalR;
@ -19,6 +19,8 @@ namespace LINGYUN.Abp.IM.SignalR.Hubs
{ {
protected IMessageProcessor Processor => LazyServiceProvider.LazyGetRequiredService<IMessageProcessor>(); protected IMessageProcessor Processor => LazyServiceProvider.LazyGetRequiredService<IMessageProcessor>();
protected IUserOnlineChanger OnlineChanger => LazyServiceProvider.LazyGetService<IUserOnlineChanger>();
protected AbpIMSignalROptions Options { get; } protected AbpIMSignalROptions Options { get; }
protected IFriendStore FriendStore { get; } protected IFriendStore FriendStore { get; }
protected IMessageStore MessageStore { get; } protected IMessageStore MessageStore { get; }
@ -39,21 +41,43 @@ namespace LINGYUN.Abp.IM.SignalR.Hubs
protected override async Task OnClientConnectedAsync(IOnlineClient client) protected override async Task OnClientConnectedAsync(IOnlineClient client)
{ {
await base.OnClientConnectedAsync(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); var userGroups = await UserGroupStore.GetUserGroupsAsync(client.TenantId, client.UserId.Value);
foreach (var group in userGroups) foreach (var group in userGroups)
{ {
// 应使用群组标识 if (isOnlined)
await Groups.AddToGroupAsync(client.ConnectionId, group.Id); {
// 应使用群组标识
await Groups.AddToGroupAsync(client.ConnectionId, group.Id);
}
var groupClient = Clients.Group(group.Id); var groupClient = Clients.Group(group.Id);
if (groupClient != null) 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); var userFriends = await FriendStore.GetListAsync(client.TenantId, client.UserId.Value);
if (userFriends.Count > 0) if (userFriends.Count > 0)
{ {
@ -61,7 +85,7 @@ namespace LINGYUN.Abp.IM.SignalR.Hubs
var userClients = Clients.Users(friendClientIds); var userClients = Clients.Users(friendClientIds);
if (userClients != null) if (userClients != null)
{ {
await userClients.SendAsync(Options.UserOnlineMethod, client.TenantId, client.UserId.Value); await userClients.SendAsync(methodName, client.TenantId, client.UserId.Value);
} }
} }
} }

33
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<bool> 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);
}
}
}

6
aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Group/Group.cs → 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 public class Group
{ {
@ -11,6 +11,10 @@
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }
/// <summary> /// <summary>
/// 群组头像
/// </summary>
public string AvatarUrl { get; set; }
/// <summary>
/// 允许匿名聊天 /// 允许匿名聊天
/// </summary> /// </summary>
public bool AllowAnonymous { get; set; } public bool AllowAnonymous { get; set; }

2
aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Group/GroupUserCard.cs → aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/GroupUserCard.cs

@ -1,4 +1,4 @@
namespace LINGYUN.Abp.IM.Group namespace LINGYUN.Abp.IM.Groups
{ {
public class GroupUserCard : UserCard public class GroupUserCard : UserCard
{ {

50
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
{
/// <summary>
/// 获取群组信息
/// </summary>
/// <param name="tenantId"></param>
/// <param name="groupId"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<Group> GetAsync(
Guid? tenantId,
string groupId,
CancellationToken cancellationToken = default);
/// <summary>
/// 获取群组数
/// </summary>
/// <param name="tenantId"></param>
/// <param name="filter"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<int> GetCountAsync(
Guid? tenantId,
string filter = null,
CancellationToken cancellationToken = default);
/// <summary>
/// 获取群组列表
/// </summary>
/// <param name="tenantId"></param>
/// <param name="filter"></param>
/// <param name="sorting"></param>
/// <param name="skipCount"></param>
/// <param name="maxResultCount"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<List<Group>> GetListAsync(
Guid? tenantId,
string filter = null,
string sorting = nameof(Group.Name),
int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default);
}
}

2
aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Group/IUserGroupStore.cs → 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;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace LINGYUN.Abp.IM.Group namespace LINGYUN.Abp.IM.Groups
{ {
public interface IUserGroupStore public interface IUserGroupStore
{ {

2
aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Group/UserGroup.cs → aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Groups/UserGroup.cs

@ -1,6 +1,6 @@
using System; using System;
namespace LINGYUN.Abp.IM.Group namespace LINGYUN.Abp.IM.Groups
{ {
public class UserGroup public class UserGroup
{ {

15
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);
}
}

14
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<bool> CheckAsync(
Guid? tenantId,
Guid userId,
CancellationToken cancellationToken = default);
}
}

20
aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Messages/IMessageStore.cs

@ -28,8 +28,8 @@ namespace LINGYUN.Abp.IM.Messages
Task<long> GetGroupMessageCountAsync( Task<long> GetGroupMessageCountAsync(
Guid? tenantId, Guid? tenantId,
long groupId, long groupId,
string filter = "",
MessageType? type = null, MessageType? type = null,
string filter = "",
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// 获取群组聊天记录 /// 获取群组聊天记录
@ -45,9 +45,9 @@ namespace LINGYUN.Abp.IM.Messages
Task<List<ChatMessage>> GetGroupMessageAsync( Task<List<ChatMessage>> GetGroupMessageAsync(
Guid? tenantId, Guid? tenantId,
long groupId, long groupId,
MessageType? type = null,
string filter = "", string filter = "",
string sorting = nameof(ChatMessage.MessageId), string sorting = nameof(ChatMessage.MessageId),
MessageType? type = null,
int skipCount = 0, int skipCount = 0,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
@ -56,12 +56,14 @@ namespace LINGYUN.Abp.IM.Messages
/// </summary> /// </summary>
/// <param name="tenantId"></param> /// <param name="tenantId"></param>
/// <param name="userId"></param> /// <param name="userId"></param>
/// <param name="state"></param>
/// <param name="sorting"></param> /// <param name="sorting"></param>
/// <param name="maxResultCount"></param> /// <param name="maxResultCount"></param>
/// <returns></returns> /// <returns></returns>
Task<List<LastChatMessage>> GetLastChatMessagesAsync( Task<List<LastChatMessage>> GetLastChatMessagesAsync(
Guid? tenantId, Guid? tenantId,
Guid userId, Guid userId,
MessageState? state = null,
string sorting = nameof(LastChatMessage.SendTime), string sorting = nameof(LastChatMessage.SendTime),
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
@ -79,23 +81,29 @@ namespace LINGYUN.Abp.IM.Messages
Guid? tenantId, Guid? tenantId,
Guid sendUserId, Guid sendUserId,
Guid receiveUserId, Guid receiveUserId,
string filter = "",
MessageType? type = null, MessageType? type = null,
string filter = "",
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// 获取与某个用户聊天记录 /// 获取用户聊天记录
/// </summary> /// </summary>
/// <param name="tenantId"></param> /// <param name="tenantId"></param>
/// <param name="userId"></param> /// <param name="sendUserId"></param>
/// <param name="receiveUserId"></param>
/// <param name="type"></param>
/// <param name="filter"></param>
/// <param name="sorting"></param>
/// <param name="skipCount"></param>
/// <param name="maxResultCount"></param> /// <param name="maxResultCount"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns> /// <returns></returns>
Task<List<ChatMessage>> GetChatMessageAsync( Task<List<ChatMessage>> GetChatMessageAsync(
Guid? tenantId, Guid? tenantId,
Guid sendUserId, Guid sendUserId,
Guid receiveUserId, Guid receiveUserId,
MessageType? type = null,
string filter = "", string filter = "",
string sorting = nameof(ChatMessage.MessageId), string sorting = nameof(ChatMessage.MessageId),
MessageType? type = null,
int skipCount = 0, int skipCount = 0,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);

2
aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/UserCard.cs

@ -40,6 +40,8 @@ namespace LINGYUN.Abp.IM
/// </summary> /// </summary>
public DateTime? Birthday { get; set; } public DateTime? Birthday { get; set; }
public bool Online { get; set; }
#endregion #endregion
} }
} }

10
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
}
}

4
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN.Abp.MessageService.Application.Contracts.csproj

@ -28,8 +28,4 @@
<ProjectReference Include="..\..\message\LINGYUN.Abp.MessageService.Domain.Shared\LINGYUN.Abp.MessageService.Domain.Shared.csproj" /> <ProjectReference Include="..\..\message\LINGYUN.Abp.MessageService.Domain.Shared\LINGYUN.Abp.MessageService.Domain.Shared.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="LINGYUN\Abp\MessageService\Group\" />
</ItemGroup>
</Project> </Project>

4
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 namespace LINGYUN.Abp.MessageService.Chat
{ {
@ -6,5 +7,6 @@ namespace LINGYUN.Abp.MessageService.Chat
{ {
public int MaxResultCount { get; set; } public int MaxResultCount { get; set; }
public string Sorting { get; set; } public string Sorting { get; set; }
public MessageState? State { get; set; }
} }
} }

29
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/IChatAppService.cs

@ -13,35 +13,6 @@ namespace LINGYUN.Abp.MessageService.Chat
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
Task<ChatMessageSendResultDto> SendMessageAsync(ChatMessage input); Task<ChatMessageSendResultDto> SendMessageAsync(ChatMessage input);
///// <summary>
///// 申请加入群组
///// </summary>
///// <param name="input"></param>
///// <returns></returns>
//Task ApplyJoinGroupAsync(UserJoinGroupDto input);
///// <summary>
///// 获取我的群组
///// </summary>
///// <returns></returns>
//Task<ListResultDto<Group>> GetMyGroupsAsync();
///// <summary>
///// 获取群组用户
///// </summary>
///// <param name="input"></param>
///// <returns></returns>
//Task<PagedResultDto<GroupUserCard>> GetGroupUsersAsync(GroupUserGetByPagedDto input);
///// <summary>
///// 处理用户群组申请
///// </summary>
///// <param name="input"></param>
///// <returns></returns>
//Task GroupAcceptUserAsync(GroupAcceptUserDto input);
///// <summary>
///// 群组移除用户
///// </summary>
///// <param name="input"></param>
///// <returns></returns>
//Task GroupRemoveUserAsync(GroupRemoveUserDto input);
/// <summary> /// <summary>
/// 获取群组消息 /// 获取群组消息
/// </summary> /// </summary>

3
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/IMyFriendAppService.cs

@ -1,4 +1,5 @@
using LINGYUN.Abp.IM.Contract; using LINGYUN.Abp.IM.Contract;
using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
@ -7,6 +8,8 @@ namespace LINGYUN.Abp.MessageService.Chat
{ {
public interface IMyFriendAppService : IApplicationService public interface IMyFriendAppService : IApplicationService
{ {
Task<UserFriend> GetAsync(Guid friendId);
Task<PagedResultDto<UserFriend>> GetListAsync(MyFriendGetByPagedDto input); Task<PagedResultDto<UserFriend>> GetListAsync(MyFriendGetByPagedDto input);
Task<ListResultDto<UserFriend>> GetAllListAsync(GetMyFriendsDto input); Task<ListResultDto<UserFriend>> GetAllListAsync(GetMyFriendsDto input);

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/GroupAcceptUserDto.cs → aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupAcceptUserDto.cs

@ -1,7 +1,7 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace LINGYUN.Abp.MessageService.Chat namespace LINGYUN.Abp.MessageService.Groups
{ {
public class GroupAcceptUserDto public class GroupAcceptUserDto
{ {

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/GroupRemoveUserDto.cs → aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/GroupRemoveUserDto.cs

@ -1,7 +1,7 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace LINGYUN.Abp.MessageService.Chat namespace LINGYUN.Abp.MessageService.Groups
{ {
public class GroupRemoveUserDto public class GroupRemoveUserDto
{ {

9
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; }
}
}

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/GroupUserGetByPagedDto.cs → 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 System.ComponentModel.DataAnnotations;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
namespace LINGYUN.Abp.MessageService.Chat namespace LINGYUN.Abp.MessageService.Groups
{ {
public class GroupUserGetByPagedDto : PagedAndSortedResultRequestDto public class GroupUserGetByPagedDto : PagedAndSortedResultRequestDto
{ {

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Chat/Dto/UserJoinGroupDto.cs → aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Groups/Dto/UserJoinGroupDto.cs

@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace LINGYUN.Abp.MessageService.Chat namespace LINGYUN.Abp.MessageService.Groups
{ {
public class UserJoinGroupDto public class UserJoinGroupDto
{ {

23
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
{
/// <summary>
/// 搜索群组
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task<PagedResultDto<Group>> SearchAsync(GroupSearchInput input);
/// <summary>
/// 获取群组信息
/// </summary>
/// <param name="groupId"></param>
/// <returns></returns>
Task<Group> GetAsync(string groupId);
}
}

40
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
{
/// <summary>
/// 申请加入群组
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task ApplyJoinGroupAsync(UserJoinGroupDto input);
/// <summary>
/// 获取我的群组
/// </summary>
/// <returns></returns>
Task<ListResultDto<Group>> GetMyGroupsAsync();
/// <summary>
/// 获取群组用户
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task<PagedResultDto<GroupUserCard>> GetGroupUsersAsync(GroupUserGetByPagedDto input);
/// <summary>
/// 处理用户群组申请
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task GroupAcceptUserAsync(GroupAcceptUserDto input);
/// <summary>
/// 群组移除用户
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task GroupRemoveUserAsync(GroupRemoveUserDto input);
}
}

14
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);
}
}
}

105
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 LINGYUN.Abp.IM.Messages;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -28,13 +28,23 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task<PagedResultDto<ChatMessage>> GetMyChatMessageAsync(UserMessageGetByPagedDto input) public virtual async Task<PagedResultDto<ChatMessage>> GetMyChatMessageAsync(UserMessageGetByPagedDto input)
{ {
var chatMessageCount = await _messageStore var chatMessageCount = await _messageStore
.GetChatMessageCountAsync(CurrentTenant.Id, CurrentUser.GetId(), input.ReceiveUserId, .GetChatMessageCountAsync(
input.Filter, input.MessageType); CurrentTenant.Id,
CurrentUser.GetId(),
input.ReceiveUserId,
input.MessageType,
input.Filter);
var chatMessages = await _messageStore var chatMessages = await _messageStore
.GetChatMessageAsync(CurrentTenant.Id, CurrentUser.GetId(), input.ReceiveUserId, .GetChatMessageAsync(
input.Filter, input.Sorting, CurrentTenant.Id,
input.MessageType, input.SkipCount, input.MaxResultCount); CurrentUser.GetId(),
input.ReceiveUserId,
input.MessageType,
input.Filter,
input.Sorting,
input.SkipCount,
input.MaxResultCount);
return new PagedResultDto<ChatMessage>(chatMessageCount, chatMessages); return new PagedResultDto<ChatMessage>(chatMessageCount, chatMessages);
} }
@ -42,86 +52,43 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task<ListResultDto<LastChatMessage>> GetMyLastChatMessageAsync(GetUserLastMessageDto input) public virtual async Task<ListResultDto<LastChatMessage>> GetMyLastChatMessageAsync(GetUserLastMessageDto input)
{ {
var chatMessages = await _messageStore var chatMessages = await _messageStore
.GetLastChatMessagesAsync(CurrentTenant.Id, CurrentUser.GetId(), .GetLastChatMessagesAsync(
input.Sorting, input.MaxResultCount); CurrentTenant.Id,
CurrentUser.GetId(),
input.State,
input.Sorting,
input.MaxResultCount);
return new ListResultDto<LastChatMessage>(chatMessages); return new ListResultDto<LastChatMessage>(chatMessages);
} }
public virtual async Task<PagedResultDto<ChatMessage>> GetMyGroupMessageAsync(GroupMessageGetByPagedDto input) public virtual async Task<PagedResultDto<ChatMessage>> 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); throw new BusinessException(MessageServiceErrorCodes.YouHaveNotJoinedGroup);
} }
var groupMessageCount = await _messageStore var groupMessageCount = await _messageStore
.GetGroupMessageCountAsync(CurrentTenant.Id, input.GroupId, .GetGroupMessageCountAsync(
input.Filter, input.MessageType); CurrentTenant.Id,
input.GroupId,
input.MessageType,
input.Filter);
var groupMessages = await _messageStore var groupMessages = await _messageStore
.GetGroupMessageAsync(CurrentTenant.Id, input.GroupId, .GetGroupMessageAsync(
input.Filter, input.Sorting, CurrentTenant.Id,
input.MessageType, input.SkipCount, input.MaxResultCount); input.GroupId,
input.MessageType,
input.Filter,
input.Sorting,
input.SkipCount,
input.MaxResultCount);
return new PagedResultDto<ChatMessage>(groupMessageCount, groupMessages); return new PagedResultDto<ChatMessage>(groupMessageCount, groupMessages);
} }
//public virtual async Task<PagedResultDto<GroupUserCard>> 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<GroupUserCard>(groupUserCardCount, groupUserCards);
//}
//[Authorize]
//public virtual async Task<ListResultDto<Group>> GetMyGroupsAsync()
//{
// var myGroups = await _userGroupStore.GetUserGroupsAsync(CurrentTenant.Id, CurrentUser.GetId());
// return new ListResultDto<Group>(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<ChatMessageSendResultDto> SendMessageAsync(ChatMessage input) public virtual async Task<ChatMessageSendResultDto> SendMessageAsync(ChatMessage input)
{ {

6
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.IM.Contract;
using LINGYUN.Abp.MessageService.Localization; using LINGYUN.Abp.MessageService.Localization;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
@ -25,6 +26,11 @@ namespace LINGYUN.Abp.MessageService.Chat
LocalizationResource = typeof(MessageServiceResource); LocalizationResource = typeof(MessageServiceResource);
} }
public virtual async Task<UserFriend> GetAsync(Guid friendId)
{
return await FriendStore.GetMemberAsync(CurrentTenant.Id, CurrentUser.GetId(), friendId);
}
public virtual async Task CreateAsync(MyFriendCreateDto input) public virtual async Task CreateAsync(MyFriendCreateDto input)
{ {
var friendCard = await UserChatCardRepository.GetMemberAsync(input.FriendId); var friendCard = await UserChatCardRepository.GetMemberAsync(input.FriendId);

40
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<Group> GetAsync(string groupId)
{
return await _groupStore.GetAsync(CurrentTenant.Id, groupId);
}
public virtual async Task<PagedResultDto<Group>> 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<Group>(count, groups);
}
}
}

86
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<PagedResultDto<GroupUserCard>> 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<GroupUserCard>(groupUserCardCount, groupUserCards);
}
public virtual async Task<ListResultDto<Group>> GetMyGroupsAsync()
{
var myGroups = await _userGroupStore.GetUserGroupsAsync(CurrentTenant.Id, CurrentUser.GetId());
return new ListResultDto<Group>(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);
}
}
}

4
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Group/ChatGroupConsts.cs → aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Groups/ChatGroupConsts.cs

@ -1,4 +1,4 @@
namespace LINGYUN.Abp.MessageService.Group namespace LINGYUN.Abp.MessageService.Groups
{ {
public class ChatGroupConsts public class ChatGroupConsts
{ {
@ -11,5 +11,7 @@
public const int MaxNoticeLength = 64; public const int MaxNoticeLength = 64;
public const int MaxDescriptionLength = 128; public const int MaxDescriptionLength = 128;
public const int MaxAvatarUrlLength = 128;
} }
} }

21
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.IM.Messages;
using LINGYUN.Abp.MessageService.Group; using LINGYUN.Abp.MessageService.Groups;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
@ -36,25 +36,26 @@ namespace LINGYUN.Abp.MessageService.Chat
Task<long> GetUserMessagesCountAsync( Task<long> GetUserMessagesCountAsync(
Guid sendUserId, Guid sendUserId,
Guid receiveUserId, Guid receiveUserId,
string filter = "",
MessageType? type = null, MessageType? type = null,
string filter = "",
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<long> GetCountAsync( Task<long> GetCountAsync(
long groupId, long groupId,
string filter = "",
MessageType? type = null, MessageType? type = null,
string filter = "",
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<long> GetCountAsync( Task<long> GetCountAsync(
Guid sendUserId, Guid sendUserId,
Guid receiveUserId, Guid receiveUserId,
string filter = "",
MessageType? type = null, MessageType? type = null,
string filter = "",
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<List<LastChatMessage>> GetLastMessagesByOneFriendAsync( Task<List<LastChatMessage>> GetLastMessagesAsync(
Guid userId, Guid userId,
MessageState? state = null,
string sorting = nameof(LastChatMessage.SendTime), string sorting = nameof(LastChatMessage.SendTime),
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
@ -62,24 +63,24 @@ namespace LINGYUN.Abp.MessageService.Chat
Task<List<UserMessage>> GetUserMessagesAsync( Task<List<UserMessage>> GetUserMessagesAsync(
Guid sendUserId, Guid sendUserId,
Guid receiveUserId, Guid receiveUserId,
MessageType? type = null,
string filter = "", string filter = "",
string sorting = nameof(UserMessage.MessageId), string sorting = nameof(UserMessage.MessageId),
MessageType? type = null,
int skipCount = 0, int skipCount = 0,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<long> GetGroupMessagesCountAsync( Task<long> GetGroupMessagesCountAsync(
long groupId, long groupId,
string filter = "",
MessageType? type = null, MessageType? type = null,
string filter = "",
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<List<GroupMessage>> GetGroupMessagesAsync( Task<List<GroupMessage>> GetGroupMessagesAsync(
long groupId, long groupId,
MessageType? type = null,
string filter = "", string filter = "",
string sorting = nameof(UserMessage.MessageId), string sorting = nameof(UserMessage.MessageId),
MessageType? type = null,
int skipCount = 0, int skipCount = 0,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
@ -87,16 +88,16 @@ namespace LINGYUN.Abp.MessageService.Chat
Task<long> GetUserGroupMessagesCountAsync( Task<long> GetUserGroupMessagesCountAsync(
Guid sendUserId, Guid sendUserId,
long groupId, long groupId,
string filter = "",
MessageType? type = null, MessageType? type = null,
string filter = "",
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<List<GroupMessage>> GetUserGroupMessagesAsync( Task<List<GroupMessage>> GetUserGroupMessagesAsync(
Guid sendUserId, Guid sendUserId,
long groupId, long groupId,
MessageType? type = null,
string filter = "", string filter = "",
string sorting = nameof(UserMessage.MessageId), string sorting = nameof(UserMessage.MessageId),
MessageType? type = null,
int skipCount = 0, int skipCount = 0,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);

4
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<UserChatCard, long> public interface IUserChatCardRepository : IBasicRepository<UserChatCard, long>
{ {
Task<UserChatCard> FindByUserIdAsync(
Guid userId,
CancellationToken cancellationToken = default);
Task<bool> CheckUserIdExistsAsync( Task<bool> CheckUserIdExistsAsync(
Guid userId, Guid userId,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);

36
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.Contract;
using LINGYUN.Abp.IM.Messages; using LINGYUN.Abp.IM.Messages;
using LINGYUN.Abp.MessageService.Group; using LINGYUN.Abp.MessageService.Groups;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
@ -72,9 +72,9 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task<List<ChatMessage>> GetGroupMessageAsync( public virtual async Task<List<ChatMessage>> GetGroupMessageAsync(
Guid? tenantId, Guid? tenantId,
long groupId, long groupId,
MessageType? type = null,
string filter = "", string filter = "",
string sorting = nameof(ChatMessage.MessageId), string sorting = nameof(ChatMessage.MessageId),
MessageType? type = null,
int skipCount = 0, int skipCount = 0,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
@ -82,7 +82,14 @@ namespace LINGYUN.Abp.MessageService.Chat
using (_currentTenant.Change(tenantId)) using (_currentTenant.Change(tenantId))
{ {
var groupMessages = await _messageRepository 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<GroupMessage>, List<ChatMessage>>(groupMessages); var chatMessages = _objectMapper.Map<List<GroupMessage>, List<ChatMessage>>(groupMessages);
@ -94,9 +101,9 @@ namespace LINGYUN.Abp.MessageService.Chat
Guid? tenantId, Guid? tenantId,
Guid sendUserId, Guid sendUserId,
Guid receiveUserId, Guid receiveUserId,
MessageType? type = null,
string filter = "", string filter = "",
string sorting = nameof(ChatMessage.MessageId), string sorting = nameof(ChatMessage.MessageId),
MessageType? type = null,
int skipCount = 0, int skipCount = 0,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
@ -104,7 +111,15 @@ namespace LINGYUN.Abp.MessageService.Chat
using (_currentTenant.Change(tenantId)) using (_currentTenant.Change(tenantId))
{ {
var userMessages = await _messageRepository 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<UserMessage>, List<ChatMessage>>(userMessages); var chatMessages = _objectMapper.Map<List<UserMessage>, List<ChatMessage>>(userMessages);
@ -115,6 +130,7 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task<List<LastChatMessage>> GetLastChatMessagesAsync( public virtual async Task<List<LastChatMessage>> GetLastChatMessagesAsync(
Guid? tenantId, Guid? tenantId,
Guid userId, Guid userId,
MessageState? state = null,
string sorting = nameof(LastChatMessage.SendTime), string sorting = nameof(LastChatMessage.SendTime),
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
@ -123,20 +139,20 @@ namespace LINGYUN.Abp.MessageService.Chat
using (_currentTenant.Change(tenantId)) using (_currentTenant.Change(tenantId))
{ {
return await _messageRepository return await _messageRepository
.GetLastMessagesByOneFriendAsync(userId, sorting, maxResultCount, cancellationToken); .GetLastMessagesAsync(userId, state, sorting, maxResultCount, cancellationToken);
} }
} }
public virtual async Task<long> GetGroupMessageCountAsync( public virtual async Task<long> GetGroupMessageCountAsync(
Guid? tenantId, Guid? tenantId,
long groupId, long groupId,
string filter = "",
MessageType? type = null, MessageType? type = null,
string filter = "",
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
using (_currentTenant.Change(tenantId)) using (_currentTenant.Change(tenantId))
{ {
return await _messageRepository.GetCountAsync(groupId, filter, type, cancellationToken); return await _messageRepository.GetCountAsync(groupId, type, filter, cancellationToken);
} }
} }
@ -144,13 +160,13 @@ namespace LINGYUN.Abp.MessageService.Chat
Guid? tenantId, Guid? tenantId,
Guid sendUserId, Guid sendUserId,
Guid receiveUserId, Guid receiveUserId,
string filter = "",
MessageType? type = null, MessageType? type = null,
string filter = "",
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
using (_currentTenant.Change(tenantId)) using (_currentTenant.Change(tenantId))
{ {
return await _messageRepository.GetCountAsync(sendUserId, receiveUserId, filter, type, cancellationToken); return await _messageRepository.GetCountAsync(sendUserId, receiveUserId, type, filter, cancellationToken);
} }
} }

16
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/UserChatCard.cs

@ -53,6 +53,10 @@ namespace LINGYUN.Abp.MessageService.Chat
/// </summary> /// </summary>
public virtual int Age { 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() protected UserChatCard()
{ {
} }
@ -85,6 +89,15 @@ namespace LINGYUN.Abp.MessageService.Chat
AvatarUrl = url; AvatarUrl = url;
} }
public void ChangeState(IClock clock, UserOnlineState state)
{
State = state;
if (State == UserOnlineState.Online)
{
LastOnlineTime = clock.Now;
}
}
public UserCard ToUserCard() public UserCard ToUserCard()
{ {
return new UserCard return new UserCard
@ -98,7 +111,8 @@ namespace LINGYUN.Abp.MessageService.Chat
Sign = Sign, Sign = Sign,
UserId = UserId, UserId = UserId,
UserName = UserName, UserName = UserName,
TenantId = TenantId TenantId = TenantId,
Online = State == UserOnlineState.Online,
}; };
} }
} }

31
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/IGroupRepository.cs

@ -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<ChatGroup, long>
{
/// <summary>
/// 用户是否已被拉黑
/// </summary>
/// <param name="id"></param>
/// <param name="formUserId"></param>
/// <returns></returns>
Task<bool> UserHasBlackedAsync(
long id,
Guid formUserId,
CancellationToken cancellationToken = default);
Task<ChatGroup> FindByIdAsync(
long id,
CancellationToken cancellationToken = default);
Task<List<UserGroupCard>> GetGroupAdminAsync(
long id,
CancellationToken cancellationToken = default);
}
}

6
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/ChatGroup.cs → aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/ChatGroup.cs

@ -2,7 +2,7 @@
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
namespace LINGYUN.Abp.MessageService.Group namespace LINGYUN.Abp.MessageService.Groups
{ {
/// <summary> /// <summary>
/// 聊天群组 /// 聊天群组
@ -53,6 +53,10 @@ namespace LINGYUN.Abp.MessageService.Group
/// 群组说明 /// 群组说明
/// </summary> /// </summary>
public virtual string Description { get; set; } public virtual string Description { get; set; }
/// <summary>
/// 群组头像地址
/// </summary>
public virtual string AvatarUrl { get; set; }
protected ChatGroup() protected ChatGroup()
{ {
} }

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/GroupChatBlack.cs → aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/GroupChatBlack.cs

@ -2,7 +2,7 @@
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
namespace LINGYUN.Abp.MessageService.Group namespace LINGYUN.Abp.MessageService.Groups
{ {
/// <summary> /// <summary>
/// 用户黑名单 /// 用户黑名单

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/GroupMessage.cs → aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/GroupMessage.cs

@ -2,7 +2,7 @@
using LINGYUN.Abp.MessageService.Chat; using LINGYUN.Abp.MessageService.Chat;
using System; using System;
namespace LINGYUN.Abp.MessageService.Group namespace LINGYUN.Abp.MessageService.Groups
{ {
public class GroupMessage : Message public class GroupMessage : Message
{ {

72
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<Group> GetAsync(
Guid? tenantId,
string groupId,
CancellationToken cancellationToken = default)
{
using (_currentTenant.Change(tenantId))
{
var group = await _groupRepository.FindByIdAsync(long.Parse(groupId), cancellationToken);
return _objectMapper.Map<ChatGroup, Group>(group);
}
}
public virtual async Task<int> GetCountAsync(
Guid? tenantId,
string filter = null,
CancellationToken cancellationToken = default)
{
using (_currentTenant.Change(tenantId))
{
return await _groupRepository.GetCountAsync(filter, cancellationToken);
}
}
public virtual async Task<List<Group>> 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<ChatGroup>, List<Group>>(groups);
}
}
}
}

55
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<ChatGroup, long>
{
/// <summary>
/// 用户是否已被拉黑
/// </summary>
/// <param name="id"></param>
/// <param name="formUserId"></param>
/// <returns></returns>
Task<bool> UserHasBlackedAsync(
long id,
Guid formUserId,
CancellationToken cancellationToken = default);
Task<ChatGroup> FindByIdAsync(
long id,
CancellationToken cancellationToken = default);
Task<List<UserGroupCard>> GetGroupAdminAsync(
long id,
CancellationToken cancellationToken = default);
/// <summary>
/// 获取群组数
/// </summary>
/// <param name="filter"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<int> GetCountAsync(
string filter = null,
CancellationToken cancellationToken = default);
/// <summary>
/// 获取群组列表
/// </summary>
/// <param name="filter"></param>
/// <param name="sorting"></param>
/// <param name="skipCount"></param>
/// <param name="maxResultCount"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<List<ChatGroup>> GetListAsync(
string filter = null,
string sorting = nameof(ChatGroup.Name),
int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default);
}
}

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/IGroupRepositoryExtensions.cs → aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/IGroupRepositoryExtensions.cs

@ -2,7 +2,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp; using Volo.Abp;
namespace LINGYUN.Abp.MessageService.Group namespace LINGYUN.Abp.MessageService.Groups
{ {
public static class IGroupRepositoryExtensions public static class IGroupRepositoryExtensions
{ {

6
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/IUserChatGroupRepository.cs → 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
namespace LINGYUN.Abp.MessageService.Group namespace LINGYUN.Abp.MessageService.Groups
{ {
public interface IUserChatGroupRepository : IBasicRepository<UserChatGroup, long> public interface IUserChatGroupRepository : IBasicRepository<UserChatGroup, long>
{ {
@ -60,7 +60,7 @@ namespace LINGYUN.Abp.MessageService.Group
/// <param name="userId"></param> /// <param name="userId"></param>
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <returns></returns>
Task<List<LINGYUN.Abp.IM.Group.Group>> GetMemberGroupsAsync( Task<List<Group>> GetMemberGroupsAsync(
Guid userId, Guid userId,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
/// <summary> /// <summary>

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/UserChatGroup.cs → aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/UserChatGroup.cs

@ -2,7 +2,7 @@
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
namespace LINGYUN.Abp.MessageService.Group namespace LINGYUN.Abp.MessageService.Groups
{ {
/// <summary> /// <summary>
/// 用户群组 /// 用户群组

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/UserGroupCard.cs → aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/UserGroupCard.cs

@ -3,7 +3,7 @@ using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
using Volo.Abp.Timing; using Volo.Abp.Timing;
namespace LINGYUN.Abp.MessageService.Group namespace LINGYUN.Abp.MessageService.Groups
{ {
/// <summary> /// <summary>
/// 用户群组卡片 /// 用户群组卡片

10
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Group/UserGroupStore.cs → 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Uow; using Volo.Abp.Uow;
namespace LINGYUN.Abp.MessageService.Group namespace LINGYUN.Abp.MessageService.Groups
{ {
public class UserGroupStore : IUserGroupStore, ITransientDependency public class UserGroupStore : IUserGroupStore, ITransientDependency
{ {
private readonly IObjectMapper _objectMapper;
private readonly ICurrentTenant _currentTenant; private readonly ICurrentTenant _currentTenant;
private readonly IUnitOfWorkManager _unitOfWorkManager; private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IUserChatGroupRepository _userChatGroupRepository; private readonly IUserChatGroupRepository _userChatGroupRepository;
public UserGroupStore( public UserGroupStore(
IObjectMapper objectMapper,
ICurrentTenant currentTenant, ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager, IUnitOfWorkManager unitOfWorkManager,
IUserChatGroupRepository userChatGroupRepository) IUserChatGroupRepository userChatGroupRepository)
{ {
_objectMapper = objectMapper;
_currentTenant = currentTenant; _currentTenant = currentTenant;
_unitOfWorkManager = unitOfWorkManager; _unitOfWorkManager = unitOfWorkManager;
_userChatGroupRepository = userChatGroupRepository; _userChatGroupRepository = userChatGroupRepository;
@ -90,7 +86,7 @@ namespace LINGYUN.Abp.MessageService.Group
} }
} }
public async Task<IEnumerable<LINGYUN.Abp.IM.Group.Group>> GetUserGroupsAsync( public async Task<IEnumerable<Group>> GetUserGroupsAsync(
Guid? tenantId, Guid? tenantId,
Guid userId, Guid userId,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)

10
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs

@ -1,12 +1,11 @@
using AutoMapper; using AutoMapper;
using LINGYUN.Abp.IM.Groups;
using LINGYUN.Abp.IM.Messages; using LINGYUN.Abp.IM.Messages;
using LINGYUN.Abp.MessageService.Chat; using LINGYUN.Abp.MessageService.Chat;
using LINGYUN.Abp.MessageService.Group; using LINGYUN.Abp.MessageService.Groups;
using LINGYUN.Abp.MessageService.Notifications; using LINGYUN.Abp.MessageService.Notifications;
using LINGYUN.Abp.MessageService.Subscriptions; using LINGYUN.Abp.MessageService.Subscriptions;
using LINGYUN.Abp.Notifications; using LINGYUN.Abp.Notifications;
using Newtonsoft.Json;
using System;
using Volo.Abp.AutoMapper; using Volo.Abp.AutoMapper;
using Volo.Abp.Data; using Volo.Abp.Data;
@ -57,6 +56,11 @@ namespace LINGYUN.Abp.MessageService.Mapper
CreateMessageMap<UserMessage, LastChatMessage>() CreateMessageMap<UserMessage, LastChatMessage>()
.ForMember(dto => dto.ToUserId, map => map.MapFrom(src => src.ReceiveUserId)) .ForMember(dto => dto.ToUserId, map => map.MapFrom(src => src.ReceiveUserId))
.Ignore(dto => dto.GroupId); .Ignore(dto => dto.GroupId);
CreateMap<ChatGroup, Group>()
.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<TSource, TDestination> CreateMessageMap<TSource, TDestination>() protected IMappingExpression<TSource, TDestination> CreateMessageMap<TSource, TDestination>()

24
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.IM.Messages;
using LINGYUN.Abp.MessageService.EntityFrameworkCore; using LINGYUN.Abp.MessageService.EntityFrameworkCore;
using LINGYUN.Abp.MessageService.Group; using LINGYUN.Abp.MessageService.Groups;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -35,9 +35,9 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task<List<GroupMessage>> GetGroupMessagesAsync( public virtual async Task<List<GroupMessage>> GetGroupMessagesAsync(
long groupId, long groupId,
MessageType? type = null,
string filter = "", string filter = "",
string sorting = nameof(UserMessage.MessageId), string sorting = nameof(UserMessage.MessageId),
MessageType? type = null,
int skipCount = 0, int skipCount = 0,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
@ -57,8 +57,8 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task<long> GetGroupMessagesCountAsync( public virtual async Task<long> GetGroupMessagesCountAsync(
long groupId, long groupId,
string filter = "",
MessageType? type = null, MessageType? type = null,
string filter = "",
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var groupMessagesCount = await (await GetDbContextAsync()).Set<GroupMessage>() var groupMessagesCount = await (await GetDbContextAsync()).Set<GroupMessage>()
@ -73,9 +73,9 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task<List<GroupMessage>> GetUserGroupMessagesAsync( public virtual async Task<List<GroupMessage>> GetUserGroupMessagesAsync(
Guid sendUserId, Guid sendUserId,
long groupId, long groupId,
MessageType? type = null,
string filter = "", string filter = "",
string sorting = nameof(UserMessage.MessageId), string sorting = nameof(UserMessage.MessageId),
MessageType? type = null,
int skipCount = 0, int skipCount = 0,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
@ -96,8 +96,8 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task<long> GetUserGroupMessagesCountAsync( public virtual async Task<long> GetUserGroupMessagesCountAsync(
Guid sendUserId, Guid sendUserId,
long groupId, long groupId,
string filter = "",
MessageType? type = null, MessageType? type = null,
string filter = "",
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var groupMessagesCount = await (await GetDbContextAsync()).Set<GroupMessage>() var groupMessagesCount = await (await GetDbContextAsync()).Set<GroupMessage>()
@ -110,8 +110,8 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task<long> GetCountAsync( public virtual async Task<long> GetCountAsync(
long groupId, long groupId,
string filter = "",
MessageType? type = null, MessageType? type = null,
string filter = "",
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetDbContextAsync()).Set<GroupMessage>() return await (await GetDbContextAsync()).Set<GroupMessage>()
@ -124,8 +124,8 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task<long> GetCountAsync( public virtual async Task<long> GetCountAsync(
Guid sendUserId, Guid sendUserId,
Guid receiveUserId, Guid receiveUserId,
string filter = "",
MessageType? type = null, MessageType? type = null,
string filter = "",
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetDbContextAsync()).Set<UserMessage>() return await (await GetDbContextAsync()).Set<UserMessage>()
@ -146,15 +146,17 @@ namespace LINGYUN.Abp.MessageService.Chat
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); .FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<LastChatMessage>> GetLastMessagesByOneFriendAsync( public virtual async Task<List<LastChatMessage>> GetLastMessagesAsync(
Guid userId, Guid userId,
MessageState? state = null,
string sorting = nameof(LastChatMessage.SendTime), string sorting = nameof(LastChatMessage.SendTime),
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var dbContext = await GetDbContextAsync(); var dbContext = await GetDbContextAsync();
var groupMsgQuery = dbContext.Set<UserMessage>() var groupMsgQuery = dbContext.Set<UserMessage>()
.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 }) .GroupBy(msg => new { msg.CreatorId, msg.ReceiveUserId })
.Select(msg => new .Select(msg => new
{ {
@ -187,9 +189,9 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task<List<UserMessage>> GetUserMessagesAsync( public virtual async Task<List<UserMessage>> GetUserMessagesAsync(
Guid sendUserId, Guid sendUserId,
Guid receiveUserId, Guid receiveUserId,
MessageType? type = null,
string filter = "", string filter = "",
string sorting = nameof(UserMessage.MessageId), string sorting = nameof(UserMessage.MessageId),
MessageType? type = null,
int skipCount = 0, int skipCount = 0,
int maxResultCount = 10, int maxResultCount = 10,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
@ -210,8 +212,8 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual async Task<long> GetUserMessagesCountAsync( public virtual async Task<long> GetUserMessagesCountAsync(
Guid sendUserId, Guid sendUserId,
Guid receiveUserId, Guid receiveUserId,
string filter = "",
MessageType? type = null, MessageType? type = null,
string filter = "",
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var userMessagesCount = await (await GetDbContextAsync()).Set<UserMessage>() var userMessagesCount = await (await GetDbContextAsync()).Set<UserMessage>()

11
aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatCardRepository.cs

@ -20,6 +20,15 @@ namespace LINGYUN.Abp.MessageService.Chat
{ {
} }
public virtual async Task<UserChatCard> FindByUserIdAsync(
Guid userId,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.Where(ucc => ucc.UserId == userId)
.FirstAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<bool> CheckUserIdExistsAsync(Guid userId, CancellationToken cancellationToken = default) public virtual async Task<bool> CheckUserIdExistsAsync(Guid userId, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
@ -46,7 +55,7 @@ namespace LINGYUN.Abp.MessageService.Chat
.WhereIf(!findUserName.IsNullOrWhiteSpace(), ucc => ucc.UserName.Contains(findUserName)) .WhereIf(!findUserName.IsNullOrWhiteSpace(), ucc => ucc.UserName.Contains(findUserName))
.WhereIf(startAge.HasValue, ucc => ucc.Age >= startAge.Value) .WhereIf(startAge.HasValue, ucc => ucc.Age >= startAge.Value)
.WhereIf(endAge.HasValue, ucc => ucc.Age <= endAge.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)); .CountAsync(GetCancellationToken(cancellationToken));
} }

15
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 LINGYUN.Abp.MessageService.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System; using System;
@ -54,7 +55,8 @@ namespace LINGYUN.Abp.MessageService.Chat
SpecialFocus = ucf.SpecialFocus, SpecialFocus = ucf.SpecialFocus,
TenantId = ucf.TenantId, TenantId = ucf.TenantId,
UserId = ucf.UserId, UserId = ucf.UserId,
UserName = ucc.UserName UserName = ucc.UserName,
Online = ucc.State == UserOnlineState.Online,
}; };
return await userFriendQuery return await userFriendQuery
@ -85,7 +87,8 @@ namespace LINGYUN.Abp.MessageService.Chat
SpecialFocus = ucf.SpecialFocus, SpecialFocus = ucf.SpecialFocus,
TenantId = ucf.TenantId, TenantId = ucf.TenantId,
UserId = ucf.UserId, UserId = ucf.UserId,
UserName = ucc.UserName UserName = ucc.UserName,
Online = ucc.State == UserOnlineState.Online,
}; };
return await userFriendQuery return await userFriendQuery
@ -131,7 +134,8 @@ namespace LINGYUN.Abp.MessageService.Chat
SpecialFocus = ucf.SpecialFocus, SpecialFocus = ucf.SpecialFocus,
TenantId = ucf.TenantId, TenantId = ucf.TenantId,
UserId = ucf.UserId, UserId = ucf.UserId,
UserName = ucc.UserName UserName = ucc.UserName,
Online = ucc.State == UserOnlineState.Online,
}; };
return await userFriendQuery return await userFriendQuery
@ -173,7 +177,8 @@ namespace LINGYUN.Abp.MessageService.Chat
SpecialFocus = ucf.SpecialFocus, SpecialFocus = ucf.SpecialFocus,
TenantId = ucf.TenantId, TenantId = ucf.TenantId,
UserId = ucf.UserId, UserId = ucf.UserId,
UserName = ucc.UserName UserName = ucc.UserName,
Online = ucc.State == UserOnlineState.Online,
}; };
return await userFriendQuery return await userFriendQuery

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreModule.cs

@ -1,5 +1,5 @@
using LINGYUN.Abp.MessageService.Chat; using LINGYUN.Abp.MessageService.Chat;
using LINGYUN.Abp.MessageService.Group; using LINGYUN.Abp.MessageService.Groups;
using LINGYUN.Abp.MessageService.Notifications; using LINGYUN.Abp.MessageService.Notifications;
using LINGYUN.Abp.MessageService.Subscriptions; using LINGYUN.Abp.MessageService.Subscriptions;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/IMessageServiceDbContext.cs

@ -1,5 +1,5 @@
using LINGYUN.Abp.MessageService.Chat; using LINGYUN.Abp.MessageService.Chat;
using LINGYUN.Abp.MessageService.Group; using LINGYUN.Abp.MessageService.Groups;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data; using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContext.cs

@ -1,5 +1,5 @@
using LINGYUN.Abp.MessageService.Chat; using LINGYUN.Abp.MessageService.Chat;
using LINGYUN.Abp.MessageService.Group; using LINGYUN.Abp.MessageService.Groups;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data; using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;

9
aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs

@ -1,5 +1,5 @@
using LINGYUN.Abp.MessageService.Chat; using LINGYUN.Abp.MessageService.Chat;
using LINGYUN.Abp.MessageService.Group; using LINGYUN.Abp.MessageService.Groups;
using LINGYUN.Abp.MessageService.Notifications; using LINGYUN.Abp.MessageService.Notifications;
using LINGYUN.Abp.MessageService.Subscriptions; using LINGYUN.Abp.MessageService.Subscriptions;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -41,7 +41,7 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore
b.ConfigureByConvention(); b.ConfigureByConvention();
b.HasIndex(p => new { p.TenantId, p.UserId, p.NotificationId }) b.HasIndex(p => new { p.TenantId, p.UserId, p.NotificationId })
.HasName("IX_Tenant_User_Notification_Id"); .HasDatabaseName("IX_Tenant_User_Notification_Id");
}); });
builder.Entity<UserSubscribe>(b => builder.Entity<UserSubscribe>(b =>
@ -57,8 +57,8 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore
b.ConfigureByConvention(); b.ConfigureByConvention();
b.HasIndex(p => new { p.TenantId, p.UserId, p.NotificationName }) b.HasIndex(p => new { p.TenantId, p.UserId, p.NotificationName })
.HasName("IX_Tenant_User_Notification_Name") .HasDatabaseName("IX_Tenant_User_Notification_Name")
.IsUnique(); .IsUnique();
}); });
builder.Entity<UserMessage>(b => builder.Entity<UserMessage>(b =>
@ -171,6 +171,7 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore
b.Property(p => p.Notice).HasMaxLength(ChatGroupConsts.MaxNoticeLength); b.Property(p => p.Notice).HasMaxLength(ChatGroupConsts.MaxNoticeLength);
b.Property(p => p.Address).HasMaxLength(ChatGroupConsts.MaxAddressLength); b.Property(p => p.Address).HasMaxLength(ChatGroupConsts.MaxAddressLength);
b.Property(p => p.Description).HasMaxLength(ChatGroupConsts.MaxDescriptionLength); b.Property(p => p.Description).HasMaxLength(ChatGroupConsts.MaxDescriptionLength);
b.Property(p => p.AvatarUrl).HasMaxLength(ChatGroupConsts.MaxAvatarUrlLength);
b.ConfigureByConvention(); b.ConfigureByConvention();

28
aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Group/EfCoreGroupRepository.cs → aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Groups/EfCoreGroupRepository.cs

@ -3,13 +3,14 @@ using Microsoft.EntityFrameworkCore;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Abp.MessageService.Group namespace LINGYUN.Abp.MessageService.Groups
{ {
public class EfCoreGroupRepository : EfCoreRepository<IMessageServiceDbContext, ChatGroup, long>, public class EfCoreGroupRepository : EfCoreRepository<IMessageServiceDbContext, ChatGroup, long>,
IGroupRepository, ITransientDependency IGroupRepository, ITransientDependency
@ -20,6 +21,31 @@ namespace LINGYUN.Abp.MessageService.Group
{ {
} }
public virtual async Task<int> 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<List<ChatGroup>> GetListAsync(
string filter = null,
string sorting = nameof(ChatGroup.Name),
int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.WhereIf(!filter.IsNullOrWhiteSpace(), x =>
x.Name.Contains(filter) || x.Tag.Contains(filter))
.OrderBy(sorting ?? nameof(ChatGroup.Name))
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<ChatGroup> FindByIdAsync( public virtual async Task<ChatGroup> FindByIdAsync(
long id, long id,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)

103
aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Group/EfCoreUserChatGroupRepository.cs → aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Groups/EfCoreUserChatGroupRepository.cs

@ -1,8 +1,7 @@
using LINGYUN.Abp.IM.Group; using LINGYUN.Abp.IM.Groups;
using LINGYUN.Abp.MessageService.Chat; using LINGYUN.Abp.MessageService.Chat;
using LINGYUN.Abp.MessageService.EntityFrameworkCore; using LINGYUN.Abp.MessageService.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Internal;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -13,7 +12,7 @@ using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Abp.MessageService.Group namespace LINGYUN.Abp.MessageService.Groups
{ {
public class EfCoreUserChatGroupRepository : EfCoreRepository<IMessageServiceDbContext, UserChatGroup, long>, public class EfCoreUserChatGroupRepository : EfCoreRepository<IMessageServiceDbContext, UserChatGroup, long>,
IUserChatGroupRepository, ITransientDependency IUserChatGroupRepository, ITransientDependency
@ -30,29 +29,29 @@ namespace LINGYUN.Abp.MessageService.Group
{ {
var dbContext = await GetDbContextAsync(); var dbContext = await GetDbContextAsync();
var cardQuery = from gp in dbContext.Set<ChatGroup>() var cardQuery = from gp in dbContext.Set<ChatGroup>()
join ucg in dbContext.Set<UserChatGroup>() join ucg in dbContext.Set<UserChatGroup>()
on gp.GroupId equals ucg.GroupId on gp.GroupId equals ucg.GroupId
join ugc in dbContext.Set<UserGroupCard>() join ugc in dbContext.Set<UserGroupCard>()
on ucg.UserId equals ugc.UserId on ucg.UserId equals ugc.UserId
join uc in dbContext.Set<UserChatCard>() join uc in dbContext.Set<UserChatCard>()
on ugc.UserId equals uc.UserId on ugc.UserId equals uc.UserId
where gp.GroupId == groupId && ugc.UserId == userId where gp.GroupId == groupId && ugc.UserId == userId
select new GroupUserCard select new GroupUserCard
{ {
TenantId = uc.TenantId, TenantId = uc.TenantId,
UserId = uc.UserId, UserId = uc.UserId,
UserName = uc.UserName, UserName = uc.UserName,
Age = uc.Age, Age = uc.Age,
AvatarUrl = uc.AvatarUrl, AvatarUrl = uc.AvatarUrl,
IsAdmin = ugc.IsAdmin, IsAdmin = ugc.IsAdmin,
IsSuperAdmin = gp.AdminUserId == uc.UserId, IsSuperAdmin = gp.AdminUserId == uc.UserId,
GroupId = gp.GroupId, GroupId = gp.GroupId,
Birthday = uc.Birthday, Birthday = uc.Birthday,
Description = uc.Description, Description = uc.Description,
NickName = ugc.NickName ?? uc.NickName, NickName = ugc.NickName ?? uc.NickName,
Sex = uc.Sex, Sex = uc.Sex,
Sign = uc.Sign Sign = uc.Sign
}; };
return await cardQuery return await cardQuery
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); .FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
@ -67,29 +66,29 @@ namespace LINGYUN.Abp.MessageService.Group
{ {
var dbContext = await GetDbContextAsync(); var dbContext = await GetDbContextAsync();
var cardQuery = from gp in dbContext.Set<ChatGroup>() var cardQuery = from gp in dbContext.Set<ChatGroup>()
join ucg in dbContext.Set<UserChatGroup>() join ucg in dbContext.Set<UserChatGroup>()
on gp.GroupId equals ucg.GroupId on gp.GroupId equals ucg.GroupId
join ugc in dbContext.Set<UserGroupCard>() join ugc in dbContext.Set<UserGroupCard>()
on ucg.UserId equals ugc.UserId on ucg.UserId equals ugc.UserId
join uc in dbContext.Set<UserChatCard>() join uc in dbContext.Set<UserChatCard>()
on ugc.UserId equals uc.UserId on ugc.UserId equals uc.UserId
where gp.GroupId == groupId where gp.GroupId == groupId
select new GroupUserCard select new GroupUserCard
{ {
TenantId = uc.TenantId, TenantId = uc.TenantId,
UserId = uc.UserId, UserId = uc.UserId,
UserName = uc.UserName, UserName = uc.UserName,
Age = uc.Age, Age = uc.Age,
AvatarUrl = uc.AvatarUrl, AvatarUrl = uc.AvatarUrl,
IsAdmin = ugc.IsAdmin, IsAdmin = ugc.IsAdmin,
IsSuperAdmin = gp.AdminUserId == uc.UserId, IsSuperAdmin = gp.AdminUserId == uc.UserId,
GroupId = gp.GroupId, GroupId = gp.GroupId,
Birthday = uc.Birthday, Birthday = uc.Birthday,
Description = uc.Description, Description = uc.Description,
NickName = ugc.NickName ?? uc.NickName, NickName = ugc.NickName ?? uc.NickName,
Sex = uc.Sex, Sex = uc.Sex,
Sign = uc.Sign Sign = uc.Sign
}; };
return await cardQuery return await cardQuery
.OrderBy(sorting ?? nameof(UserChatCard.UserId)) .OrderBy(sorting ?? nameof(UserChatCard.UserId))
@ -126,7 +125,7 @@ namespace LINGYUN.Abp.MessageService.Group
GetCancellationToken(cancellationToken)); GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<IM.Group.Group>> GetMemberGroupsAsync( public virtual async Task<List<Group>> GetMemberGroupsAsync(
Guid userId, Guid userId,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
@ -137,6 +136,7 @@ namespace LINGYUN.Abp.MessageService.Group
where ucg.UserId.Equals(userId) where ucg.UserId.Equals(userId)
group ucg by new group ucg by new
{ {
gp.AvatarUrl,
gp.AllowAnonymous, gp.AllowAnonymous,
gp.AllowSendMessage, gp.AllowSendMessage,
gp.MaxUserCount, gp.MaxUserCount,
@ -144,8 +144,9 @@ namespace LINGYUN.Abp.MessageService.Group
gp.GroupId, gp.GroupId,
} }
into cg into cg
select new IM.Group.Group select new Group
{ {
AvatarUrl = cg.Key.AvatarUrl,
AllowAnonymous = cg.Key.AllowAnonymous, AllowAnonymous = cg.Key.AllowAnonymous,
AllowSendMessage = cg.Key.AllowSendMessage, AllowSendMessage = cg.Key.AllowSendMessage,
MaxUserLength = cg.Key.MaxUserCount, MaxUserLength = cg.Key.MaxUserCount,

11
aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/AbpMessageServiceHttpApiModule.cs

@ -1,5 +1,7 @@
using Microsoft.Extensions.DependencyInjection; using LINGYUN.Abp.MessageService.Localization;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
namespace LINGYUN.Abp.MessageService namespace LINGYUN.Abp.MessageService
@ -16,6 +18,13 @@ namespace LINGYUN.Abp.MessageService
{ {
mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpMessageServiceHttpApiModule).Assembly); mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpMessageServiceHttpApiModule).Assembly);
}); });
PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
{
options.AddAssemblyResource(
typeof(MessageServiceResource), // 用于本地化的资源
typeof(AbpMessageServiceApplicationContractsModule).Assembly); // Dto所在程序集
});
} }
} }
} }

8
aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Chat/MyFriendController.cs

@ -1,5 +1,6 @@
using LINGYUN.Abp.IM.Contract; using LINGYUN.Abp.IM.Contract;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
@ -37,6 +38,13 @@ namespace LINGYUN.Abp.MessageService.Chat
await MyFriendAppService.DeleteAsync(input); await MyFriendAppService.DeleteAsync(input);
} }
[HttpGet]
[Route("{friendId}")]
public virtual async Task<UserFriend> GetAsync(Guid friendId)
{
return await MyFriendAppService.GetAsync(friendId);
}
[HttpGet] [HttpGet]
[Route("all")] [Route("all")]
public virtual async Task<ListResultDto<UserFriend>> GetAllListAsync(GetMyFriendsDto input) public virtual async Task<ListResultDto<UserFriend>> GetAllListAsync(GetMyFriendsDto input)

35
aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Groups/GroupController.cs

@ -0,0 +1,35 @@
using LINGYUN.Abp.IM.Groups;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Mvc;
namespace LINGYUN.Abp.MessageService.Groups
{
[RemoteService(Name = AbpMessageServiceConsts.RemoteServiceName)]
[Route("api/im/groups")]
public class GroupController : AbpController, IGroupAppService
{
private readonly IGroupAppService _service;
public GroupController(IGroupAppService service)
{
_service = service;
}
[HttpGet]
[Route("{groupId}")]
public virtual async Task<Group> GetAsync(string groupId)
{
return await _service.GetAsync(groupId);
}
[HttpGet]
[Route("search")]
public virtual async Task<PagedResultDto<Group>> SearchAsync(GroupSearchInput input)
{
return await _service.SearchAsync(input);
}
}
}

55
aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Groups/UserGroupController.cs

@ -0,0 +1,55 @@
using LINGYUN.Abp.IM.Groups;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Mvc;
namespace LINGYUN.Abp.MessageService.Groups
{
[RemoteService(Name = AbpMessageServiceConsts.RemoteServiceName)]
[Route("api/im/user-groups")]
public class UserGroupController : AbpController, IUserGroupAppService
{
private readonly IUserGroupAppService _service;
public UserGroupController(IUserGroupAppService service)
{
_service = service;
}
[HttpPost]
[Route("join")]
public virtual async Task ApplyJoinGroupAsync(UserJoinGroupDto input)
{
await _service.ApplyJoinGroupAsync(input);
}
[HttpGet]
public virtual async Task<PagedResultDto<GroupUserCard>> GetGroupUsersAsync(GroupUserGetByPagedDto input)
{
return await _service.GetGroupUsersAsync(input);
}
[HttpGet]
[Route("me")]
public virtual async Task<ListResultDto<Group>> GetMyGroupsAsync()
{
return await _service.GetMyGroupsAsync();
}
[HttpPut]
[Route("accept")]
public virtual async Task GroupAcceptUserAsync(GroupAcceptUserDto input)
{
await _service.GroupAcceptUserAsync(input);
}
[HttpPut]
[Route("remove")]
public virtual async Task GroupRemoveUserAsync(GroupRemoveUserDto input)
{
await _service.GroupRemoveUserAsync(input);
}
}
}

622
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211110144233_Add-Field-Online-Avatar.Designer.cs

@ -0,0 +1,622 @@
// <auto-generated />
using System;
using LINGYUN.Abp.MessageService.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Abp.MessageService.Migrations
{
[DbContext(typeof(MessageServiceHostMigrationsDbContext))]
[Migration("20211110144233_Add-Field-Online-Avatar")]
partial class AddFieldOnlineAvatar
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql)
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.12");
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatCard", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<int>("Age")
.HasColumnType("int");
b.Property<string>("AvatarUrl")
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<DateTime?>("Birthday")
.HasColumnType("datetime(6)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<DateTime?>("LastOnlineTime")
.HasColumnType("datetime(6)");
b.Property<string>("NickName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<int>("Sex")
.HasColumnType("int");
b.Property<string>("Sign")
.HasMaxLength(30)
.HasColumnType("varchar(30)");
b.Property<int>("State")
.HasColumnType("int");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.Property<string>("UserName")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserChatCards");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatFriend", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<bool>("Black")
.HasColumnType("tinyint(1)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<bool>("DontDisturb")
.HasColumnType("tinyint(1)");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<Guid>("FrientId")
.HasColumnType("char(36)");
b.Property<string>("RemarkName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<bool>("SpecialFocus")
.HasColumnType("tinyint(1)");
b.Property<byte>("Status")
.HasColumnType("tinyint unsigned");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "FrientId");
b.ToTable("AppUserChatFriends");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatSetting", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<bool>("AllowAddFriend")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowAnonymous")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowReceiveMessage")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowSendMessage")
.HasColumnType("tinyint(1)");
b.Property<bool>("RequireAddFriendValition")
.HasColumnType("tinyint(1)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserChatSettings");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserMessage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Content")
.IsRequired()
.HasMaxLength(1048576)
.HasColumnType("longtext");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<long>("MessageId")
.HasColumnType("bigint");
b.Property<Guid>("ReceiveUserId")
.HasColumnType("char(36)");
b.Property<sbyte>("SendState")
.HasColumnType("tinyint");
b.Property<string>("SendUserName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "ReceiveUserId");
b.ToTable("AppUserMessages");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.ChatGroup", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("Address")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<Guid>("AdminUserId")
.HasColumnType("char(36)");
b.Property<bool>("AllowAnonymous")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowSendMessage")
.HasColumnType("tinyint(1)");
b.Property<string>("AvatarUrl")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<int>("MaxUserCount")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("varchar(20)");
b.Property<string>("Notice")
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<string>("Tag")
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.HasIndex("TenantId", "Name");
b.ToTable("AppChatGroups");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupChatBlack", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<Guid>("ShieldUserId")
.HasColumnType("char(36)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId");
b.ToTable("AppGroupChatBlacks");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupMessage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Content")
.IsRequired()
.HasMaxLength(1048576)
.HasColumnType("longtext");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<long>("MessageId")
.HasColumnType("bigint");
b.Property<sbyte>("SendState")
.HasColumnType("tinyint");
b.Property<string>("SendUserName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId");
b.ToTable("AppGroupMessages");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserChatGroup", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId", "UserId");
b.ToTable("AppUserChatGroups");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserGroupCard", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<bool>("IsAdmin")
.HasColumnType("tinyint(1)");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<string>("NickName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<DateTime?>("SilenceEnd")
.HasColumnType("datetime(6)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserGroupCards");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.Notification", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<DateTime?>("ExpirationTime")
.HasColumnType("datetime(6)");
b.Property<string>("NotificationData")
.IsRequired()
.HasMaxLength(1048576)
.HasColumnType("longtext");
b.Property<long>("NotificationId")
.HasColumnType("bigint");
b.Property<string>("NotificationName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("NotificationTypeName")
.IsRequired()
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<sbyte>("Severity")
.HasColumnType("tinyint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "NotificationName");
b.ToTable("AppNotifications");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.UserNotification", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<long>("NotificationId")
.HasColumnType("bigint");
b.Property<int>("ReadStatus")
.HasColumnType("int");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "NotificationId")
.HasDatabaseName("IX_Tenant_User_Notification_Id");
b.ToTable("AppUserNotifications");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Subscriptions.UserSubscribe", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<string>("NotificationName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.Property<string>("UserName")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(128)
.HasColumnType("varchar(128)")
.HasDefaultValue("/");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "NotificationName")
.IsUnique()
.HasDatabaseName("IX_Tenant_User_Notification_Name");
b.ToTable("AppUserSubscribes");
});
#pragma warning restore 612, 618
}
}
}

47
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211110144233_Add-Field-Online-Avatar.cs

@ -0,0 +1,47 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace LINGYUN.Abp.MessageService.Migrations
{
public partial class AddFieldOnlineAvatar : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "LastOnlineTime",
table: "AppUserChatCards",
type: "datetime(6)",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "State",
table: "AppUserChatCards",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<string>(
name: "AvatarUrl",
table: "AppChatGroups",
type: "varchar(128)",
maxLength: 128,
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "LastOnlineTime",
table: "AppUserChatCards");
migrationBuilder.DropColumn(
name: "State",
table: "AppUserChatCards");
migrationBuilder.DropColumn(
name: "AvatarUrl",
table: "AppChatGroups");
}
}
}

22
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/MessageServiceHostMigrationsDbContextModelSnapshot.cs

@ -17,7 +17,7 @@ namespace LINGYUN.Abp.MessageService.Migrations
modelBuilder modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql)
.HasAnnotation("Relational:MaxIdentifierLength", 64) .HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.11"); .HasAnnotation("ProductVersion", "5.0.12");
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatCard", b => modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatCard", b =>
{ {
@ -65,6 +65,9 @@ namespace LINGYUN.Abp.MessageService.Migrations
.HasColumnType("char(36)") .HasColumnType("char(36)")
.HasColumnName("LastModifierId"); .HasColumnName("LastModifierId");
b.Property<DateTime?>("LastOnlineTime")
.HasColumnType("datetime(6)");
b.Property<string>("NickName") b.Property<string>("NickName")
.HasMaxLength(256) .HasMaxLength(256)
.HasColumnType("varchar(256)"); .HasColumnType("varchar(256)");
@ -76,6 +79,9 @@ namespace LINGYUN.Abp.MessageService.Migrations
.HasMaxLength(30) .HasMaxLength(30)
.HasColumnType("varchar(30)"); .HasColumnType("varchar(30)");
b.Property<int>("State")
.HasColumnType("int");
b.Property<Guid?>("TenantId") b.Property<Guid?>("TenantId")
.HasColumnType("char(36)") .HasColumnType("char(36)")
.HasColumnName("TenantId"); .HasColumnName("TenantId");
@ -248,7 +254,7 @@ namespace LINGYUN.Abp.MessageService.Migrations
b.ToTable("AppUserMessages"); b.ToTable("AppUserMessages");
}); });
modelBuilder.Entity("LINGYUN.Abp.MessageService.Group.ChatGroup", b => modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.ChatGroup", b =>
{ {
b.Property<long>("Id") b.Property<long>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -267,6 +273,10 @@ namespace LINGYUN.Abp.MessageService.Migrations
b.Property<bool>("AllowSendMessage") b.Property<bool>("AllowSendMessage")
.HasColumnType("tinyint(1)"); .HasColumnType("tinyint(1)");
b.Property<string>("AvatarUrl")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<DateTime>("CreationTime") b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)") .HasColumnType("datetime(6)")
.HasColumnName("CreationTime"); .HasColumnName("CreationTime");
@ -317,7 +327,7 @@ namespace LINGYUN.Abp.MessageService.Migrations
b.ToTable("AppChatGroups"); b.ToTable("AppChatGroups");
}); });
modelBuilder.Entity("LINGYUN.Abp.MessageService.Group.GroupChatBlack", b => modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupChatBlack", b =>
{ {
b.Property<long>("Id") b.Property<long>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -348,7 +358,7 @@ namespace LINGYUN.Abp.MessageService.Migrations
b.ToTable("AppGroupChatBlacks"); b.ToTable("AppGroupChatBlacks");
}); });
modelBuilder.Entity("LINGYUN.Abp.MessageService.Group.GroupMessage", b => modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupMessage", b =>
{ {
b.Property<long>("Id") b.Property<long>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -405,7 +415,7 @@ namespace LINGYUN.Abp.MessageService.Migrations
b.ToTable("AppGroupMessages"); b.ToTable("AppGroupMessages");
}); });
modelBuilder.Entity("LINGYUN.Abp.MessageService.Group.UserChatGroup", b => modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserChatGroup", b =>
{ {
b.Property<long>("Id") b.Property<long>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@ -436,7 +446,7 @@ namespace LINGYUN.Abp.MessageService.Migrations
b.ToTable("AppUserChatGroups"); b.ToTable("AppUserChatGroups");
}); });
modelBuilder.Entity("LINGYUN.Abp.MessageService.Group.UserGroupCard", b => modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserGroupCard", b =>
{ {
b.Property<long>("Id") b.Property<long>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()

16
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/appsettings.Development.json

@ -23,13 +23,13 @@
} }
}, },
"ConnectionStrings": { "ConnectionStrings": {
"Default": "Server=localhost;Database=Messages;User Id=colin;Password=123456", "Default": "Server=localhost;Database=Messages;User Id=root;Password=123456",
"MessageService": "Server=localhost;Database=Messages;User Id=colin;Password=123456", "MessageService": "Server=localhost;Database=Messages;User Id=root;Password=123456",
"AbpIdentity": "Server=localhost;Database=Messages;User Id=colin;Password=123456", "AbpIdentity": "Server=localhost;Database=Messages;User Id=root;Password=123456",
"AbpTenantManagement": "Server=localhost;Database=Platform;User Id=colin;Password=123456", "AbpTenantManagement": "Server=localhost;Database=Platform;User Id=root;Password=123456",
"AbpSettingManagement": "Server=localhost;Database=Platform;User Id=colin;Password=123456", "AbpSettingManagement": "Server=localhost;Database=Platform;User Id=root;Password=123456",
"AbpPermissionManagement": "Server=localhost;Database=Platform;User Id=colin;Password=123456", "AbpPermissionManagement": "Server=localhost;Database=Platform;User Id=root;Password=123456",
"AbpLocalizationManagement": "Server=localhost;Database=Platform;User Id=colin;Password=123456" "AbpLocalizationManagement": "Server=localhost;Database=Platform;User Id=root;Password=123456"
}, },
"Redis": { "Redis": {
"Configuration": "localhost,defaultDatabase=8", "Configuration": "localhost,defaultDatabase=8",
@ -41,7 +41,7 @@
}, },
"Hangfire": { "Hangfire": {
"MySql": { "MySql": {
"Connection": "Server=localhost;Database=Messages;User Id=colin;Password=123456;Allow User Variables=true", "Connection": "Server=localhost;Database=Messages;User Id=root;Password=123456;Allow User Variables=true",
"TablePrefix": "AppHangfire" "TablePrefix": "AppHangfire"
}, },
"Dashboard": { "Dashboard": {

Loading…
Cancel
Save