82 changed files with 3989 additions and 531 deletions
@ -0,0 +1,14 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netcoreapp3.1</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.SignalR" Version="3.2.0" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,25 @@ |
|||
using System.Collections.Generic; |
|||
|
|||
namespace LINGYUN.Abp.AspNetCore.SignalR.JwtToken |
|||
{ |
|||
public class AbpAspNetCoreSignalRJwtTokenMapPathOptions |
|||
{ |
|||
public List<string> MapJwtTokenPaths { get; set; } |
|||
public AbpAspNetCoreSignalRJwtTokenMapPathOptions() |
|||
{ |
|||
MapJwtTokenPaths = new List<string>(); |
|||
} |
|||
|
|||
public void MapPath(string path) |
|||
{ |
|||
if (path.StartsWith("/signalr-hubs/")) |
|||
{ |
|||
MapJwtTokenPaths.AddIfNotContains(path); |
|||
} |
|||
else |
|||
{ |
|||
MapJwtTokenPaths.AddIfNotContains($"/signalr-hubs/{path}"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.AspNetCore.SignalR; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.AspNetCore.SignalR.JwtToken |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpAspNetCoreSignalRModule))] |
|||
public class AbpAspNetCoreSignalRJwtTokenModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
var configuration = context.Services.GetConfiguration(); |
|||
|
|||
Configure<AbpAspNetCoreSignalRJwtTokenMapPathOptions>(configuration.GetSection("SignalR:MapPath")); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
using LINGYUN.Abp.AspNetCore.SignalR.JwtToken; |
|||
using Microsoft.Extensions.Options; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Microsoft.AspNetCore.Http |
|||
{ |
|||
public class SignalRJwtTokenMiddleware : IMiddleware, ITransientDependency |
|||
{ |
|||
protected AbpAspNetCoreSignalRJwtTokenMapPathOptions Options { get; } |
|||
|
|||
public SignalRJwtTokenMiddleware(IOptions<AbpAspNetCoreSignalRJwtTokenMapPathOptions> options) |
|||
{ |
|||
Options = options.Value; |
|||
} |
|||
|
|||
public async Task InvokeAsync(HttpContext context, RequestDelegate next) |
|||
{ |
|||
if (Options.MapJwtTokenPaths.Any(path => context.Request.Path.StartsWithSegments(path))) |
|||
{ |
|||
if (context.User.Identity?.IsAuthenticated != true) |
|||
{ |
|||
if (context.Request.Query.TryGetValue("access_token", out var accessToken)) |
|||
{ |
|||
context.Request.Headers.Add("Authorization", $"Bearer {accessToken}"); |
|||
} |
|||
|
|||
} |
|||
} |
|||
//if (context.Request.Path.StartsWithSegments("/signalr-hubs/"))
|
|||
//{
|
|||
// if (context.User.Identity?.IsAuthenticated != true)
|
|||
// {
|
|||
// if (context.Request.Query.TryGetValue("access_token", out var accessToken))
|
|||
// {
|
|||
// context.Request.Headers.Add("Authorization", $"Bearer {accessToken}");
|
|||
// }
|
|||
|
|||
// }
|
|||
//}
|
|||
await next(context); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,110 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.IM.Contract |
|||
{ |
|||
public interface IFriendStore |
|||
{ |
|||
/// <summary>
|
|||
/// 获取好友数量
|
|||
/// </summary>
|
|||
/// <param name="tenantId"></param>
|
|||
/// <param name="userId"></param>
|
|||
/// <param name="filter"></param>
|
|||
/// <returns></returns>
|
|||
Task<int> GetCountAsync( |
|||
Guid? tenantId, |
|||
Guid userId, |
|||
string filter = ""); |
|||
/// <summary>
|
|||
/// 获取好友列表
|
|||
/// </summary>
|
|||
/// <param name="tenantId"></param>
|
|||
/// <param name="userId"></param>
|
|||
/// <param name="filter"></param>
|
|||
/// <param name="sorting"></param>
|
|||
/// <param name="reverse"></param>
|
|||
/// <param name="skipCount"></param>
|
|||
/// <param name="maxResultCount"></param>
|
|||
/// <returns></returns>
|
|||
Task<List<UserFriend>> GetListAsync( |
|||
Guid? tenantId, |
|||
Guid userId, |
|||
string filter = "", |
|||
string sorting = nameof(UserFriend.UserId), |
|||
bool reverse = false, |
|||
int skipCount = 0, |
|||
int maxResultCount = 10); |
|||
/// <summary>
|
|||
/// 获取最近联系好友列表
|
|||
/// </summary>
|
|||
/// <param name="tenantId"></param>
|
|||
/// <param name="userId"></param>
|
|||
/// <param name="skipCount"></param>
|
|||
/// <param name="maxResultCount"></param>
|
|||
/// <returns></returns>
|
|||
Task<List<UserFriend>> GetLastContactListAsync( |
|||
Guid? tenantId, |
|||
Guid userId, |
|||
int skipCount = 0, |
|||
int maxResultCount = 10); |
|||
/// <summary>
|
|||
/// 获取好友信息
|
|||
/// </summary>
|
|||
/// <param name="tenantId"></param>
|
|||
/// <param name="userId"></param>
|
|||
/// <param name="friendId"></param>
|
|||
/// <returns></returns>
|
|||
Task<UserFriend> GetMemberAsync( |
|||
Guid? tenantId, |
|||
Guid userId, |
|||
Guid friendId); |
|||
/// <summary>
|
|||
/// 添加好友
|
|||
/// </summary>
|
|||
/// <param name="tenantId"></param>
|
|||
/// <param name="userId"></param>
|
|||
/// <param name="friendId"></param>
|
|||
/// <param name="remarkName"></param>
|
|||
/// <returns></returns>
|
|||
Task AddMemberAsync( |
|||
Guid? tenantId, |
|||
Guid userId, |
|||
Guid friendId, |
|||
string remarkName = ""); |
|||
/// <summary>
|
|||
/// 移除好友
|
|||
/// </summary>
|
|||
/// <param name="tenantId"></param>
|
|||
/// <param name="userId"></param>
|
|||
/// <param name="friendId"></param>
|
|||
/// <returns></returns>
|
|||
Task RemoveMemberAsync( |
|||
Guid? tenantId, |
|||
Guid userId, |
|||
Guid friendId); |
|||
/// <summary>
|
|||
/// 添加黑名单
|
|||
/// </summary>
|
|||
/// <param name="tenantId"></param>
|
|||
/// <param name="userId"></param>
|
|||
/// <param name="friendId"></param>
|
|||
/// <returns></returns>
|
|||
Task AddShieldMemberAsync( |
|||
Guid? tenantId, |
|||
Guid userId, |
|||
Guid friendId); |
|||
/// <summary>
|
|||
/// 移除黑名单
|
|||
/// </summary>
|
|||
/// <param name="tenantId"></param>
|
|||
/// <param name="userId"></param>
|
|||
/// <param name="friendId"></param>
|
|||
/// <returns></returns>
|
|||
Task RemoveShieldMemberAsync( |
|||
Guid? tenantId, |
|||
Guid userId, |
|||
Guid friendId); |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
using System; |
|||
|
|||
namespace LINGYUN.Abp.IM.Contract |
|||
{ |
|||
public class UserFriend : UserCard |
|||
{ |
|||
/// <summary>
|
|||
/// 好友标识
|
|||
/// </summary>
|
|||
public Guid FriendId { get; set; } |
|||
/// <summary>
|
|||
/// 已添加黑名单
|
|||
/// </summary>
|
|||
public bool Black { get; set; } |
|||
/// <summary>
|
|||
/// 特别关注
|
|||
/// </summary>
|
|||
public bool SpecialFocus { get; set; } |
|||
/// <summary>
|
|||
/// 消息免打扰
|
|||
/// </summary>
|
|||
public bool DontDisturb { get; set; } |
|||
/// <summary>
|
|||
/// 备注名称
|
|||
/// </summary>
|
|||
public string RemarkName { get; set; } |
|||
} |
|||
} |
|||
@ -1,22 +1,12 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
|
|||
namespace LINGYUN.Abp.IM.Group |
|||
namespace LINGYUN.Abp.IM.Group |
|||
{ |
|||
public class GroupUserCard : UserCard |
|||
{ |
|||
public long GroupId { get; set; } |
|||
public bool IsAdmin { get; set; } |
|||
public bool IsSuperAdmin { get; set; } |
|||
public IDictionary<string, bool> Permissions { get; set; } |
|||
public GroupUserCard() |
|||
{ |
|||
Permissions = new Dictionary<string, bool>(); |
|||
} |
|||
|
|||
public bool IsGrant(string key) |
|||
{ |
|||
return Permissions.Any(x => x.Equals(key) && x.Value); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,60 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.IM |
|||
{ |
|||
/// <summary>
|
|||
/// IM用户资料查找接口
|
|||
/// </summary>
|
|||
public interface IUserCardFinder |
|||
{ |
|||
/// <summary>
|
|||
/// 查询IM用户数量
|
|||
/// </summary>
|
|||
/// <param name="tenantId"></param>
|
|||
/// <param name="findUserName">用户名称</param>
|
|||
/// <param name="startAge">起止年龄</param>
|
|||
/// <param name="endAge">起止年龄</param>
|
|||
/// <param name="sex">性别</param>
|
|||
/// <returns></returns>
|
|||
Task<int> GetCountAsync( |
|||
Guid? tenantId, |
|||
string findUserName = "", |
|||
int? startAge = null, |
|||
int? endAge = null, |
|||
Sex? sex = null); |
|||
/// <summary>
|
|||
/// 查询IM用户列表
|
|||
/// </summary>
|
|||
/// <param name="tenantId"></param>
|
|||
/// <param name="findUserName">用户名称</param>
|
|||
/// <param name="startAge">起止年龄</param>
|
|||
/// <param name="endAge">起止年龄</param>
|
|||
/// <param name="sex">性别</param>
|
|||
/// <param name="sorting">排序字段</param>
|
|||
/// <param name="reverse">是否倒序</param>
|
|||
/// <param name="skipCount">起始记录位置</param>
|
|||
/// <param name="maxResultCount">最大返回数量</param>
|
|||
/// <returns></returns>
|
|||
Task<List<UserCard>> GetListAsync( |
|||
Guid? tenantId, |
|||
string findUserName = "", |
|||
int? startAge = null, |
|||
int? endAge = null, |
|||
Sex? sex = null, |
|||
string sorting = nameof(UserCard.UserId), |
|||
bool reverse = false, |
|||
int skipCount = 0, |
|||
int maxResultCount = 10); |
|||
/// <summary>
|
|||
/// 获取IM用户信息
|
|||
/// </summary>
|
|||
/// <param name="tenantId"></param>
|
|||
/// <param name="findUserId"></param>
|
|||
/// <returns></returns>
|
|||
Task<UserCard> GetMemberAsync( |
|||
Guid? tenantId, |
|||
Guid findUserId); |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
namespace LINGYUN.Abp.IM |
|||
{ |
|||
public enum Sex |
|||
{ |
|||
Male, |
|||
Female, |
|||
Other |
|||
} |
|||
} |
|||
@ -1,25 +0,0 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Microsoft.AspNetCore.Http |
|||
{ |
|||
public class SignalRJwtTokenMiddleware : IMiddleware, ITransientDependency |
|||
{ |
|||
public async Task InvokeAsync(HttpContext context, RequestDelegate next) |
|||
{ |
|||
// 仅针对自定义的SignalR hub
|
|||
if (context.Request.Path.StartsWithSegments("/signalr-hubs/notifications")) |
|||
{ |
|||
if (context.User.Identity?.IsAuthenticated != true) |
|||
{ |
|||
if (context.Request.Query.TryGetValue("access_token", out var accessToken)) |
|||
{ |
|||
context.Request.Headers.Add("Authorization", $"Bearer {accessToken}"); |
|||
} |
|||
|
|||
} |
|||
} |
|||
await next(context); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
public class MyFriendCreateDto : MyFriendOperationDto |
|||
{ |
|||
public string RemarkName { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
public class MyFriendGetByPagedDto : PagedAndSortedResultRequestDto |
|||
{ |
|||
public string Filter { get; set; } |
|||
|
|||
public bool Reverse { get; set; } |
|||
} |
|||
|
|||
public class MyLastContractFriendGetByPagedDto : PagedResultRequestDto |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
public class MyFriendOperationDto |
|||
{ |
|||
[Required] |
|||
public Guid FriendId { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using LINGYUN.Abp.IM.Contract; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
public interface IMyFriendAppService : IApplicationService |
|||
{ |
|||
Task<PagedResultDto<UserFriend>> GetMyFriendsAsync(MyFriendGetByPagedDto input); |
|||
|
|||
Task<PagedResultDto<UserFriend>> GetLastContactFriendsAsync(PagedResultRequestDto input); |
|||
|
|||
Task CreateAsync(MyFriendCreateDto input); |
|||
|
|||
Task DeleteAsync(MyFriendOperationDto input); |
|||
} |
|||
} |
|||
@ -0,0 +1,53 @@ |
|||
using LINGYUN.Abp.IM.Contract; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
[Authorize] |
|||
public class MyFriendAppService : ApplicationService, IMyFriendAppService |
|||
{ |
|||
protected IFriendStore FriendStore { get; } |
|||
|
|||
public MyFriendAppService(IFriendStore friendStore) |
|||
{ |
|||
FriendStore = friendStore; |
|||
} |
|||
|
|||
public virtual async Task CreateAsync(MyFriendCreateDto input) |
|||
{ |
|||
await FriendStore.AddMemberAsync(CurrentTenant.Id, CurrentUser.GetId(), input.FriendId, input.RemarkName); |
|||
} |
|||
|
|||
public virtual async Task DeleteAsync(MyFriendOperationDto input) |
|||
{ |
|||
await FriendStore.RemoveMemberAsync(CurrentTenant.Id, CurrentUser.GetId(), input.FriendId); |
|||
} |
|||
|
|||
public virtual async Task<PagedResultDto<UserFriend>> GetLastContactFriendsAsync(PagedResultRequestDto input) |
|||
{ |
|||
var myFrientCount = await FriendStore.GetCountAsync(CurrentTenant.Id, CurrentUser.GetId()); |
|||
|
|||
var myFriends = await FriendStore |
|||
.GetLastContactListAsync(CurrentTenant.Id, CurrentUser.GetId(), |
|||
input.SkipCount, input.MaxResultCount); |
|||
|
|||
return new PagedResultDto<UserFriend>(myFrientCount, myFriends); |
|||
} |
|||
|
|||
public virtual async Task<PagedResultDto<UserFriend>> GetMyFriendsAsync(MyFriendGetByPagedDto input) |
|||
{ |
|||
var myFrientCount = await FriendStore.GetCountAsync(CurrentTenant.Id, CurrentUser.GetId()); |
|||
|
|||
var myFriends = await FriendStore |
|||
.GetListAsync(CurrentTenant.Id, CurrentUser.GetId(), |
|||
input.Filter, input.Sorting, input.Reverse, |
|||
input.SkipCount, input.MaxResultCount); |
|||
|
|||
return new PagedResultDto<UserFriend>(myFrientCount, myFriends); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
public class UserChatCardConsts |
|||
{ |
|||
public static int MaxUserNameLength { get; set; } = AbpUserConsts.MaxUserNameLength; |
|||
public static int MaxSignLength { get; set; } = 30; |
|||
public static int MaxNickNameLength { get; set; } = AbpUserConsts.MaxUserNameLength; |
|||
public static int MaxDescriptionLength { get; set; } = 50; |
|||
public static int MaxAvatarUrlLength { get; set; } = 512; |
|||
} |
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.Timing; |
|||
using Volo.Abp.Uow; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
public class ChatDataSeeder : IChatDataSeeder, ITransientDependency |
|||
{ |
|||
protected IClock Clock { get; } |
|||
protected ICurrentTenant CurrentTenant { get; } |
|||
protected IUserChatCardRepository UserChatCardRepository { get; } |
|||
protected IUserChatSettingRepository UserChatSettingRepository { get; } |
|||
public ChatDataSeeder( |
|||
IClock clock, |
|||
ICurrentTenant currentTenant, |
|||
IUserChatCardRepository userChatCardRepository, |
|||
IUserChatSettingRepository userChatSettingRepository) |
|||
{ |
|||
Clock = clock; |
|||
CurrentTenant = currentTenant; |
|||
UserChatCardRepository = userChatCardRepository; |
|||
UserChatSettingRepository = userChatSettingRepository; |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task SeedAsync(IUserData user) |
|||
{ |
|||
using (CurrentTenant.Change(user.TenantId)) |
|||
{ |
|||
var userHasOpendIm = await UserChatSettingRepository.UserHasOpendImAsync(user.Id); |
|||
if (!userHasOpendIm) |
|||
{ |
|||
var userChatSetting = new UserChatSetting(user.Id, user.TenantId); |
|||
|
|||
await UserChatSettingRepository.InsertAsync(userChatSetting); |
|||
|
|||
var userChatCard = new UserChatCard(user.Id, user.UserName, IM.Sex.Male, user.UserName, tenantId: user.TenantId) |
|||
{ |
|||
CreationTime = Clock.Now, |
|||
CreatorId = user.Id |
|||
}; |
|||
|
|||
await UserChatCardRepository.InsertAsync(userChatCard); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,69 +0,0 @@ |
|||
using System; |
|||
using Volo.Abp.Domain.Entities.Auditing; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
/// <summary>
|
|||
/// 群管理员
|
|||
/// </summary>
|
|||
public class ChatGroupAdmin : AuditedEntity<long>, IMultiTenant |
|||
{ |
|||
/// <summary>
|
|||
/// 租户
|
|||
/// </summary>
|
|||
public virtual Guid? TenantId { get; protected set; } |
|||
/// <summary>
|
|||
/// 群组标识
|
|||
/// </summary>
|
|||
public virtual long GroupId { get; protected set; } |
|||
/// <summary>
|
|||
/// 管理员用户
|
|||
/// </summary>
|
|||
public virtual Guid UserId { get; protected set; } |
|||
/// <summary>
|
|||
/// 是否群主
|
|||
/// </summary>
|
|||
public virtual bool IsSuperAdmin { get; protected set; } |
|||
/// <summary>
|
|||
/// 允许禁言
|
|||
/// </summary>
|
|||
public virtual bool AllowSilence { get; set; } |
|||
/// <summary>
|
|||
/// 允许踢人
|
|||
/// </summary>
|
|||
public virtual bool AllowKickPeople { get; set; } |
|||
/// <summary>
|
|||
/// 允许加人
|
|||
/// </summary>
|
|||
public virtual bool AllowAddPeople { get; set; } |
|||
/// <summary>
|
|||
/// 允许发送群公告
|
|||
/// </summary>
|
|||
public virtual bool AllowSendNotice { get; set; } |
|||
/// <summary>
|
|||
/// 允许解散群组
|
|||
/// </summary>
|
|||
public virtual bool AllowDissolveGroup { get; set; } |
|||
protected ChatGroupAdmin() { } |
|||
public ChatGroupAdmin(long groupId, Guid userId, bool isSuperAdmin = false) |
|||
{ |
|||
GroupId = groupId; |
|||
UserId = userId; |
|||
AllowSilence = true; |
|||
AllowKickPeople = true; |
|||
AllowAddPeople = true; |
|||
AllowSendNotice = true; |
|||
SetSuperAdmin(isSuperAdmin); |
|||
} |
|||
|
|||
public void SetSuperAdmin(bool isSuperAdmin = false) |
|||
{ |
|||
IsSuperAdmin = isSuperAdmin; |
|||
if (isSuperAdmin) |
|||
{ |
|||
AllowDissolveGroup = true; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,119 @@ |
|||
using LINGYUN.Abp.IM.Contract; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Services; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
public class FriendStore : DomainService, IFriendStore |
|||
{ |
|||
protected IUserChatFriendRepository UserChatFriendRepository { get; } |
|||
|
|||
public FriendStore( |
|||
IUserChatFriendRepository userChatFriendRepository) |
|||
{ |
|||
UserChatFriendRepository = userChatFriendRepository; |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task AddMemberAsync(Guid? tenantId, Guid userId, Guid friendId, string remarkName = "") |
|||
{ |
|||
using (CurrentTenant.Change(tenantId)) |
|||
{ |
|||
if (!await UserChatFriendRepository.IsAddedAsync(userId, friendId)) |
|||
{ |
|||
var userChatFriend = new UserChatFriend(userId, friendId, remarkName, tenantId) |
|||
{ |
|||
CreationTime = Clock.Now, |
|||
CreatorId = userId |
|||
}; |
|||
|
|||
await UserChatFriendRepository.InsertAsync(userChatFriend); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task AddShieldMemberAsync(Guid? tenantId, Guid userId, Guid friendId) |
|||
{ |
|||
await ChangeFriendShieldAsync(tenantId, userId, friendId, true); |
|||
} |
|||
|
|||
public virtual async Task<int> GetCountAsync(Guid? tenantId, Guid userId, string filter = "") |
|||
{ |
|||
using (CurrentTenant.Change(tenantId)) |
|||
{ |
|||
return await UserChatFriendRepository |
|||
.GetMembersCountAsync(userId, filter); |
|||
} |
|||
} |
|||
|
|||
public virtual async Task<List<UserFriend>> GetListAsync(Guid? tenantId, Guid userId, string filter = "", string sorting = nameof(UserFriend.UserId), bool reverse = false, int skipCount = 0, int maxResultCount = 10) |
|||
{ |
|||
using (CurrentTenant.Change(tenantId)) |
|||
{ |
|||
return await UserChatFriendRepository |
|||
.GetMembersAsync(userId, filter, sorting, reverse, |
|||
skipCount, maxResultCount); |
|||
} |
|||
} |
|||
|
|||
public virtual async Task<List<UserFriend>> GetLastContactListAsync( |
|||
Guid? tenantId, |
|||
Guid userId, |
|||
int skipCount = 0, |
|||
int maxResultCount = 10) |
|||
{ |
|||
using (CurrentTenant.Change(tenantId)) |
|||
{ |
|||
return await UserChatFriendRepository |
|||
.GetLastContactMembersAsync(userId, |
|||
skipCount, maxResultCount); |
|||
} |
|||
} |
|||
|
|||
public virtual async Task<UserFriend> GetMemberAsync(Guid? tenantId, Guid userId, Guid friendId) |
|||
{ |
|||
using (CurrentTenant.Change(tenantId)) |
|||
{ |
|||
return await UserChatFriendRepository |
|||
.GetMemberAsync(userId, friendId); |
|||
} |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task RemoveMemberAsync(Guid? tenantId, Guid userId, Guid friendId) |
|||
{ |
|||
using (CurrentTenant.Change(tenantId)) |
|||
{ |
|||
var userChatFriend = await UserChatFriendRepository.FindByUserFriendIdAsync(userId, friendId); |
|||
if (userChatFriend != null) |
|||
{ |
|||
await UserChatFriendRepository.DeleteAsync(userChatFriend); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task RemoveShieldMemberAsync(Guid? tenantId, Guid userId, Guid friendId) |
|||
{ |
|||
await ChangeFriendShieldAsync(tenantId, userId, friendId, false); |
|||
} |
|||
|
|||
|
|||
protected virtual async Task ChangeFriendShieldAsync(Guid? tenantId, Guid userId, Guid friendId, bool isBlack = false) |
|||
{ |
|||
using (CurrentTenant.Change(tenantId)) |
|||
{ |
|||
var userChatFriend = await UserChatFriendRepository.FindByUserFriendIdAsync(userId, friendId); |
|||
if (userChatFriend != null) |
|||
{ |
|||
userChatFriend.Black = isBlack; |
|||
await UserChatFriendRepository.UpdateAsync(userChatFriend); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
public interface IChatDataSeeder |
|||
{ |
|||
Task SeedAsync( |
|||
IUserData user); |
|||
} |
|||
} |
|||
@ -1,30 +1,92 @@ |
|||
using LINGYUN.Abp.IM.Messages; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
public interface IMessageRepository |
|||
{ |
|||
Task<UserMessage> InsertUserMessageAsync(UserMessage userMessage, bool saveChangs = false); |
|||
Task InsertUserMessageAsync( |
|||
UserMessage userMessage, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<GroupMessage> InsertGroupMessageAsync(GroupMessage groupMessage, bool saveChangs = false); |
|||
Task InsertGroupMessageAsync( |
|||
GroupMessage groupMessage, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<UserMessage> GetUserMessageAsync(long id); |
|||
Task<UserMessage> GetUserMessageAsync( |
|||
long id, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<GroupMessage> GetGroupMessageAsync(long id); |
|||
Task<GroupMessage> GetGroupMessageAsync( |
|||
long id, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<long> GetUserMessagesCountAsync(Guid sendUserId, Guid receiveUserId, string filter = "", MessageType? type = null); |
|||
Task<long> GetUserMessagesCountAsync( |
|||
Guid sendUserId, |
|||
Guid receiveUserId, |
|||
string filter = "", |
|||
MessageType? type = null, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<List<UserMessage>> GetUserMessagesAsync(Guid sendUserId, Guid receiveUserId, string filter = "", string sorting = nameof(UserMessage.MessageId), MessageType? type = null, int skipCount = 1, int maxResultCount = 10); |
|||
Task<long> GetCountAsync( |
|||
long groupId, |
|||
string filter = "", |
|||
MessageType? type = null, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<long> GetGroupMessagesCountAsync(long groupId, string filter = "", MessageType? type = null); |
|||
Task<long> GetCountAsync( |
|||
Guid sendUserId, |
|||
Guid receiveUserId, |
|||
string filter = "", |
|||
MessageType? type = null, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<List<GroupMessage>> GetGroupMessagesAsync(long groupId, string filter = "", string sorting = nameof(UserMessage.MessageId), MessageType? type = null, int skipCount = 1, int maxResultCount = 10); |
|||
Task<List<UserMessage>> GetUserMessagesAsync( |
|||
Guid sendUserId, |
|||
Guid receiveUserId, |
|||
string filter = "", |
|||
string sorting = nameof(UserMessage.MessageId), |
|||
bool reverse = true, |
|||
MessageType? type = null, |
|||
int skipCount = 0, |
|||
int maxResultCount = 10, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<long> GetUserGroupMessagesCountAsync(Guid sendUserId, long groupId, string filter = "", MessageType? type = null); |
|||
Task<long> GetGroupMessagesCountAsync( |
|||
long groupId, |
|||
string filter = "", |
|||
MessageType? type = null, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<List<GroupMessage>> GetUserGroupMessagesAsync(Guid sendUserId, long groupId, string filter = "", string sorting = nameof(UserMessage.MessageId), MessageType? type = null, int skipCount = 1, int maxResultCount = 10); |
|||
Task<List<GroupMessage>> GetGroupMessagesAsync( |
|||
long groupId, |
|||
string filter = "", |
|||
string sorting = nameof(UserMessage.MessageId), |
|||
bool reverse = true, |
|||
MessageType? type = null, |
|||
int skipCount = 0, |
|||
int maxResultCount = 10, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<long> GetUserGroupMessagesCountAsync( |
|||
Guid sendUserId, |
|||
long groupId, |
|||
string filter = "", |
|||
MessageType? type = null, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<List<GroupMessage>> GetUserGroupMessagesAsync( |
|||
Guid sendUserId, |
|||
long groupId, |
|||
string filter = "", |
|||
string sorting = nameof(UserMessage.MessageId), |
|||
bool reverse = true, |
|||
MessageType? type = null, |
|||
int skipCount = 0, |
|||
int maxResultCount = 10, |
|||
CancellationToken cancellationToken = default); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,38 @@ |
|||
using LINGYUN.Abp.IM; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Repositories; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
public interface IUserChatCardRepository : IBasicRepository<UserChatCard, long> |
|||
{ |
|||
Task<bool> CheckUserIdExistsAsync( |
|||
Guid userId, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<int> GetMemberCountAsync( |
|||
string findUserName = "", |
|||
int? startAge = null, |
|||
int? endAge = null, |
|||
Sex? sex = null, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<List<UserCard>> GetMembersAsync( |
|||
string findUserName = "", |
|||
int? startAge = null, |
|||
int? endAge = null, |
|||
Sex? sex = null, |
|||
string sorting = nameof(UserChatCard.UserId), |
|||
bool reverse = false, |
|||
int skipCount = 0, |
|||
int maxResultCount = 10, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<UserCard> GetMemberAsync( |
|||
Guid findUserId, |
|||
CancellationToken cancellationToken = default); |
|||
} |
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
using LINGYUN.Abp.IM.Contract; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Repositories; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
public interface IUserChatFriendRepository : IBasicRepository<UserChatFriend, long> |
|||
{ |
|||
Task<bool> IsAddedAsync( |
|||
Guid userId, |
|||
Guid frientId, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<UserChatFriend> FindByUserFriendIdAsync( |
|||
Guid userId, |
|||
Guid friendId, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<int> GetMembersCountAsync( |
|||
Guid userId, |
|||
string filter = "", |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<List<UserFriend>> GetMembersAsync( |
|||
Guid userId, |
|||
string filter = "", |
|||
string sorting = nameof(UserChatFriend.UserId), |
|||
bool reverse = false, |
|||
int skipCount = 0, |
|||
int maxResultCount = 10, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<List<UserFriend>> GetLastContactMembersAsync( |
|||
Guid userId, |
|||
int skipCount = 0, |
|||
int maxResultCount = 10, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<UserFriend> GetMemberAsync( |
|||
Guid userId, |
|||
Guid friendId, |
|||
CancellationToken cancellationToken = default); |
|||
} |
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
using LINGYUN.Abp.IM; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Services; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
public class UserCardFinder : DomainService, IUserCardFinder |
|||
{ |
|||
protected IUserChatCardRepository UserChatCardRepository { get; } |
|||
|
|||
public UserCardFinder( |
|||
IUserChatCardRepository userChatCardRepository) |
|||
{ |
|||
UserChatCardRepository = userChatCardRepository; |
|||
} |
|||
|
|||
public virtual async Task<int> GetCountAsync(Guid? tenantId, string findUserName = "", int? startAge = null, int? endAge = null, Sex? sex = null) |
|||
{ |
|||
using (CurrentTenant.Change(tenantId)) |
|||
{ |
|||
return await UserChatCardRepository |
|||
.GetMemberCountAsync(findUserName, startAge, endAge, sex); |
|||
} |
|||
} |
|||
|
|||
public virtual async Task<List<UserCard>> GetListAsync(Guid? tenantId, string findUserName = "", int? startAge = null, int? endAge = null, Sex? sex = null, string sorting = nameof(UserCard.UserId), bool reverse = false, int skipCount = 0, int maxResultCount = 10) |
|||
{ |
|||
using (CurrentTenant.Change(tenantId)) |
|||
{ |
|||
return await UserChatCardRepository |
|||
.GetMembersAsync(findUserName, startAge, endAge, sex, |
|||
sorting, reverse, skipCount, maxResultCount); |
|||
} |
|||
} |
|||
|
|||
public virtual async Task<UserCard> GetMemberAsync(Guid? tenantId, Guid findUserId) |
|||
{ |
|||
using (CurrentTenant.Change(tenantId)) |
|||
{ |
|||
return await UserChatCardRepository |
|||
.GetMemberAsync(findUserId); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,105 @@ |
|||
using LINGYUN.Abp.IM; |
|||
using LINGYUN.Abp.MessageService.Utils; |
|||
using System; |
|||
using Volo.Abp.Domain.Entities.Auditing; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.Timing; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
/// <summary>
|
|||
/// 用户卡片
|
|||
/// </summary>
|
|||
public class UserChatCard : AuditedAggregateRoot<long>, IMultiTenant |
|||
{ |
|||
/// <summary>
|
|||
/// 租户
|
|||
/// </summary>
|
|||
public virtual Guid? TenantId { get; protected set; } |
|||
/// <summary>
|
|||
/// 用户标识
|
|||
/// </summary>
|
|||
public virtual Guid UserId { get; protected set; } |
|||
/// <summary>
|
|||
/// 用户名
|
|||
/// </summary>
|
|||
public virtual string UserName { get; protected set; } |
|||
/// <summary>
|
|||
/// 性别
|
|||
/// </summary>
|
|||
public virtual Sex Sex { get; set; } |
|||
/// <summary>
|
|||
/// 签名
|
|||
/// </summary>
|
|||
public virtual string Sign { get; set; } |
|||
/// <summary>
|
|||
/// 昵称
|
|||
/// </summary>
|
|||
public virtual string NickName { get; set; } |
|||
/// <summary>
|
|||
/// 说明
|
|||
/// </summary>
|
|||
public virtual string Description { get; set; } |
|||
/// <summary>
|
|||
/// 头像地址
|
|||
/// </summary>
|
|||
public virtual string AvatarUrl { get; protected set; } |
|||
/// <summary>
|
|||
/// 生日
|
|||
/// </summary>
|
|||
public virtual DateTime? Birthday { get; protected set; } |
|||
/// <summary>
|
|||
/// 年龄
|
|||
/// </summary>
|
|||
public virtual int Age { get; protected set; } |
|||
|
|||
protected UserChatCard() |
|||
{ |
|||
} |
|||
|
|||
public UserChatCard( |
|||
Guid userId, |
|||
string userName, |
|||
Sex sex, |
|||
string nickName = null, |
|||
string avatarUrl = "", |
|||
Guid? tenantId = null) |
|||
{ |
|||
Sex = sex; |
|||
UserId = userId; |
|||
UserName = userName; |
|||
NickName = nickName ?? userName; |
|||
AvatarUrl = avatarUrl; |
|||
TenantId = tenantId; |
|||
} |
|||
|
|||
public void SetBirthday(DateTime birthday, IClock clock) |
|||
{ |
|||
Birthday = birthday; |
|||
|
|||
Age = DateTimeHelper.CalcAgrByBirthdate(birthday, clock.Now); |
|||
} |
|||
|
|||
public void SetAvatarUrl(string url) |
|||
{ |
|||
AvatarUrl = url; |
|||
} |
|||
|
|||
public UserCard ToUserCard() |
|||
{ |
|||
return new UserCard |
|||
{ |
|||
Age = Age, |
|||
AvatarUrl = AvatarUrl, |
|||
Birthday = Birthday, |
|||
Description = Description, |
|||
NickName = NickName, |
|||
Sex = Sex, |
|||
Sign = Sign, |
|||
UserId = UserId, |
|||
UserName = UserName, |
|||
TenantId = TenantId |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
using System; |
|||
using Volo.Abp.Domain.Entities.Auditing; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
public class UserChatFriend : CreationAuditedEntity<long>, IMultiTenant |
|||
{ |
|||
/// <summary>
|
|||
/// 租户
|
|||
/// </summary>
|
|||
public virtual Guid? TenantId { get; protected set; } |
|||
/// <summary>
|
|||
/// 用户标识
|
|||
/// </summary>
|
|||
public virtual Guid UserId { get; protected set; } |
|||
/// <summary>
|
|||
/// 好友标识
|
|||
/// </summary>
|
|||
public virtual Guid FrientId { get; protected set; } |
|||
/// <summary>
|
|||
/// 已添加黑名单
|
|||
/// </summary>
|
|||
public virtual bool Black { get; set; } |
|||
/// <summary>
|
|||
/// 消息免打扰
|
|||
/// </summary>
|
|||
public virtual bool DontDisturb { get; set; } |
|||
/// <summary>
|
|||
/// 特别关注
|
|||
/// </summary>
|
|||
public virtual bool SpecialFocus { get; set; } |
|||
/// <summary>
|
|||
/// 备注名称
|
|||
/// </summary>
|
|||
public virtual string RemarkName { get; set; } |
|||
|
|||
protected UserChatFriend() |
|||
{ |
|||
} |
|||
|
|||
public UserChatFriend( |
|||
Guid userId, |
|||
Guid friendId, |
|||
string remarkName = "", |
|||
Guid? tenantId = null) |
|||
{ |
|||
UserId = userId; |
|||
FrientId = friendId; |
|||
RemarkName = remarkName; |
|||
TenantId = tenantId; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,74 @@ |
|||
using System; |
|||
using Volo.Abp.Domain.Entities.Auditing; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.Timing; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
/// <summary>
|
|||
/// 用户群组卡片
|
|||
/// </summary>
|
|||
public class UserGroupCard : AuditedAggregateRoot<long>, IMultiTenant |
|||
{ |
|||
/// <summary>
|
|||
/// 租户
|
|||
/// </summary>
|
|||
public virtual Guid? TenantId { get; protected set; } |
|||
/// <summary>
|
|||
/// 用户标识
|
|||
/// </summary>
|
|||
public virtual Guid UserId { get; protected set; } |
|||
/// <summary>
|
|||
/// 昵称
|
|||
/// </summary>
|
|||
public virtual string NickName { get; set; } |
|||
/// <summary>
|
|||
/// 是否管理员
|
|||
/// </summary>
|
|||
public virtual bool IsAdmin { get; protected set; } |
|||
/// <summary>
|
|||
/// 禁言期止
|
|||
/// </summary>
|
|||
public virtual DateTime? SilenceEnd { get; protected set; } |
|||
protected UserGroupCard() |
|||
{ |
|||
} |
|||
public UserGroupCard( |
|||
Guid userId, |
|||
string nickName = "", |
|||
bool isAdmin = false, |
|||
DateTime? silenceEnd = null, |
|||
Guid? tenantId = null) |
|||
{ |
|||
UserId = userId; |
|||
NickName = nickName; |
|||
IsAdmin = isAdmin; |
|||
SilenceEnd = silenceEnd; |
|||
TenantId = tenantId; |
|||
} |
|||
/// <summary>
|
|||
/// 设置管理员
|
|||
/// </summary>
|
|||
/// <param name="admin"></param>
|
|||
public void SetAdmin(bool admin) |
|||
{ |
|||
IsAdmin = admin; |
|||
} |
|||
/// <summary>
|
|||
/// 禁言
|
|||
/// </summary>
|
|||
/// <param name="clock"></param>
|
|||
/// <param name="seconds"></param>
|
|||
public void Silence(IClock clock, double seconds) |
|||
{ |
|||
SilenceEnd = clock.Now.AddSeconds(seconds); |
|||
} |
|||
/// <summary>
|
|||
/// 解除禁言
|
|||
/// </summary>
|
|||
public void UnSilence() |
|||
{ |
|||
SilenceEnd = null; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Utils |
|||
{ |
|||
public static class DateTimeHelper |
|||
{ |
|||
public static int CalcAgrByBirthdate(DateTime birthdate, DateTime nowTime) |
|||
{ |
|||
int age = nowTime.Year - birthdate.Year; |
|||
if (nowTime.Month < birthdate.Month || (nowTime.Month == birthdate.Month && nowTime.Day < birthdate.Day)) |
|||
{ |
|||
age--; |
|||
} |
|||
return age < 0 ? 0 : age; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
using LINGYUN.Abp.IM; |
|||
using LINGYUN.Abp.MessageService.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
public class EfCoreUserChatCardRepository : EfCoreRepository<IMessageServiceDbContext, UserChatCard, long>, IUserChatCardRepository |
|||
{ |
|||
public EfCoreUserChatCardRepository( |
|||
IDbContextProvider<IMessageServiceDbContext> dbContextProvider) |
|||
: base(dbContextProvider) |
|||
{ |
|||
} |
|||
|
|||
public virtual async Task<bool> CheckUserIdExistsAsync(Guid userId, CancellationToken cancellationToken = default) |
|||
{ |
|||
return await DbSet |
|||
.AnyAsync(ucc => ucc.UserId == userId, |
|||
GetCancellationToken(cancellationToken)); |
|||
} |
|||
|
|||
public virtual async Task<UserCard> GetMemberAsync(Guid findUserId, CancellationToken cancellationToken = default) |
|||
{ |
|||
return await DbSet |
|||
.Where(ucc => ucc.UserId == findUserId) |
|||
.Select(ucc => ucc.ToUserCard()) |
|||
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
|
|||
public virtual async Task<int> GetMemberCountAsync(string findUserName = "", int? startAge = null, int? endAge = null, Sex? sex = null, CancellationToken cancellationToken = default) |
|||
{ |
|||
return await DbSet |
|||
.WhereIf(!findUserName.IsNullOrWhiteSpace(), ucc => ucc.UserName.Contains(findUserName)) |
|||
.WhereIf(startAge.HasValue, ucc => ucc.Age >= startAge.Value) |
|||
.WhereIf(endAge.HasValue, ucc => ucc.Age <= endAge.Value) |
|||
.WhereIf(sex.HasValue, ucc => ucc.Sex == sex) |
|||
.CountAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
|
|||
public virtual async Task<List<UserCard>> GetMembersAsync(string findUserName = "", int? startAge = null, int? endAge = null, Sex? sex = null, string sorting = nameof(UserChatCard.UserId), bool reverse = false, int skipCount = 0, int maxResultCount = 10, CancellationToken cancellationToken = default) |
|||
{ |
|||
sorting ??= nameof(UserChatCard.UserId); |
|||
sorting = reverse ? sorting + " desc" : sorting; |
|||
return await DbSet |
|||
.WhereIf(!findUserName.IsNullOrWhiteSpace(), ucc => ucc.UserName.Contains(findUserName)) |
|||
.WhereIf(startAge.HasValue, ucc => ucc.Age >= startAge.Value) |
|||
.WhereIf(endAge.HasValue, ucc => ucc.Age <= endAge.Value) |
|||
.WhereIf(sex.HasValue, ucc => ucc.Sex == sex) |
|||
.OrderBy(sorting) |
|||
.PageBy(skipCount, maxResultCount) |
|||
.Select(ucc => ucc.ToUserCard()) |
|||
.ToListAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,164 @@ |
|||
using LINGYUN.Abp.IM.Contract; |
|||
using LINGYUN.Abp.MessageService.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Chat |
|||
{ |
|||
public class EfCoreUserChatFriendRepository : EfCoreRepository<IMessageServiceDbContext, UserChatFriend, long>, IUserChatFriendRepository |
|||
{ |
|||
public EfCoreUserChatFriendRepository( |
|||
IDbContextProvider<IMessageServiceDbContext> dbContextProvider) |
|||
: base(dbContextProvider) |
|||
{ |
|||
} |
|||
|
|||
public virtual async Task<UserChatFriend> FindByUserFriendIdAsync(Guid userId, Guid friendId, CancellationToken cancellationToken = default) |
|||
{ |
|||
return await DbSet |
|||
.Where(ucf => ucf.UserId == userId && ucf.FrientId == friendId) |
|||
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
|
|||
public virtual async Task<UserFriend> GetMemberAsync(Guid userId, Guid friendId, CancellationToken cancellationToken = default) |
|||
{ |
|||
var userFriendQuery = from ucf in DbContext.Set<UserChatFriend>() |
|||
join ucc in DbContext.Set<UserChatCard>() |
|||
on ucf.FrientId equals ucc.UserId |
|||
where ucf.UserId == userId && ucf.FrientId == friendId |
|||
select new UserFriend |
|||
{ |
|||
Age = ucc.Age, |
|||
AvatarUrl = ucc.AvatarUrl, |
|||
Birthday = ucc.Birthday, |
|||
Black = ucf.Black, |
|||
Description = ucc.Description, |
|||
DontDisturb = ucf.DontDisturb, |
|||
FriendId = ucf.FrientId, |
|||
NickName = ucc.NickName, |
|||
RemarkName = ucf.RemarkName, |
|||
Sex = ucc.Sex, |
|||
Sign = ucc.Sign, |
|||
SpecialFocus = ucf.SpecialFocus, |
|||
TenantId = ucf.TenantId, |
|||
UserId = ucf.UserId, |
|||
UserName = ucc.UserName |
|||
}; |
|||
|
|||
return await userFriendQuery |
|||
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
|
|||
public virtual async Task<List<UserFriend>> GetMembersAsync(Guid userId, string filter = "", string sorting = nameof(UserChatFriend.UserId), bool reverse = false, int skipCount = 0, int maxResultCount = 10, CancellationToken cancellationToken = default) |
|||
{ |
|||
// 过滤用户资料
|
|||
var userChatCardQuery = DbContext.Set<UserChatCard>() |
|||
.WhereIf(!filter.IsNullOrWhiteSpace(), ucc => ucc.UserName.Contains(filter) || ucc.NickName.Contains(filter)); |
|||
|
|||
// 过滤好友资料
|
|||
var userChatFriendQuery = DbContext.Set<UserChatFriend>() |
|||
.WhereIf(!filter.IsNullOrWhiteSpace(), ucf => ucf.RemarkName.Contains(filter)); |
|||
|
|||
// 组合查询
|
|||
var userFriendQuery = from ucf in userChatFriendQuery |
|||
join ucc in userChatCardQuery // TODO: Need LEFT JOIN?
|
|||
on ucf.FrientId equals ucc.UserId |
|||
where ucf.UserId == userId |
|||
select new UserFriend |
|||
{ |
|||
Age = ucc.Age, |
|||
AvatarUrl = ucc.AvatarUrl, |
|||
Birthday = ucc.Birthday, |
|||
Black = ucf.Black, |
|||
Description = ucc.Description, |
|||
DontDisturb = ucf.DontDisturb, |
|||
FriendId = ucf.FrientId, |
|||
NickName = ucc.NickName, |
|||
RemarkName = ucf.RemarkName, |
|||
Sex = ucc.Sex, |
|||
Sign = ucc.Sign, |
|||
SpecialFocus = ucf.SpecialFocus, |
|||
TenantId = ucf.TenantId, |
|||
UserId = ucf.UserId, |
|||
UserName = ucc.UserName |
|||
}; |
|||
|
|||
return await userFriendQuery |
|||
.OrderBy(sorting) |
|||
.PageBy(skipCount, maxResultCount) |
|||
.ToListAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
|
|||
public virtual async Task<List<UserFriend>> GetLastContactMembersAsync( |
|||
Guid userId, |
|||
int skipCount = 0, |
|||
int maxResultCount = 10, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
var userReceiveMsgQuery = DbContext.Set<UserMessage>() |
|||
.Where(um => um.ReceiveUserId == userId); |
|||
|
|||
var userFriendQuery = from ucf in DbContext.Set<UserChatFriend>() |
|||
join ucc in DbContext.Set<UserChatCard>() |
|||
on ucf.FrientId equals ucc.UserId |
|||
join um in userReceiveMsgQuery |
|||
on ucc.UserId equals um.CreatorId |
|||
where ucf.UserId == userId |
|||
orderby um.CreationTime descending // 消息创建时间倒序
|
|||
select new UserFriend |
|||
{ |
|||
Age = ucc.Age, |
|||
AvatarUrl = ucc.AvatarUrl, |
|||
Birthday = ucc.Birthday, |
|||
Black = ucf.Black, |
|||
Description = ucc.Description, |
|||
DontDisturb = ucf.DontDisturb, |
|||
FriendId = ucf.FrientId, |
|||
NickName = ucc.NickName, |
|||
RemarkName = ucf.RemarkName, |
|||
Sex = ucc.Sex, |
|||
Sign = ucc.Sign, |
|||
SpecialFocus = ucf.SpecialFocus, |
|||
TenantId = ucf.TenantId, |
|||
UserId = ucf.UserId, |
|||
UserName = ucc.UserName |
|||
}; |
|||
|
|||
return await userFriendQuery |
|||
.PageBy(skipCount, maxResultCount) |
|||
.ToListAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
|
|||
public virtual async Task<int> GetMembersCountAsync(Guid userId, string filter = "", CancellationToken cancellationToken = default) |
|||
{ |
|||
var userChatCardQuery = DbContext.Set<UserChatCard>() |
|||
.WhereIf(!filter.IsNullOrWhiteSpace(), ucc => ucc.UserName.Contains(filter) || ucc.NickName.Contains(filter)); |
|||
|
|||
var userChatFriendQuery = DbContext.Set<UserChatFriend>() |
|||
.WhereIf(!filter.IsNullOrWhiteSpace(), ucf => ucf.RemarkName.Contains(filter)); |
|||
|
|||
var userFriendQuery = from ucf in userChatFriendQuery |
|||
join ucc in userChatCardQuery |
|||
on ucf.FrientId equals ucc.UserId |
|||
where ucf.UserId == userId |
|||
select ucc; |
|||
|
|||
return await userFriendQuery |
|||
.CountAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
|
|||
public virtual async Task<bool> IsAddedAsync(Guid userId, Guid frientId, CancellationToken cancellationToken = default) |
|||
{ |
|||
return await DbSet |
|||
.AnyAsync(ucf => ucf.UserId == userId && ucf.FrientId == frientId, |
|||
GetCancellationToken(cancellationToken)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using LINGYUN.Abp.MessageService.Chat; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.EntityFrameworkCore |
|||
{ |
|||
[ConnectionStringName(AbpMessageServiceDbProperties.ConnectionStringName)] |
|||
public interface IMessageServiceDbContext : IEfCoreDbContext |
|||
{ |
|||
DbSet<UserChatCard> UserChatCards { get; set; } |
|||
DbSet<UserGroupCard> UserGroupCards { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
using LINGYUN.Abp.IM.Contract; |
|||
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.Chat |
|||
{ |
|||
[RemoteService(Name = AbpMessageServiceConsts.RemoteServiceName)] |
|||
[Route("api/im/my-friends")] |
|||
public class MyFriendController : AbpController, IMyFriendAppService |
|||
{ |
|||
protected IMyFriendAppService MyFriendAppService { get; } |
|||
|
|||
public MyFriendController(IMyFriendAppService myFriendAppService) |
|||
{ |
|||
MyFriendAppService = myFriendAppService; |
|||
} |
|||
|
|||
[HttpPost] |
|||
public virtual async Task CreateAsync(MyFriendCreateDto input) |
|||
{ |
|||
await MyFriendAppService.CreateAsync(input); |
|||
} |
|||
|
|||
[HttpDelete] |
|||
public virtual async Task DeleteAsync(MyFriendOperationDto input) |
|||
{ |
|||
await MyFriendAppService.DeleteAsync(input); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("last-contacts")] |
|||
public virtual async Task<PagedResultDto<UserFriend>> GetLastContactFriendsAsync(PagedResultRequestDto input) |
|||
{ |
|||
return await MyFriendAppService.GetLastContactFriendsAsync(input); |
|||
} |
|||
|
|||
[HttpGet] |
|||
public virtual async Task<PagedResultDto<UserFriend>> GetMyFriendsAsync(MyFriendGetByPagedDto input) |
|||
{ |
|||
return await MyFriendAppService.GetMyFriendsAsync(input); |
|||
} |
|||
} |
|||
} |
|||
Binary file not shown.
@ -0,0 +1,590 @@ |
|||
// <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("20201024093309_Add-MemberCard-Entity")] |
|||
partial class AddMemberCardEntity |
|||
{ |
|||
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
|||
.HasAnnotation("ProductVersion", "3.1.7") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 64); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.ChatGroup", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<string>("Address") |
|||
.HasColumnType("varchar(256) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(256); |
|||
|
|||
b.Property<Guid>("AdminUserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<bool>("AllowAnonymous") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<bool>("AllowSendMessage") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnName("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Description") |
|||
.HasColumnType("varchar(128) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(128); |
|||
|
|||
b.Property<long>("GroupId") |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnName("LastModificationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnName("LastModifierId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<int>("MaxUserCount") |
|||
.HasColumnType("int"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasColumnType("varchar(20) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(20); |
|||
|
|||
b.Property<string>("Notice") |
|||
.HasColumnType("varchar(64) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(64); |
|||
|
|||
b.Property<string>("Tag") |
|||
.HasColumnType("varchar(512) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(512); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "Name"); |
|||
|
|||
b.ToTable("AppChatGroups"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.GroupChatBlack", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<long>("GroupId") |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<Guid>("ShieldUserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "GroupId"); |
|||
|
|||
b.ToTable("AppGroupChatBlacks"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.GroupMessage", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<string>("Content") |
|||
.IsRequired() |
|||
.HasColumnType("longtext CHARACTER SET utf8mb4") |
|||
.HasMaxLength(1048576); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<long>("GroupId") |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<long>("MessageId") |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<sbyte>("SendState") |
|||
.HasColumnType("tinyint"); |
|||
|
|||
b.Property<string>("SendUserName") |
|||
.IsRequired() |
|||
.HasColumnType("varchar(64) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(64); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<int>("Type") |
|||
.HasColumnType("int"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "GroupId"); |
|||
|
|||
b.ToTable("AppGroupMessages"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatBlack", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("ShieldUserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("UserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "UserId"); |
|||
|
|||
b.ToTable("AppUserChatBlacks"); |
|||
}); |
|||
|
|||
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") |
|||
.HasColumnType("varchar(512) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(512); |
|||
|
|||
b.Property<DateTime?>("Birthday") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasColumnName("ConcurrencyStamp") |
|||
.HasColumnType("varchar(40) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(40); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnName("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Description") |
|||
.HasColumnType("varchar(50) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(50); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnName("ExtraProperties") |
|||
.HasColumnType("longtext CHARACTER SET utf8mb4"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnName("LastModificationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnName("LastModifierId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("NickName") |
|||
.HasColumnType("varchar(256) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(256); |
|||
|
|||
b.Property<int>("Sex") |
|||
.HasColumnType("int"); |
|||
|
|||
b.Property<string>("Sign") |
|||
.HasColumnType("varchar(30) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(30); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("UserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("UserName") |
|||
.IsRequired() |
|||
.HasColumnType("varchar(256) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(256); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "UserId"); |
|||
|
|||
b.ToTable("AppUserChatCards"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatGroup", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnName("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<long>("GroupId") |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("UserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "GroupId", "UserId"); |
|||
|
|||
b.ToTable("AppUserChatGroups"); |
|||
}); |
|||
|
|||
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") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("UserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "UserId"); |
|||
|
|||
b.ToTable("AppUserChatSettings"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserGroupCard", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasColumnName("ConcurrencyStamp") |
|||
.HasColumnType("varchar(40) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(40); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnName("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnName("ExtraProperties") |
|||
.HasColumnType("longtext CHARACTER SET utf8mb4"); |
|||
|
|||
b.Property<bool>("IsAdmin") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnName("LastModificationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnName("LastModifierId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("NickName") |
|||
.HasColumnType("varchar(256) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(256); |
|||
|
|||
b.Property<DateTime?>("SilenceEnd") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("UserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "UserId"); |
|||
|
|||
b.ToTable("AppUserGroupCards"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserMessage", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<string>("Content") |
|||
.IsRequired() |
|||
.HasColumnType("longtext CHARACTER SET utf8mb4") |
|||
.HasMaxLength(1048576); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<long>("MessageId") |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<Guid>("ReceiveUserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<sbyte>("SendState") |
|||
.HasColumnType("tinyint"); |
|||
|
|||
b.Property<string>("SendUserName") |
|||
.IsRequired() |
|||
.HasColumnType("varchar(64) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(64); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<int>("Type") |
|||
.HasColumnType("int"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "ReceiveUserId"); |
|||
|
|||
b.ToTable("AppUserMessages"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserSpecialFocus", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("FocusUserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("UserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "UserId"); |
|||
|
|||
b.ToTable("AppUserSpecialFocuss"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.Notification", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<DateTime?>("ExpirationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<string>("NotificationCateGory") |
|||
.IsRequired() |
|||
.HasColumnType("varchar(50) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(50); |
|||
|
|||
b.Property<string>("NotificationData") |
|||
.IsRequired() |
|||
.HasColumnType("longtext CHARACTER SET utf8mb4") |
|||
.HasMaxLength(1048576); |
|||
|
|||
b.Property<long>("NotificationId") |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<string>("NotificationName") |
|||
.IsRequired() |
|||
.HasColumnType("varchar(100) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(100); |
|||
|
|||
b.Property<string>("NotificationTypeName") |
|||
.IsRequired() |
|||
.HasColumnType("varchar(512) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(512); |
|||
|
|||
b.Property<sbyte>("Severity") |
|||
.HasColumnType("tinyint"); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
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") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("UserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "UserId", "NotificationId") |
|||
.HasName("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") |
|||
.HasColumnName("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<string>("NotificationName") |
|||
.IsRequired() |
|||
.HasColumnType("varchar(100) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(100); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("UserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("UserName") |
|||
.IsRequired() |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("varchar(128) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(128) |
|||
.HasDefaultValue("/"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "UserId", "NotificationName") |
|||
.IsUnique() |
|||
.HasName("IX_Tenant_User_Notification_Name"); |
|||
|
|||
b.ToTable("AppUserSubscribes"); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,125 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Metadata; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Migrations |
|||
{ |
|||
public partial class AddMemberCardEntity : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "AppChatGroupAdmins"); |
|||
|
|||
migrationBuilder.AddColumn<Guid>( |
|||
name: "AdminUserId", |
|||
table: "AppChatGroups", |
|||
nullable: false, |
|||
defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AppUserChatCards", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<long>(nullable: false) |
|||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
|||
ExtraProperties = table.Column<string>(nullable: true), |
|||
ConcurrencyStamp = table.Column<string>(maxLength: 40, nullable: true), |
|||
CreationTime = table.Column<DateTime>(nullable: false), |
|||
CreatorId = table.Column<Guid>(nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(nullable: true), |
|||
LastModifierId = table.Column<Guid>(nullable: true), |
|||
TenantId = table.Column<Guid>(nullable: true), |
|||
UserId = table.Column<Guid>(nullable: false), |
|||
UserName = table.Column<string>(maxLength: 256, nullable: false), |
|||
Sex = table.Column<int>(nullable: false), |
|||
Sign = table.Column<string>(maxLength: 30, nullable: true), |
|||
NickName = table.Column<string>(maxLength: 256, nullable: true), |
|||
Description = table.Column<string>(maxLength: 50, nullable: true), |
|||
AvatarUrl = table.Column<string>(maxLength: 512, nullable: true), |
|||
Birthday = table.Column<DateTime>(nullable: true), |
|||
Age = table.Column<int>(nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AppUserChatCards", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AppUserGroupCards", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<long>(nullable: false) |
|||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
|||
ExtraProperties = table.Column<string>(nullable: true), |
|||
ConcurrencyStamp = table.Column<string>(maxLength: 40, nullable: true), |
|||
CreationTime = table.Column<DateTime>(nullable: false), |
|||
CreatorId = table.Column<Guid>(nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(nullable: true), |
|||
LastModifierId = table.Column<Guid>(nullable: true), |
|||
TenantId = table.Column<Guid>(nullable: true), |
|||
UserId = table.Column<Guid>(nullable: false), |
|||
NickName = table.Column<string>(maxLength: 256, nullable: true), |
|||
IsAdmin = table.Column<bool>(nullable: false), |
|||
SilenceEnd = table.Column<DateTime>(nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AppUserGroupCards", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AppUserChatCards_TenantId_UserId", |
|||
table: "AppUserChatCards", |
|||
columns: new[] { "TenantId", "UserId" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AppUserGroupCards_TenantId_UserId", |
|||
table: "AppUserGroupCards", |
|||
columns: new[] { "TenantId", "UserId" }); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "AppUserChatCards"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AppUserGroupCards"); |
|||
|
|||
migrationBuilder.DropColumn( |
|||
name: "AdminUserId", |
|||
table: "AppChatGroups"); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AppChatGroupAdmins", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<long>(type: "bigint", nullable: false) |
|||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
|||
AllowAddPeople = table.Column<bool>(type: "tinyint(1)", nullable: false), |
|||
AllowDissolveGroup = table.Column<bool>(type: "tinyint(1)", nullable: false), |
|||
AllowKickPeople = table.Column<bool>(type: "tinyint(1)", nullable: false), |
|||
AllowSendNotice = table.Column<bool>(type: "tinyint(1)", nullable: false), |
|||
AllowSilence = table.Column<bool>(type: "tinyint(1)", nullable: false), |
|||
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
|||
CreatorId = table.Column<string>(type: "char(36)", nullable: true), |
|||
GroupId = table.Column<long>(type: "bigint", nullable: false), |
|||
IsSuperAdmin = table.Column<bool>(type: "tinyint(1)", nullable: false), |
|||
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
|||
LastModifierId = table.Column<string>(type: "char(36)", nullable: true), |
|||
TenantId = table.Column<string>(type: "char(36)", nullable: true), |
|||
UserId = table.Column<string>(type: "char(36)", nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AppChatGroupAdmins", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AppChatGroupAdmins_TenantId_GroupId", |
|||
table: "AppChatGroupAdmins", |
|||
columns: new[] { "TenantId", "GroupId" }); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,634 @@ |
|||
// <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("20201024114206_Add-UserChatFriend-Entity")] |
|||
partial class AddUserChatFriendEntity |
|||
{ |
|||
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
|||
.HasAnnotation("ProductVersion", "3.1.7") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 64); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.ChatGroup", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<string>("Address") |
|||
.HasColumnType("varchar(256) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(256); |
|||
|
|||
b.Property<Guid>("AdminUserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<bool>("AllowAnonymous") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<bool>("AllowSendMessage") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnName("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Description") |
|||
.HasColumnType("varchar(128) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(128); |
|||
|
|||
b.Property<long>("GroupId") |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnName("LastModificationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnName("LastModifierId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<int>("MaxUserCount") |
|||
.HasColumnType("int"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasColumnType("varchar(20) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(20); |
|||
|
|||
b.Property<string>("Notice") |
|||
.HasColumnType("varchar(64) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(64); |
|||
|
|||
b.Property<string>("Tag") |
|||
.HasColumnType("varchar(512) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(512); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "Name"); |
|||
|
|||
b.ToTable("AppChatGroups"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.GroupChatBlack", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<long>("GroupId") |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<Guid>("ShieldUserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "GroupId"); |
|||
|
|||
b.ToTable("AppGroupChatBlacks"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.GroupMessage", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<string>("Content") |
|||
.IsRequired() |
|||
.HasColumnType("longtext CHARACTER SET utf8mb4") |
|||
.HasMaxLength(1048576); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<long>("GroupId") |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<long>("MessageId") |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<sbyte>("SendState") |
|||
.HasColumnType("tinyint"); |
|||
|
|||
b.Property<string>("SendUserName") |
|||
.IsRequired() |
|||
.HasColumnType("varchar(64) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(64); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<int>("Type") |
|||
.HasColumnType("int"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "GroupId"); |
|||
|
|||
b.ToTable("AppGroupMessages"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatBlack", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("ShieldUserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("UserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "UserId"); |
|||
|
|||
b.ToTable("AppUserChatBlacks"); |
|||
}); |
|||
|
|||
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") |
|||
.HasColumnType("varchar(512) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(512); |
|||
|
|||
b.Property<DateTime?>("Birthday") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasColumnName("ConcurrencyStamp") |
|||
.HasColumnType("varchar(40) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(40); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnName("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Description") |
|||
.HasColumnType("varchar(50) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(50); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnName("ExtraProperties") |
|||
.HasColumnType("longtext CHARACTER SET utf8mb4"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnName("LastModificationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnName("LastModifierId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("NickName") |
|||
.HasColumnType("varchar(256) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(256); |
|||
|
|||
b.Property<int>("Sex") |
|||
.HasColumnType("int"); |
|||
|
|||
b.Property<string>("Sign") |
|||
.HasColumnType("varchar(30) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(30); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("UserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("UserName") |
|||
.IsRequired() |
|||
.HasColumnType("varchar(256) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(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<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnName("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<bool>("DontDisturb") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<Guid>("FrientId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("RemarkName") |
|||
.HasColumnType("varchar(256) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(256); |
|||
|
|||
b.Property<bool>("SpecialFocus") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("UserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "UserId", "FrientId"); |
|||
|
|||
b.ToTable("AppUserChatFriends"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatGroup", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnName("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<long>("GroupId") |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("UserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "GroupId", "UserId"); |
|||
|
|||
b.ToTable("AppUserChatGroups"); |
|||
}); |
|||
|
|||
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") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("UserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "UserId"); |
|||
|
|||
b.ToTable("AppUserChatSettings"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserGroupCard", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasColumnName("ConcurrencyStamp") |
|||
.HasColumnType("varchar(40) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(40); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnName("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnName("ExtraProperties") |
|||
.HasColumnType("longtext CHARACTER SET utf8mb4"); |
|||
|
|||
b.Property<bool>("IsAdmin") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnName("LastModificationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnName("LastModifierId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("NickName") |
|||
.HasColumnType("varchar(256) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(256); |
|||
|
|||
b.Property<DateTime?>("SilenceEnd") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("UserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "UserId"); |
|||
|
|||
b.ToTable("AppUserGroupCards"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserMessage", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<string>("Content") |
|||
.IsRequired() |
|||
.HasColumnType("longtext CHARACTER SET utf8mb4") |
|||
.HasMaxLength(1048576); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<long>("MessageId") |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<Guid>("ReceiveUserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<sbyte>("SendState") |
|||
.HasColumnType("tinyint"); |
|||
|
|||
b.Property<string>("SendUserName") |
|||
.IsRequired() |
|||
.HasColumnType("varchar(64) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(64); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<int>("Type") |
|||
.HasColumnType("int"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "ReceiveUserId"); |
|||
|
|||
b.ToTable("AppUserMessages"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserSpecialFocus", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("FocusUserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("UserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "UserId"); |
|||
|
|||
b.ToTable("AppUserSpecialFocuss"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.Notification", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnName("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<DateTime?>("ExpirationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<string>("NotificationCateGory") |
|||
.IsRequired() |
|||
.HasColumnType("varchar(50) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(50); |
|||
|
|||
b.Property<string>("NotificationData") |
|||
.IsRequired() |
|||
.HasColumnType("longtext CHARACTER SET utf8mb4") |
|||
.HasMaxLength(1048576); |
|||
|
|||
b.Property<long>("NotificationId") |
|||
.HasColumnType("bigint"); |
|||
|
|||
b.Property<string>("NotificationName") |
|||
.IsRequired() |
|||
.HasColumnType("varchar(100) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(100); |
|||
|
|||
b.Property<string>("NotificationTypeName") |
|||
.IsRequired() |
|||
.HasColumnType("varchar(512) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(512); |
|||
|
|||
b.Property<sbyte>("Severity") |
|||
.HasColumnType("tinyint"); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
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") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("UserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "UserId", "NotificationId") |
|||
.HasName("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") |
|||
.HasColumnName("CreationTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<string>("NotificationName") |
|||
.IsRequired() |
|||
.HasColumnType("varchar(100) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(100); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<Guid>("UserId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("UserName") |
|||
.IsRequired() |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("varchar(128) CHARACTER SET utf8mb4") |
|||
.HasMaxLength(128) |
|||
.HasDefaultValue("/"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "UserId", "NotificationName") |
|||
.IsUnique() |
|||
.HasName("IX_Tenant_User_Notification_Name"); |
|||
|
|||
b.ToTable("AppUserSubscribes"); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Metadata; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Migrations |
|||
{ |
|||
public partial class AddUserChatFriendEntity : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "AppUserChatFriends", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<long>(nullable: false) |
|||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
|||
CreationTime = table.Column<DateTime>(nullable: false), |
|||
CreatorId = table.Column<Guid>(nullable: true), |
|||
TenantId = table.Column<Guid>(nullable: true), |
|||
UserId = table.Column<Guid>(nullable: false), |
|||
FrientId = table.Column<Guid>(nullable: false), |
|||
Black = table.Column<bool>(nullable: false), |
|||
DontDisturb = table.Column<bool>(nullable: false), |
|||
SpecialFocus = table.Column<bool>(nullable: false), |
|||
RemarkName = table.Column<string>(maxLength: 256, nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AppUserChatFriends", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AppUserChatFriends_TenantId_UserId_FrientId", |
|||
table: "AppUserChatFriends", |
|||
columns: new[] { "TenantId", "UserId", "FrientId" }); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "AppUserChatFriends"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,71 @@ |
|||
import ApiService from './serviceBase' |
|||
import { PagedResultDto, PagedAndSortedResultRequestDto, PagedResultRequestDto } from './types' |
|||
|
|||
const serviceUrl = process.env.VUE_APP_BASE_API |
|||
|
|||
export default class ImApiService { |
|||
public static getMyFriends(payload: MyFriendGetByPaged) { |
|||
let _url = 'api/im/my-friends' |
|||
_url += '?filter=' + payload.filter |
|||
_url += '&sorting=' + payload.sorting |
|||
_url += '&reverse=' + payload.reverse |
|||
_url += '&skipCount=' + payload.skipCount |
|||
_url += '&maxResultCount=' + payload.maxResultCount |
|||
return ApiService.Get<PagedResultDto<UserFriend>>(_url, serviceUrl) |
|||
} |
|||
} |
|||
|
|||
export enum Sex |
|||
{ |
|||
Male, |
|||
Female, |
|||
Other |
|||
} |
|||
|
|||
export class UserCard { |
|||
tenantId?: string |
|||
userId = '' |
|||
userName = '' |
|||
avatarUrl = '' |
|||
nickName = '' |
|||
age = 0 |
|||
sex = Sex.Male |
|||
sign = '' |
|||
description = '' |
|||
birthday?: Date |
|||
} |
|||
|
|||
export class UserFriend extends UserCard { |
|||
friendId = '' |
|||
remarkName = '' |
|||
black = false |
|||
specialFocus = false |
|||
dontDisturb = false |
|||
} |
|||
|
|||
export class MyFriendGetByPaged extends PagedAndSortedResultRequestDto { |
|||
filter = '' |
|||
sorting = 'UserName' |
|||
skipCount = 0 |
|||
reverse = false |
|||
} |
|||
|
|||
export enum MessageType { |
|||
Text = 0, |
|||
Image = 10, |
|||
Link = 20, |
|||
Video = 30 |
|||
} |
|||
|
|||
export class ChatMessage { |
|||
tenantId?: string |
|||
groupId = '' |
|||
messageId = '' |
|||
formUserId = '' |
|||
formUserName = '' |
|||
toUserId = '' |
|||
content = '' |
|||
sendTime = new Date() |
|||
isAnonymous = false |
|||
messageType = MessageType.Text |
|||
} |
|||
@ -0,0 +1,122 @@ |
|||
<template> |
|||
<div> |
|||
<lemon-imui |
|||
v-show="showDialog" |
|||
ref="IMUI" |
|||
:user="currentUser" |
|||
@send="handleSendMessage" |
|||
/> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import EventBusMiXin from '@/mixins/EventBusMiXin' |
|||
import Component, { mixins } from 'vue-class-component' |
|||
|
|||
import { UserModule } from '@/store/modules/user' |
|||
|
|||
import ImApiService, { MyFriendGetByPaged, UserFriend, ChatMessage } from '@/api/instant-message' |
|||
|
|||
import { HubConnection, HubConnectionBuilder, HubConnectionState } from '@microsoft/signalr' |
|||
|
|||
class MyContract { |
|||
id = '' |
|||
displayName = '' |
|||
avatar = '' |
|||
type = '' |
|||
index = 'A' |
|||
unread = 0 |
|||
lastSendTime = 0 |
|||
lastContent = '0' |
|||
} |
|||
|
|||
@Component({ |
|||
name: 'InstantMessage' |
|||
}) |
|||
export default class InstantMessage extends mixins(EventBusMiXin) { |
|||
private showDialog = false |
|||
private dataFilter = new MyFriendGetByPaged() |
|||
private myFriendCount = 0 |
|||
private myFriends = new Array<UserFriend>() |
|||
|
|||
private connection!: HubConnection |
|||
|
|||
get currentUser() { |
|||
return { |
|||
id: UserModule.id, |
|||
displayName: UserModule.userName, |
|||
avatar: '' |
|||
} |
|||
} |
|||
|
|||
mounted() { |
|||
this.subscribe('onShowImDialog', this.onShowImDialog) |
|||
this.handleStartConnection() |
|||
} |
|||
|
|||
destroyed() { |
|||
this.unSubscribe('onShowImDialog') |
|||
} |
|||
|
|||
private handleStartConnection() { |
|||
if (!this.connection) { |
|||
const builder = new HubConnectionBuilder() |
|||
const userToken = UserModule.token.replace('Bearer ', '') |
|||
this.connection = builder |
|||
.withUrl('/signalr-hubs/signalr-hubs/messages', { accessTokenFactory: () => userToken }) |
|||
.withAutomaticReconnect({ nextRetryDelayInMilliseconds: () => 60000 }) |
|||
.build() |
|||
this.connection.onclose(error => { |
|||
console.log('signalr connection has closed, error:') |
|||
console.log(error) |
|||
}) |
|||
} |
|||
if (this.connection.state !== HubConnectionState.Connected) { |
|||
this.connection |
|||
.start() |
|||
.then(() => { |
|||
ImApiService |
|||
.getMyFriends(this.dataFilter) |
|||
.then(res => { |
|||
this.myFriends = res.items |
|||
this.myFriendCount = res.totalCount |
|||
this.handleInitContracts() |
|||
}) |
|||
}) |
|||
} |
|||
} |
|||
|
|||
private handleInitContracts() { |
|||
const myContracts = new Array<MyContract>() |
|||
this.myFriends |
|||
.forEach(friend => { |
|||
const myContract = new MyContract() |
|||
myContract.id = friend.friendId |
|||
myContract.displayName = friend.remarkName ?? friend.userName |
|||
myContracts.push(myContract) |
|||
}) |
|||
const imui = this.$refs.IMUI as any |
|||
imui.initContacts(myContracts) |
|||
} |
|||
|
|||
private onShowImDialog() { |
|||
this.showDialog = !this.showDialog |
|||
} |
|||
|
|||
private handleSendMessage(message: any, next: any, file: any) { |
|||
console.log(message, next, file) |
|||
const chatMessage = new ChatMessage() |
|||
chatMessage.formUserId = message.fromUser.id |
|||
chatMessage.formUserName = message.fromUser.displayName |
|||
chatMessage.toUserId = message.toContactId |
|||
chatMessage.content = message.content |
|||
this.connection |
|||
.invoke('SendMessage', chatMessage) |
|||
.then(() => { |
|||
setTimeout(() => { |
|||
next() |
|||
}, 1000) |
|||
}) |
|||
} |
|||
} |
|||
</script> |
|||
Loading…
Reference in new issue