committed by
GitHub
63 changed files with 2685 additions and 1395 deletions
@ -0,0 +1,33 @@ |
|||||
|
using LINGYUN.Abp.RealTime.Client; |
||||
|
using System; |
||||
|
using System.Linq; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IM.SignalR |
||||
|
{ |
||||
|
public class UserOnlineChecker : IUserOnlineChecker, ITransientDependency |
||||
|
{ |
||||
|
private readonly IOnlineClientManager _onlineClientManager; |
||||
|
|
||||
|
public UserOnlineChecker( |
||||
|
IOnlineClientManager onlineClientManager) |
||||
|
{ |
||||
|
_onlineClientManager = onlineClientManager; |
||||
|
} |
||||
|
|
||||
|
public virtual Task<bool> CheckAsync( |
||||
|
Guid? tenantId, |
||||
|
Guid userId, |
||||
|
CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var onlineClients = _onlineClientManager |
||||
|
.GetAllClients(client => client.UserId.Equals(userId)); |
||||
|
|
||||
|
var userOnlined = onlineClients?.Any() == true; |
||||
|
|
||||
|
return Task.FromResult(userOnlined); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,12 +1,12 @@ |
|||||
namespace LINGYUN.Abp.IM.Group |
namespace LINGYUN.Abp.IM.Groups |
||||
{ |
{ |
||||
public class GroupUserCard : UserCard |
public class GroupUserCard : UserCard |
||||
{ |
{ |
||||
public long GroupId { get; set; } |
public long GroupId { get; set; } |
||||
public bool IsAdmin { get; set; } |
public bool IsAdmin { get; set; } |
||||
public bool IsSuperAdmin { get; set; } |
public bool IsSuperAdmin { get; set; } |
||||
public GroupUserCard() |
public GroupUserCard() |
||||
{ |
{ |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,50 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IM.Groups |
||||
|
{ |
||||
|
public interface IGroupStore |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 获取群组信息
|
||||
|
/// </summary>
|
||||
|
/// <param name="tenantId"></param>
|
||||
|
/// <param name="groupId"></param>
|
||||
|
/// <param name="cancellationToken"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task<Group> GetAsync( |
||||
|
Guid? tenantId, |
||||
|
string groupId, |
||||
|
CancellationToken cancellationToken = default); |
||||
|
/// <summary>
|
||||
|
/// 获取群组数
|
||||
|
/// </summary>
|
||||
|
/// <param name="tenantId"></param>
|
||||
|
/// <param name="filter"></param>
|
||||
|
/// <param name="cancellationToken"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task<int> GetCountAsync( |
||||
|
Guid? tenantId, |
||||
|
string filter = null, |
||||
|
CancellationToken cancellationToken = default); |
||||
|
/// <summary>
|
||||
|
/// 获取群组列表
|
||||
|
/// </summary>
|
||||
|
/// <param name="tenantId"></param>
|
||||
|
/// <param name="filter"></param>
|
||||
|
/// <param name="sorting"></param>
|
||||
|
/// <param name="skipCount"></param>
|
||||
|
/// <param name="maxResultCount"></param>
|
||||
|
/// <param name="cancellationToken"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task<List<Group>> GetListAsync( |
||||
|
Guid? tenantId, |
||||
|
string filter = null, |
||||
|
string sorting = nameof(Group.Name), |
||||
|
int skipCount = 0, |
||||
|
int maxResultCount = 10, |
||||
|
CancellationToken cancellationToken = default); |
||||
|
} |
||||
|
} |
||||
@ -1,13 +1,13 @@ |
|||||
using System; |
using System; |
||||
|
|
||||
namespace LINGYUN.Abp.IM.Group |
namespace LINGYUN.Abp.IM.Groups |
||||
{ |
{ |
||||
public class UserGroup |
public class UserGroup |
||||
{ |
{ |
||||
public Guid? TenantId { get; set; } |
public Guid? TenantId { get; set; } |
||||
public Guid UserId { get; set; } |
public Guid UserId { get; set; } |
||||
public long GroupId { get; set; } |
public long GroupId { get; set; } |
||||
public bool IsAdmin { get; set; } |
public bool IsAdmin { get; set; } |
||||
public bool IsSuperAdmin { get; set; } |
public bool IsSuperAdmin { get; set; } |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
using System; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IM |
||||
|
{ |
||||
|
public interface IUserOnlineChanger |
||||
|
{ |
||||
|
Task ChangeAsync( |
||||
|
Guid? tenantId, |
||||
|
Guid userId, |
||||
|
UserOnlineState state, |
||||
|
CancellationToken cancellationToken = default); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
using System; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IM |
||||
|
{ |
||||
|
public interface IUserOnlineChecker |
||||
|
{ |
||||
|
Task<bool> CheckAsync( |
||||
|
Guid? tenantId, |
||||
|
Guid userId, |
||||
|
CancellationToken cancellationToken = default); |
||||
|
} |
||||
|
} |
||||
@ -1,45 +1,47 @@ |
|||||
using System; |
using System; |
||||
|
|
||||
namespace LINGYUN.Abp.IM |
namespace LINGYUN.Abp.IM |
||||
{ |
{ |
||||
public class UserCard |
public class UserCard |
||||
{ |
{ |
||||
public Guid? TenantId { get; set; } |
public Guid? TenantId { get; set; } |
||||
|
|
||||
public Guid UserId { get; set; } |
public Guid UserId { get; set; } |
||||
|
|
||||
#region 细粒度的用户资料
|
#region 细粒度的用户资料
|
||||
|
|
||||
public string UserName { get; set; } |
public string UserName { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 头像
|
/// 头像
|
||||
/// </summary>
|
/// </summary>
|
||||
public string AvatarUrl { get; set; } |
public string AvatarUrl { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 昵称
|
/// 昵称
|
||||
/// </summary>
|
/// </summary>
|
||||
public string NickName { get; set; } |
public string NickName { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 年龄
|
/// 年龄
|
||||
/// </summary>
|
/// </summary>
|
||||
public int Age { get; set; } |
public int Age { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 性别
|
/// 性别
|
||||
/// </summary>
|
/// </summary>
|
||||
public Sex Sex { get; set; } |
public Sex Sex { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 签名
|
/// 签名
|
||||
/// </summary>
|
/// </summary>
|
||||
public string Sign { get; set; } |
public string Sign { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 说明
|
/// 说明
|
||||
/// </summary>
|
/// </summary>
|
||||
public string Description { get; set; } |
public string Description { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 生日
|
/// 生日
|
||||
/// </summary>
|
/// </summary>
|
||||
public DateTime? Birthday { get; set; } |
public DateTime? Birthday { get; set; } |
||||
|
|
||||
#endregion
|
public bool Online { get; set; } |
||||
} |
|
||||
} |
#endregion
|
||||
|
} |
||||
|
} |
||||
|
|||||
@ -0,0 +1,10 @@ |
|||||
|
namespace LINGYUN.Abp.IM |
||||
|
{ |
||||
|
public enum UserOnlineState |
||||
|
{ |
||||
|
Online, |
||||
|
Offline, |
||||
|
Busy, |
||||
|
Stealth |
||||
|
} |
||||
|
} |
||||
@ -1,65 +1,36 @@ |
|||||
using LINGYUN.Abp.IM.Messages; |
using LINGYUN.Abp.IM.Messages; |
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
using Volo.Abp.Application.Dtos; |
using Volo.Abp.Application.Dtos; |
||||
using Volo.Abp.Application.Services; |
using Volo.Abp.Application.Services; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Chat |
namespace LINGYUN.Abp.MessageService.Chat |
||||
{ |
{ |
||||
public interface IChatAppService : IApplicationService |
public interface IChatAppService : IApplicationService |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 发送消息
|
/// 发送消息
|
||||
/// </summary>
|
/// </summary>
|
||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
/// <returns></returns>
|
||||
Task<ChatMessageSendResultDto> SendMessageAsync(ChatMessage input); |
Task<ChatMessageSendResultDto> SendMessageAsync(ChatMessage input); |
||||
///// <summary>
|
/// <summary>
|
||||
///// 申请加入群组
|
/// 获取群组消息
|
||||
///// </summary>
|
/// </summary>
|
||||
///// <param name="input"></param>
|
/// <param name="input"></param>
|
||||
///// <returns></returns>
|
/// <returns></returns>
|
||||
//Task ApplyJoinGroupAsync(UserJoinGroupDto input);
|
Task<PagedResultDto<ChatMessage>> GetMyGroupMessageAsync(GroupMessageGetByPagedDto input); |
||||
///// <summary>
|
/// <summary>
|
||||
///// 获取我的群组
|
/// 获取我的消息
|
||||
///// </summary>
|
/// </summary>
|
||||
///// <returns></returns>
|
/// <param name="input"></param>
|
||||
//Task<ListResultDto<Group>> GetMyGroupsAsync();
|
/// <returns></returns>
|
||||
///// <summary>
|
Task<PagedResultDto<ChatMessage>> GetMyChatMessageAsync(UserMessageGetByPagedDto input); |
||||
///// 获取群组用户
|
/// <summary>
|
||||
///// </summary>
|
/// 获取我最近的消息
|
||||
///// <param name="input"></param>
|
/// </summary>
|
||||
///// <returns></returns>
|
/// <param name="input"></param>
|
||||
//Task<PagedResultDto<GroupUserCard>> GetGroupUsersAsync(GroupUserGetByPagedDto input);
|
/// <returns></returns>
|
||||
///// <summary>
|
Task<ListResultDto<LastChatMessage>> GetMyLastChatMessageAsync(GetUserLastMessageDto input); |
||||
///// 处理用户群组申请
|
//TOTO: 还应该有获取我的未读消息 获取我的未读群组消息
|
||||
///// </summary>
|
} |
||||
///// <param name="input"></param>
|
} |
||||
///// <returns></returns>
|
|
||||
//Task GroupAcceptUserAsync(GroupAcceptUserDto input);
|
|
||||
///// <summary>
|
|
||||
///// 群组移除用户
|
|
||||
///// </summary>
|
|
||||
///// <param name="input"></param>
|
|
||||
///// <returns></returns>
|
|
||||
//Task GroupRemoveUserAsync(GroupRemoveUserDto input);
|
|
||||
/// <summary>
|
|
||||
/// 获取群组消息
|
|
||||
/// </summary>
|
|
||||
/// <param name="input"></param>
|
|
||||
/// <returns></returns>
|
|
||||
Task<PagedResultDto<ChatMessage>> GetMyGroupMessageAsync(GroupMessageGetByPagedDto input); |
|
||||
/// <summary>
|
|
||||
/// 获取我的消息
|
|
||||
/// </summary>
|
|
||||
/// <param name="input"></param>
|
|
||||
/// <returns></returns>
|
|
||||
Task<PagedResultDto<ChatMessage>> GetMyChatMessageAsync(UserMessageGetByPagedDto input); |
|
||||
/// <summary>
|
|
||||
/// 获取我最近的消息
|
|
||||
/// </summary>
|
|
||||
/// <param name="input"></param>
|
|
||||
/// <returns></returns>
|
|
||||
Task<ListResultDto<LastChatMessage>> GetMyLastChatMessageAsync(GetUserLastMessageDto input); |
|
||||
//TOTO: 还应该有获取我的未读消息 获取我的未读群组消息
|
|
||||
} |
|
||||
} |
|
||||
|
|||||
@ -1,20 +1,23 @@ |
|||||
using LINGYUN.Abp.IM.Contract; |
using LINGYUN.Abp.IM.Contract; |
||||
using System.Threading.Tasks; |
using System; |
||||
using Volo.Abp.Application.Dtos; |
using System.Threading.Tasks; |
||||
using Volo.Abp.Application.Services; |
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Application.Services; |
||||
namespace LINGYUN.Abp.MessageService.Chat |
|
||||
{ |
namespace LINGYUN.Abp.MessageService.Chat |
||||
public interface IMyFriendAppService : IApplicationService |
{ |
||||
{ |
public interface IMyFriendAppService : IApplicationService |
||||
Task<PagedResultDto<UserFriend>> GetListAsync(MyFriendGetByPagedDto input); |
{ |
||||
|
Task<UserFriend> GetAsync(Guid friendId); |
||||
Task<ListResultDto<UserFriend>> GetAllListAsync(GetMyFriendsDto input); |
|
||||
|
Task<PagedResultDto<UserFriend>> GetListAsync(MyFriendGetByPagedDto input); |
||||
Task CreateAsync(MyFriendCreateDto input); |
|
||||
|
Task<ListResultDto<UserFriend>> GetAllListAsync(GetMyFriendsDto input); |
||||
Task DeleteAsync(MyFriendOperationDto input); |
|
||||
|
Task CreateAsync(MyFriendCreateDto input); |
||||
Task AddRequestAsync(MyFriendAddRequestDto input); |
|
||||
} |
Task DeleteAsync(MyFriendOperationDto input); |
||||
} |
|
||||
|
Task AddRequestAsync(MyFriendAddRequestDto input); |
||||
|
} |
||||
|
} |
||||
|
|||||
@ -1,19 +1,19 @@ |
|||||
using System; |
using System; |
||||
using System.ComponentModel.DataAnnotations; |
using System.ComponentModel.DataAnnotations; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Chat |
namespace LINGYUN.Abp.MessageService.Groups |
||||
{ |
{ |
||||
public class GroupAcceptUserDto |
public class GroupAcceptUserDto |
||||
{ |
{ |
||||
[Required] |
[Required] |
||||
public Guid UserId { get; set; } |
public Guid UserId { get; set; } |
||||
|
|
||||
[Required] |
[Required] |
||||
public long GroupId { get; set; } |
public long GroupId { get; set; } |
||||
|
|
||||
public bool AllowAccept { get; set; } = true; |
public bool AllowAccept { get; set; } = true; |
||||
|
|
||||
[StringLength(64)] |
[StringLength(64)] |
||||
public string RejectReason { get; set; } |
public string RejectReason { get; set; } |
||||
} |
} |
||||
} |
} |
||||
@ -1,14 +1,14 @@ |
|||||
using System; |
using System; |
||||
using System.ComponentModel.DataAnnotations; |
using System.ComponentModel.DataAnnotations; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Chat |
namespace LINGYUN.Abp.MessageService.Groups |
||||
{ |
{ |
||||
public class GroupRemoveUserDto |
public class GroupRemoveUserDto |
||||
{ |
{ |
||||
[Required] |
[Required] |
||||
public Guid UserId { get; set; } |
public Guid UserId { get; set; } |
||||
|
|
||||
[Required] |
[Required] |
||||
public long GroupId { get; set; } |
public long GroupId { get; set; } |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Groups |
||||
|
{ |
||||
|
public class GroupSearchInput : PagedAndSortedResultRequestDto |
||||
|
{ |
||||
|
public string Filter { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -1,7 +1,7 @@ |
|||||
using System.ComponentModel.DataAnnotations; |
using System.ComponentModel.DataAnnotations; |
||||
using Volo.Abp.Application.Dtos; |
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Chat |
namespace LINGYUN.Abp.MessageService.Groups |
||||
{ |
{ |
||||
public class GroupUserGetByPagedDto : PagedAndSortedResultRequestDto |
public class GroupUserGetByPagedDto : PagedAndSortedResultRequestDto |
||||
{ |
{ |
||||
@ -1,14 +1,14 @@ |
|||||
using System.ComponentModel.DataAnnotations; |
using System.ComponentModel.DataAnnotations; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Chat |
namespace LINGYUN.Abp.MessageService.Groups |
||||
{ |
{ |
||||
public class UserJoinGroupDto |
public class UserJoinGroupDto |
||||
{ |
{ |
||||
[Required] |
[Required] |
||||
public long GroupId { get; set; } |
public long GroupId { get; set; } |
||||
|
|
||||
[Required] |
[Required] |
||||
[StringLength(100)] |
[StringLength(100)] |
||||
public string JoinInfo { get; set; } |
public string JoinInfo { get; set; } |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
using LINGYUN.Abp.IM.Groups; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Groups |
||||
|
{ |
||||
|
public interface IGroupAppService : IApplicationService |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 搜索群组
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task<PagedResultDto<Group>> SearchAsync(GroupSearchInput input); |
||||
|
/// <summary>
|
||||
|
/// 获取群组信息
|
||||
|
/// </summary>
|
||||
|
/// <param name="groupId"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task<Group> GetAsync(string groupId); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
using LINGYUN.Abp.IM.Groups; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Groups |
||||
|
{ |
||||
|
public interface IUserGroupAppService : IApplicationService |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 申请加入群组
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task ApplyJoinGroupAsync(UserJoinGroupDto input); |
||||
|
/// <summary>
|
||||
|
/// 获取我的群组
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
Task<ListResultDto<Group>> GetMyGroupsAsync(); |
||||
|
/// <summary>
|
||||
|
/// 获取群组用户
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task<PagedResultDto<GroupUserCard>> GetGroupUsersAsync(GroupUserGetByPagedDto input); |
||||
|
/// <summary>
|
||||
|
/// 处理用户群组申请
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task GroupAcceptUserAsync(GroupAcceptUserDto input); |
||||
|
/// <summary>
|
||||
|
/// 群组移除用户
|
||||
|
/// </summary>
|
||||
|
/// <param name="input"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task GroupRemoveUserAsync(GroupRemoveUserDto input); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
using LINGYUN.Abp.MessageService.Localization; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService |
||||
|
{ |
||||
|
public abstract class AbpMessageServiceApplicationServiceBase : ApplicationService |
||||
|
{ |
||||
|
protected AbpMessageServiceApplicationServiceBase() |
||||
|
{ |
||||
|
LocalizationResource = typeof(MessageServiceResource); |
||||
|
ObjectMapperContext = typeof(AbpMessageServiceApplicationModule); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
using LINGYUN.Abp.IM.Groups; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Groups |
||||
|
{ |
||||
|
[AllowAnonymous] |
||||
|
public class GroupAppService : AbpMessageServiceApplicationServiceBase, IGroupAppService |
||||
|
{ |
||||
|
private readonly IGroupStore _groupStore; |
||||
|
|
||||
|
public GroupAppService( |
||||
|
IGroupStore groupStore) |
||||
|
{ |
||||
|
_groupStore = groupStore; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<Group> GetAsync(string groupId) |
||||
|
{ |
||||
|
return await _groupStore.GetAsync(CurrentTenant.Id, groupId); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<PagedResultDto<Group>> SearchAsync(GroupSearchInput input) |
||||
|
{ |
||||
|
var count = await _groupStore.GetCountAsync( |
||||
|
CurrentTenant.Id, |
||||
|
input.Filter); |
||||
|
|
||||
|
var groups = await _groupStore.GetListAsync( |
||||
|
CurrentTenant.Id, |
||||
|
input.Filter, |
||||
|
input.Sorting, |
||||
|
input.SkipCount, |
||||
|
input.MaxResultCount); |
||||
|
|
||||
|
return new PagedResultDto<Group>(count, groups); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,86 @@ |
|||||
|
using LINGYUN.Abp.IM.Groups; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using System; |
||||
|
using System.Collections.Immutable; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Users; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Groups |
||||
|
{ |
||||
|
[Authorize] |
||||
|
public class UserGroupAppService : AbpMessageServiceApplicationServiceBase, IUserGroupAppService |
||||
|
{ |
||||
|
private readonly IUserGroupStore _userGroupStore; |
||||
|
|
||||
|
public UserGroupAppService( |
||||
|
IUserGroupStore userGroupStore) |
||||
|
{ |
||||
|
_userGroupStore = userGroupStore; |
||||
|
} |
||||
|
|
||||
|
public virtual Task ApplyJoinGroupAsync(UserJoinGroupDto input) |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<PagedResultDto<GroupUserCard>> GetGroupUsersAsync(GroupUserGetByPagedDto input) |
||||
|
{ |
||||
|
var groupUserCardCount = await _userGroupStore |
||||
|
.GetMembersCountAsync(CurrentTenant.Id, input.GroupId); |
||||
|
|
||||
|
var groupUserCards = await _userGroupStore.GetMembersAsync( |
||||
|
CurrentTenant.Id, |
||||
|
input.GroupId, |
||||
|
input.Sorting, |
||||
|
input.SkipCount, |
||||
|
input.MaxResultCount); |
||||
|
|
||||
|
return new PagedResultDto<GroupUserCard>(groupUserCardCount, groupUserCards); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<ListResultDto<Group>> GetMyGroupsAsync() |
||||
|
{ |
||||
|
var myGroups = await _userGroupStore.GetUserGroupsAsync(CurrentTenant.Id, CurrentUser.GetId()); |
||||
|
|
||||
|
return new ListResultDto<Group>(myGroups.ToImmutableList()); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task GroupAcceptUserAsync(GroupAcceptUserDto input) |
||||
|
{ |
||||
|
var myGroupCard = await _userGroupStore |
||||
|
.GetUserGroupCardAsync(CurrentTenant.Id, input.GroupId, CurrentUser.GetId()); |
||||
|
if (myGroupCard == null) |
||||
|
{ |
||||
|
// 当前登录用户不再用户组
|
||||
|
throw new UserFriendlyException(""); |
||||
|
} |
||||
|
if (!myGroupCard.IsAdmin) |
||||
|
{ |
||||
|
// 当前登录用户没有加人权限
|
||||
|
throw new UserFriendlyException(""); |
||||
|
} |
||||
|
await _userGroupStore |
||||
|
.AddUserToGroupAsync(CurrentTenant.Id, input.UserId, input.GroupId, CurrentUser.GetId()); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task GroupRemoveUserAsync(GroupRemoveUserDto input) |
||||
|
{ |
||||
|
var myGroupCard = await _userGroupStore |
||||
|
.GetUserGroupCardAsync(CurrentTenant.Id, input.GroupId, CurrentUser.GetId()); |
||||
|
if (myGroupCard == null) |
||||
|
{ |
||||
|
// 当前登录用户不再用户组
|
||||
|
throw new UserFriendlyException(""); |
||||
|
} |
||||
|
if (!myGroupCard.IsAdmin) |
||||
|
{ |
||||
|
// 当前登录用户没有踢人权限
|
||||
|
throw new UserFriendlyException(""); |
||||
|
} |
||||
|
await _userGroupStore |
||||
|
.RemoveUserFormGroupAsync(CurrentTenant.Id, input.UserId, input.GroupId); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,15 +1,17 @@ |
|||||
namespace LINGYUN.Abp.MessageService.Group |
namespace LINGYUN.Abp.MessageService.Groups |
||||
{ |
{ |
||||
public class ChatGroupConsts |
public class ChatGroupConsts |
||||
{ |
{ |
||||
public const int MaxNameLength = 20; |
public const int MaxNameLength = 20; |
||||
|
|
||||
public const int MaxTagLength = 512; |
public const int MaxTagLength = 512; |
||||
|
|
||||
public const int MaxAddressLength = 256; |
public const int MaxAddressLength = 256; |
||||
|
|
||||
public const int MaxNoticeLength = 64; |
public const int MaxNoticeLength = 64; |
||||
|
|
||||
public const int MaxDescriptionLength = 128; |
public const int MaxDescriptionLength = 128; |
||||
} |
|
||||
} |
public const int MaxAvatarUrlLength = 128; |
||||
|
} |
||||
|
} |
||||
@ -1,105 +1,119 @@ |
|||||
using LINGYUN.Abp.IM; |
using LINGYUN.Abp.IM; |
||||
using LINGYUN.Abp.MessageService.Utils; |
using LINGYUN.Abp.MessageService.Utils; |
||||
using System; |
using System; |
||||
using Volo.Abp.Domain.Entities.Auditing; |
using Volo.Abp.Domain.Entities.Auditing; |
||||
using Volo.Abp.MultiTenancy; |
using Volo.Abp.MultiTenancy; |
||||
using Volo.Abp.Timing; |
using Volo.Abp.Timing; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Chat |
namespace LINGYUN.Abp.MessageService.Chat |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 用户卡片
|
/// 用户卡片
|
||||
/// </summary>
|
/// </summary>
|
||||
public class UserChatCard : AuditedAggregateRoot<long>, IMultiTenant |
public class UserChatCard : AuditedAggregateRoot<long>, IMultiTenant |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 租户
|
/// 租户
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual Guid? TenantId { get; protected set; } |
public virtual Guid? TenantId { get; protected set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 用户标识
|
/// 用户标识
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual Guid UserId { get; protected set; } |
public virtual Guid UserId { get; protected set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 用户名
|
/// 用户名
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual string UserName { get; protected set; } |
public virtual string UserName { get; protected set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 性别
|
/// 性别
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual Sex Sex { get; set; } |
public virtual Sex Sex { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 签名
|
/// 签名
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual string Sign { get; set; } |
public virtual string Sign { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 昵称
|
/// 昵称
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual string NickName { get; set; } |
public virtual string NickName { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 说明
|
/// 说明
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual string Description { get; set; } |
public virtual string Description { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 头像地址
|
/// 头像地址
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual string AvatarUrl { get; protected set; } |
public virtual string AvatarUrl { get; protected set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 生日
|
/// 生日
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual DateTime? Birthday { get; protected set; } |
public virtual DateTime? Birthday { get; protected set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 年龄
|
/// 年龄
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual int Age { get; protected set; } |
public virtual int Age { get; protected set; } |
||||
|
|
||||
protected UserChatCard() |
public virtual DateTime? LastOnlineTime { get; protected set; } |
||||
{ |
|
||||
} |
public virtual UserOnlineState State { get; protected set; } |
||||
|
|
||||
public UserChatCard( |
protected UserChatCard() |
||||
Guid userId, |
{ |
||||
string userName, |
} |
||||
Sex sex, |
|
||||
string nickName = null, |
public UserChatCard( |
||||
string avatarUrl = "", |
Guid userId, |
||||
Guid? tenantId = null) |
string userName, |
||||
{ |
Sex sex, |
||||
Sex = sex; |
string nickName = null, |
||||
UserId = userId; |
string avatarUrl = "", |
||||
UserName = userName; |
Guid? tenantId = null) |
||||
NickName = nickName ?? userName; |
{ |
||||
AvatarUrl = avatarUrl; |
Sex = sex; |
||||
TenantId = tenantId; |
UserId = userId; |
||||
} |
UserName = userName; |
||||
|
NickName = nickName ?? userName; |
||||
public void SetBirthday(DateTime birthday, IClock clock) |
AvatarUrl = avatarUrl; |
||||
{ |
TenantId = tenantId; |
||||
Birthday = birthday; |
} |
||||
|
|
||||
Age = DateTimeHelper.CalcAgrByBirthdate(birthday, clock.Now); |
public void SetBirthday(DateTime birthday, IClock clock) |
||||
} |
{ |
||||
|
Birthday = birthday; |
||||
public void SetAvatarUrl(string url) |
|
||||
{ |
Age = DateTimeHelper.CalcAgrByBirthdate(birthday, clock.Now); |
||||
AvatarUrl = url; |
} |
||||
} |
|
||||
|
public void SetAvatarUrl(string url) |
||||
public UserCard ToUserCard() |
{ |
||||
{ |
AvatarUrl = url; |
||||
return new UserCard |
} |
||||
{ |
|
||||
Age = Age, |
public void ChangeState(IClock clock, UserOnlineState state) |
||||
AvatarUrl = AvatarUrl, |
{ |
||||
Birthday = Birthday, |
State = state; |
||||
Description = Description, |
if (State == UserOnlineState.Online) |
||||
NickName = NickName, |
{ |
||||
Sex = Sex, |
LastOnlineTime = clock.Now; |
||||
Sign = Sign, |
} |
||||
UserId = UserId, |
} |
||||
UserName = UserName, |
|
||||
TenantId = TenantId |
public UserCard ToUserCard() |
||||
}; |
{ |
||||
} |
return new UserCard |
||||
} |
{ |
||||
} |
Age = Age, |
||||
|
AvatarUrl = AvatarUrl, |
||||
|
Birthday = Birthday, |
||||
|
Description = Description, |
||||
|
NickName = NickName, |
||||
|
Sex = Sex, |
||||
|
Sign = Sign, |
||||
|
UserId = UserId, |
||||
|
UserName = UserName, |
||||
|
TenantId = TenantId, |
||||
|
Online = State == UserOnlineState.Online, |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|||||
@ -1,31 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Threading; |
|
||||
using System.Threading.Tasks; |
|
||||
using Volo.Abp.Domain.Repositories; |
|
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Group |
|
||||
{ |
|
||||
public interface IGroupRepository : IBasicRepository<ChatGroup, long> |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// 用户是否已被拉黑
|
|
||||
/// </summary>
|
|
||||
/// <param name="id"></param>
|
|
||||
/// <param name="formUserId"></param>
|
|
||||
/// <returns></returns>
|
|
||||
Task<bool> UserHasBlackedAsync( |
|
||||
long id, |
|
||||
Guid formUserId, |
|
||||
CancellationToken cancellationToken = default); |
|
||||
|
|
||||
Task<ChatGroup> FindByIdAsync( |
|
||||
long id, |
|
||||
CancellationToken cancellationToken = default); |
|
||||
|
|
||||
Task<List<UserGroupCard>> GetGroupAdminAsync( |
|
||||
long id, |
|
||||
CancellationToken cancellationToken = default); |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
@ -1,75 +1,79 @@ |
|||||
using System; |
using System; |
||||
using Volo.Abp.Domain.Entities.Auditing; |
using Volo.Abp.Domain.Entities.Auditing; |
||||
using Volo.Abp.MultiTenancy; |
using Volo.Abp.MultiTenancy; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Group |
namespace LINGYUN.Abp.MessageService.Groups |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 聊天群组
|
/// 聊天群组
|
||||
/// </summary>
|
/// </summary>
|
||||
public class ChatGroup : AuditedEntity<long>, IMultiTenant |
public class ChatGroup : AuditedEntity<long>, IMultiTenant |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 租户
|
/// 租户
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual Guid? TenantId { get; protected set; } |
public virtual Guid? TenantId { get; protected set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 群主
|
/// 群主
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual Guid AdminUserId { get; protected set; } |
public virtual Guid AdminUserId { get; protected set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 群组标识
|
/// 群组标识
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual long GroupId { get; protected set; } |
public virtual long GroupId { get; protected set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 群组名称
|
/// 群组名称
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual string Name { get; protected set; } |
public virtual string Name { get; protected set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 群组标记
|
/// 群组标记
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual string Tag { get; protected set; } |
public virtual string Tag { get; protected set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 群组地址
|
/// 群组地址
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual string Address { get; set; } |
public virtual string Address { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 群组公告
|
/// 群组公告
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual string Notice { get; set; } |
public virtual string Notice { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 最大用户数量
|
/// 最大用户数量
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual int MaxUserCount { get; protected set; } |
public virtual int MaxUserCount { get; protected set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 允许匿名聊天
|
/// 允许匿名聊天
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual bool AllowAnonymous { get; set; } |
public virtual bool AllowAnonymous { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 允许发送消息
|
/// 允许发送消息
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual bool AllowSendMessage { get; set; } |
public virtual bool AllowSendMessage { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 群组说明
|
/// 群组说明
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual string Description { get; set; } |
public virtual string Description { get; set; } |
||||
protected ChatGroup() |
/// <summary>
|
||||
{ |
/// 群组头像地址
|
||||
} |
/// </summary>
|
||||
public ChatGroup( |
public virtual string AvatarUrl { get; set; } |
||||
long id, |
protected ChatGroup() |
||||
Guid adminUserId, |
{ |
||||
string name, |
} |
||||
string tag = "", |
public ChatGroup( |
||||
string address = "", |
long id, |
||||
int maxUserCount = 200) |
Guid adminUserId, |
||||
{ |
string name, |
||||
GroupId = id; |
string tag = "", |
||||
AdminUserId = adminUserId; |
string address = "", |
||||
Name = name; |
int maxUserCount = 200) |
||||
Tag = tag; |
{ |
||||
Address = address; |
GroupId = id; |
||||
MaxUserCount = maxUserCount; |
AdminUserId = adminUserId; |
||||
} |
Name = name; |
||||
} |
Tag = tag; |
||||
} |
Address = address; |
||||
|
MaxUserCount = maxUserCount; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,32 +1,32 @@ |
|||||
using System; |
using System; |
||||
using Volo.Abp.Domain.Entities.Auditing; |
using Volo.Abp.Domain.Entities.Auditing; |
||||
using Volo.Abp.MultiTenancy; |
using Volo.Abp.MultiTenancy; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Group |
namespace LINGYUN.Abp.MessageService.Groups |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 用户黑名单
|
/// 用户黑名单
|
||||
/// </summary>
|
/// </summary>
|
||||
public class GroupChatBlack : CreationAuditedEntity<long>, IMultiTenant |
public class GroupChatBlack : CreationAuditedEntity<long>, IMultiTenant |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 租户
|
/// 租户
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual Guid? TenantId { get; protected set; } |
public virtual Guid? TenantId { get; protected set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 群组标识
|
/// 群组标识
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual long GroupId { get; protected set; } |
public virtual long GroupId { get; protected set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 拉黑的用户
|
/// 拉黑的用户
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual Guid ShieldUserId { get; protected set; } |
public virtual Guid ShieldUserId { get; protected set; } |
||||
protected GroupChatBlack() { } |
protected GroupChatBlack() { } |
||||
public GroupChatBlack(long groupId, Guid shieldUserId, Guid? tenantId) |
public GroupChatBlack(long groupId, Guid shieldUserId, Guid? tenantId) |
||||
{ |
{ |
||||
GroupId = groupId; |
GroupId = groupId; |
||||
ShieldUserId = shieldUserId; |
ShieldUserId = shieldUserId; |
||||
TenantId = tenantId; |
TenantId = tenantId; |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -1,25 +1,25 @@ |
|||||
using LINGYUN.Abp.IM.Messages; |
using LINGYUN.Abp.IM.Messages; |
||||
using LINGYUN.Abp.MessageService.Chat; |
using LINGYUN.Abp.MessageService.Chat; |
||||
using System; |
using System; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Group |
namespace LINGYUN.Abp.MessageService.Groups |
||||
{ |
{ |
||||
public class GroupMessage : Message |
public class GroupMessage : Message |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 群组标识
|
/// 群组标识
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual long GroupId { get; protected set; } |
public virtual long GroupId { get; protected set; } |
||||
|
|
||||
protected GroupMessage() { } |
protected GroupMessage() { } |
||||
public GroupMessage(long id, Guid sendUserId, string sendUserName, string content, MessageType type = MessageType.Text) |
public GroupMessage(long id, Guid sendUserId, string sendUserName, string content, MessageType type = MessageType.Text) |
||||
: base(id, sendUserId, sendUserName, content, type) |
: base(id, sendUserId, sendUserName, content, type) |
||||
{ |
{ |
||||
|
|
||||
} |
} |
||||
public void SendToGroup(long groupId) |
public void SendToGroup(long groupId) |
||||
{ |
{ |
||||
GroupId = groupId; |
GroupId = groupId; |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,72 @@ |
|||||
|
using LINGYUN.Abp.IM.Groups; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
using Volo.Abp.ObjectMapping; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Groups |
||||
|
{ |
||||
|
public class GroupStore : IGroupStore, ITransientDependency |
||||
|
{ |
||||
|
private readonly IObjectMapper _objectMapper; |
||||
|
private readonly ICurrentTenant _currentTenant; |
||||
|
private readonly IGroupRepository _groupRepository; |
||||
|
|
||||
|
public GroupStore( |
||||
|
IObjectMapper objectMapper, |
||||
|
ICurrentTenant currentTenant, |
||||
|
IGroupRepository groupRepository) |
||||
|
{ |
||||
|
_objectMapper = objectMapper; |
||||
|
_currentTenant = currentTenant; |
||||
|
_groupRepository = groupRepository; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<Group> GetAsync( |
||||
|
Guid? tenantId, |
||||
|
string groupId, |
||||
|
CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
using (_currentTenant.Change(tenantId)) |
||||
|
{ |
||||
|
var group = await _groupRepository.FindByIdAsync(long.Parse(groupId), cancellationToken); |
||||
|
return _objectMapper.Map<ChatGroup, Group>(group); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<int> GetCountAsync( |
||||
|
Guid? tenantId, |
||||
|
string filter = null, |
||||
|
CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
using (_currentTenant.Change(tenantId)) |
||||
|
{ |
||||
|
return await _groupRepository.GetCountAsync(filter, cancellationToken); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<List<Group>> GetListAsync( |
||||
|
Guid? tenantId, |
||||
|
string filter = null, |
||||
|
string sorting = nameof(Group.Name), |
||||
|
int skipCount = 0, |
||||
|
int maxResultCount = 10, |
||||
|
CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
using (_currentTenant.Change(tenantId)) |
||||
|
{ |
||||
|
var groups = await _groupRepository.GetListAsync( |
||||
|
filter, |
||||
|
sorting, |
||||
|
skipCount, |
||||
|
maxResultCount, |
||||
|
cancellationToken); |
||||
|
|
||||
|
return _objectMapper.Map<List<ChatGroup>, List<Group>>(groups); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,55 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Groups |
||||
|
{ |
||||
|
public interface IGroupRepository : IBasicRepository<ChatGroup, long> |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 用户是否已被拉黑
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <param name="formUserId"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task<bool> UserHasBlackedAsync( |
||||
|
long id, |
||||
|
Guid formUserId, |
||||
|
CancellationToken cancellationToken = default); |
||||
|
|
||||
|
Task<ChatGroup> FindByIdAsync( |
||||
|
long id, |
||||
|
CancellationToken cancellationToken = default); |
||||
|
|
||||
|
Task<List<UserGroupCard>> GetGroupAdminAsync( |
||||
|
long id, |
||||
|
CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 获取群组数
|
||||
|
/// </summary>
|
||||
|
/// <param name="filter"></param>
|
||||
|
/// <param name="cancellationToken"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task<int> GetCountAsync( |
||||
|
string filter = null, |
||||
|
CancellationToken cancellationToken = default); |
||||
|
/// <summary>
|
||||
|
/// 获取群组列表
|
||||
|
/// </summary>
|
||||
|
/// <param name="filter"></param>
|
||||
|
/// <param name="sorting"></param>
|
||||
|
/// <param name="skipCount"></param>
|
||||
|
/// <param name="maxResultCount"></param>
|
||||
|
/// <param name="cancellationToken"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task<List<ChatGroup>> GetListAsync( |
||||
|
string filter = null, |
||||
|
string sorting = nameof(ChatGroup.Name), |
||||
|
int skipCount = 0, |
||||
|
int maxResultCount = 10, |
||||
|
CancellationToken cancellationToken = default); |
||||
|
} |
||||
|
} |
||||
@ -1,19 +1,19 @@ |
|||||
using System.Threading; |
using System.Threading; |
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
using Volo.Abp; |
using Volo.Abp; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Group |
namespace LINGYUN.Abp.MessageService.Groups |
||||
{ |
{ |
||||
public static class IGroupRepositoryExtensions |
public static class IGroupRepositoryExtensions |
||||
{ |
{ |
||||
public static async Task<ChatGroup> GetByIdAsync( |
public static async Task<ChatGroup> GetByIdAsync( |
||||
this IGroupRepository repository, |
this IGroupRepository repository, |
||||
long id, |
long id, |
||||
CancellationToken cancellationToken = default) |
CancellationToken cancellationToken = default) |
||||
{ |
{ |
||||
var group = await repository.FindByIdAsync(id, cancellationToken); |
var group = await repository.FindByIdAsync(id, cancellationToken); |
||||
|
|
||||
return group ?? throw new BusinessException(MessageServiceErrorCodes.GroupNotFount); |
return group ?? throw new BusinessException(MessageServiceErrorCodes.GroupNotFount); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -1,27 +1,27 @@ |
|||||
using System; |
using System; |
||||
using Volo.Abp.Domain.Entities.Auditing; |
using Volo.Abp.Domain.Entities.Auditing; |
||||
using Volo.Abp.MultiTenancy; |
using Volo.Abp.MultiTenancy; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Group |
namespace LINGYUN.Abp.MessageService.Groups |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 用户群组
|
/// 用户群组
|
||||
/// </summary>
|
/// </summary>
|
||||
public class UserChatGroup : CreationAuditedEntity<long>, IMultiTenant |
public class UserChatGroup : CreationAuditedEntity<long>, IMultiTenant |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 租户
|
/// 租户
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual Guid? TenantId { get; protected set; } |
public virtual Guid? TenantId { get; protected set; } |
||||
public virtual Guid UserId { get; protected set; } |
public virtual Guid UserId { get; protected set; } |
||||
public virtual long GroupId { get; protected set; } |
public virtual long GroupId { get; protected set; } |
||||
protected UserChatGroup() { } |
protected UserChatGroup() { } |
||||
public UserChatGroup(long groupId, Guid userId, Guid acceptUserId, Guid? tenantId = null) |
public UserChatGroup(long groupId, Guid userId, Guid acceptUserId, Guid? tenantId = null) |
||||
{ |
{ |
||||
UserId = userId; |
UserId = userId; |
||||
GroupId = groupId; |
GroupId = groupId; |
||||
CreatorId = acceptUserId; |
CreatorId = acceptUserId; |
||||
TenantId = tenantId; |
TenantId = tenantId; |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -1,74 +1,74 @@ |
|||||
using System; |
using System; |
||||
using Volo.Abp.Domain.Entities.Auditing; |
using Volo.Abp.Domain.Entities.Auditing; |
||||
using Volo.Abp.MultiTenancy; |
using Volo.Abp.MultiTenancy; |
||||
using Volo.Abp.Timing; |
using Volo.Abp.Timing; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Group |
namespace LINGYUN.Abp.MessageService.Groups |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 用户群组卡片
|
/// 用户群组卡片
|
||||
/// </summary>
|
/// </summary>
|
||||
public class UserGroupCard : AuditedAggregateRoot<long>, IMultiTenant |
public class UserGroupCard : AuditedAggregateRoot<long>, IMultiTenant |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 租户
|
/// 租户
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual Guid? TenantId { get; protected set; } |
public virtual Guid? TenantId { get; protected set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 用户标识
|
/// 用户标识
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual Guid UserId { get; protected set; } |
public virtual Guid UserId { get; protected set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 昵称
|
/// 昵称
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual string NickName { get; set; } |
public virtual string NickName { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 是否管理员
|
/// 是否管理员
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual bool IsAdmin { get; protected set; } |
public virtual bool IsAdmin { get; protected set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 禁言期止
|
/// 禁言期止
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual DateTime? SilenceEnd { get; protected set; } |
public virtual DateTime? SilenceEnd { get; protected set; } |
||||
protected UserGroupCard() |
protected UserGroupCard() |
||||
{ |
{ |
||||
} |
} |
||||
public UserGroupCard( |
public UserGroupCard( |
||||
Guid userId, |
Guid userId, |
||||
string nickName = "", |
string nickName = "", |
||||
bool isAdmin = false, |
bool isAdmin = false, |
||||
DateTime? silenceEnd = null, |
DateTime? silenceEnd = null, |
||||
Guid? tenantId = null) |
Guid? tenantId = null) |
||||
{ |
{ |
||||
UserId = userId; |
UserId = userId; |
||||
NickName = nickName; |
NickName = nickName; |
||||
IsAdmin = isAdmin; |
IsAdmin = isAdmin; |
||||
SilenceEnd = silenceEnd; |
SilenceEnd = silenceEnd; |
||||
TenantId = tenantId; |
TenantId = tenantId; |
||||
} |
} |
||||
/// <summary>
|
/// <summary>
|
||||
/// 设置管理员
|
/// 设置管理员
|
||||
/// </summary>
|
/// </summary>
|
||||
/// <param name="admin"></param>
|
/// <param name="admin"></param>
|
||||
public void SetAdmin(bool admin) |
public void SetAdmin(bool admin) |
||||
{ |
{ |
||||
IsAdmin = admin; |
IsAdmin = admin; |
||||
} |
} |
||||
/// <summary>
|
/// <summary>
|
||||
/// 禁言
|
/// 禁言
|
||||
/// </summary>
|
/// </summary>
|
||||
/// <param name="clock"></param>
|
/// <param name="clock"></param>
|
||||
/// <param name="seconds"></param>
|
/// <param name="seconds"></param>
|
||||
public void Silence(IClock clock, double seconds) |
public void Silence(IClock clock, double seconds) |
||||
{ |
{ |
||||
SilenceEnd = clock.Now.AddSeconds(seconds); |
SilenceEnd = clock.Now.AddSeconds(seconds); |
||||
} |
} |
||||
/// <summary>
|
/// <summary>
|
||||
/// 解除禁言
|
/// 解除禁言
|
||||
/// </summary>
|
/// </summary>
|
||||
public void UnSilence() |
public void UnSilence() |
||||
{ |
{ |
||||
SilenceEnd = null; |
SilenceEnd = null; |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -1,77 +1,81 @@ |
|||||
using AutoMapper; |
using AutoMapper; |
||||
using LINGYUN.Abp.IM.Messages; |
using LINGYUN.Abp.IM.Groups; |
||||
using LINGYUN.Abp.MessageService.Chat; |
using LINGYUN.Abp.IM.Messages; |
||||
using LINGYUN.Abp.MessageService.Group; |
using LINGYUN.Abp.MessageService.Chat; |
||||
using LINGYUN.Abp.MessageService.Notifications; |
using LINGYUN.Abp.MessageService.Groups; |
||||
using LINGYUN.Abp.MessageService.Subscriptions; |
using LINGYUN.Abp.MessageService.Notifications; |
||||
using LINGYUN.Abp.Notifications; |
using LINGYUN.Abp.MessageService.Subscriptions; |
||||
using Newtonsoft.Json; |
using LINGYUN.Abp.Notifications; |
||||
using System; |
using Volo.Abp.AutoMapper; |
||||
using Volo.Abp.AutoMapper; |
using Volo.Abp.Data; |
||||
using Volo.Abp.Data; |
|
||||
|
namespace LINGYUN.Abp.MessageService.Mapper |
||||
namespace LINGYUN.Abp.MessageService.Mapper |
{ |
||||
{ |
public class MessageServiceDomainAutoMapperProfile : Profile |
||||
public class MessageServiceDomainAutoMapperProfile : Profile |
{ |
||||
{ |
public MessageServiceDomainAutoMapperProfile() |
||||
public MessageServiceDomainAutoMapperProfile() |
{ |
||||
{ |
//CreateMap<Notification, NotificationInfo>()
|
||||
//CreateMap<Notification, NotificationInfo>()
|
// .ForMember(dto => dto.Id, map => map.MapFrom(src => src.NotificationId))
|
||||
// .ForMember(dto => dto.Id, map => map.MapFrom(src => src.NotificationId))
|
// .ForMember(dto => dto.Name, map => map.MapFrom(src => src.NotificationName))
|
||||
// .ForMember(dto => dto.Name, map => map.MapFrom(src => src.NotificationName))
|
// .ForMember(dto => dto.Lifetime, map => map.Ignore())
|
||||
// .ForMember(dto => dto.Lifetime, map => map.Ignore())
|
// .ForMember(dto => dto.Type, map => map.MapFrom(src => src.Type))
|
||||
// .ForMember(dto => dto.Type, map => map.MapFrom(src => src.Type))
|
// .ForMember(dto => dto.Severity, map => map.MapFrom(src => src.Severity))
|
||||
// .ForMember(dto => dto.Severity, map => map.MapFrom(src => src.Severity))
|
// .ForMember(dto => dto.Data, map => map.MapFrom((src, nfi) =>
|
||||
// .ForMember(dto => dto.Data, map => map.MapFrom((src, nfi) =>
|
// {
|
||||
// {
|
// var dataType = Type.GetType(src.NotificationTypeName);
|
||||
// var dataType = Type.GetType(src.NotificationTypeName);
|
// var data = JsonConvert.DeserializeObject(src.NotificationData, dataType);
|
||||
// var data = JsonConvert.DeserializeObject(src.NotificationData, dataType);
|
// if(data != null && data is NotificationData notificationData)
|
||||
// if(data != null && data is NotificationData notificationData)
|
// {
|
||||
// {
|
// if (notificationData.NeedLocalizer())
|
||||
// if (notificationData.NeedLocalizer())
|
// {
|
||||
// {
|
// var title = JsonConvert.DeserializeObject<LocalizableStringInfo>(notificationData.TryGetData("title").ToString());
|
||||
// var title = JsonConvert.DeserializeObject<LocalizableStringInfo>(notificationData.TryGetData("title").ToString());
|
// var message = JsonConvert.DeserializeObject<LocalizableStringInfo>(notificationData.TryGetData("message").ToString());
|
||||
// var message = JsonConvert.DeserializeObject<LocalizableStringInfo>(notificationData.TryGetData("message").ToString());
|
// notificationData.TrySetData("title", title);
|
||||
// notificationData.TrySetData("title", title);
|
// notificationData.TrySetData("message", message);
|
||||
// notificationData.TrySetData("message", message);
|
// }
|
||||
// }
|
// return notificationData;
|
||||
// return notificationData;
|
// }
|
||||
// }
|
// return new NotificationData();
|
||||
// return new NotificationData();
|
// }));
|
||||
// }));
|
|
||||
|
CreateMap<Notification, NotificationInfo>() |
||||
CreateMap<Notification, NotificationInfo>() |
.ConvertUsing<NotificationTypeConverter>(); |
||||
.ConvertUsing<NotificationTypeConverter>(); |
|
||||
|
CreateMap<UserSubscribe, NotificationSubscriptionInfo>(); |
||||
CreateMap<UserSubscribe, NotificationSubscriptionInfo>(); |
|
||||
|
CreateMessageMap<GroupMessage, ChatMessage>() |
||||
CreateMessageMap<GroupMessage, ChatMessage>() |
.ForMember(dto => dto.Content, map => map.MapFrom(src => src.Content)) |
||||
.ForMember(dto => dto.Content, map => map.MapFrom(src => src.Content)) |
.ForMember(dto => dto.GroupId, map => map.MapFrom(src => src.GroupId.ToString())) |
||||
.ForMember(dto => dto.GroupId, map => map.MapFrom(src => src.GroupId.ToString())) |
.Ignore(dto => dto.ToUserId); |
||||
.Ignore(dto => dto.ToUserId); |
|
||||
|
CreateMessageMap<UserMessage, ChatMessage>() |
||||
CreateMessageMap<UserMessage, ChatMessage>() |
.ForMember(dto => dto.ToUserId, map => map.MapFrom(src => src.ReceiveUserId)) |
||||
.ForMember(dto => dto.ToUserId, map => map.MapFrom(src => src.ReceiveUserId)) |
.Ignore(dto => dto.GroupId); |
||||
.Ignore(dto => dto.GroupId); |
|
||||
|
CreateMessageMap<UserMessage, LastChatMessage>() |
||||
CreateMessageMap<UserMessage, LastChatMessage>() |
.ForMember(dto => dto.ToUserId, map => map.MapFrom(src => src.ReceiveUserId)) |
||||
.ForMember(dto => dto.ToUserId, map => map.MapFrom(src => src.ReceiveUserId)) |
.Ignore(dto => dto.GroupId); |
||||
.Ignore(dto => dto.GroupId); |
|
||||
} |
CreateMap<ChatGroup, Group>() |
||||
|
.ForMember(g => g.Id, map => map.MapFrom(src => src.GroupId.ToString())) |
||||
protected IMappingExpression<TSource, TDestination> CreateMessageMap<TSource, TDestination>() |
.ForMember(g => g.MaxUserLength, map => map.MapFrom(src => src.MaxUserCount)) |
||||
where TSource : Message |
.Ignore(g => g.GroupUserCount); |
||||
where TDestination : ChatMessage |
} |
||||
{ |
|
||||
return CreateMap<TSource, TDestination>() |
protected IMappingExpression<TSource, TDestination> CreateMessageMap<TSource, TDestination>() |
||||
.ForMember(dto => dto.Content, map => map.MapFrom(src => src.Content)) |
where TSource : Message |
||||
.ForMember(dto => dto.MessageId, map => map.MapFrom(src => src.MessageId.ToString())) |
where TDestination : ChatMessage |
||||
.ForMember(dto => dto.FormUserId, map => map.MapFrom(src => src.CreatorId)) |
{ |
||||
.ForMember(dto => dto.FormUserName, map => map.MapFrom(src => src.SendUserName)) |
return CreateMap<TSource, TDestination>() |
||||
.ForMember(dto => dto.SendTime, map => map.MapFrom(src => src.CreationTime)) |
.ForMember(dto => dto.Content, map => map.MapFrom(src => src.Content)) |
||||
.ForMember(dto => dto.MessageType, map => map.MapFrom(src => src.Type)) |
.ForMember(dto => dto.MessageId, map => map.MapFrom(src => src.MessageId.ToString())) |
||||
.ForMember(dto => dto.IsAnonymous, map => map.MapFrom(src => src.GetProperty(nameof(ChatMessage.IsAnonymous), false))) |
.ForMember(dto => dto.FormUserId, map => map.MapFrom(src => src.CreatorId)) |
||||
.MapExtraProperties(); |
.ForMember(dto => dto.FormUserName, map => map.MapFrom(src => src.SendUserName)) |
||||
} |
.ForMember(dto => dto.SendTime, map => map.MapFrom(src => src.CreationTime)) |
||||
} |
.ForMember(dto => dto.MessageType, map => map.MapFrom(src => src.Type)) |
||||
} |
.ForMember(dto => dto.IsAnonymous, map => map.MapFrom(src => src.GetProperty(nameof(ChatMessage.IsAnonymous), false))) |
||||
|
.MapExtraProperties(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|||||
@ -1,35 +1,35 @@ |
|||||
using LINGYUN.Abp.MessageService.Chat; |
using LINGYUN.Abp.MessageService.Chat; |
||||
using LINGYUN.Abp.MessageService.Group; |
using LINGYUN.Abp.MessageService.Groups; |
||||
using LINGYUN.Abp.MessageService.Notifications; |
using LINGYUN.Abp.MessageService.Notifications; |
||||
using LINGYUN.Abp.MessageService.Subscriptions; |
using LINGYUN.Abp.MessageService.Subscriptions; |
||||
using Microsoft.Extensions.DependencyInjection; |
using Microsoft.Extensions.DependencyInjection; |
||||
using Volo.Abp.EntityFrameworkCore; |
using Volo.Abp.EntityFrameworkCore; |
||||
using Volo.Abp.Modularity; |
using Volo.Abp.Modularity; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.EntityFrameworkCore |
namespace LINGYUN.Abp.MessageService.EntityFrameworkCore |
||||
{ |
{ |
||||
[DependsOn( |
[DependsOn( |
||||
typeof(AbpMessageServiceDomainModule), |
typeof(AbpMessageServiceDomainModule), |
||||
typeof(AbpEntityFrameworkCoreModule))] |
typeof(AbpEntityFrameworkCoreModule))] |
||||
public class AbpMessageServiceEntityFrameworkCoreModule : AbpModule |
public class AbpMessageServiceEntityFrameworkCoreModule : AbpModule |
||||
{ |
{ |
||||
public override void ConfigureServices(ServiceConfigurationContext context) |
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
{ |
{ |
||||
context.Services.AddAbpDbContext<MessageServiceDbContext>(options => |
context.Services.AddAbpDbContext<MessageServiceDbContext>(options => |
||||
{ |
{ |
||||
options.AddRepository<Notification, EfCoreNotificationRepository>(); |
options.AddRepository<Notification, EfCoreNotificationRepository>(); |
||||
options.AddRepository<UserNotification, EfCoreUserNotificationRepository>(); |
options.AddRepository<UserNotification, EfCoreUserNotificationRepository>(); |
||||
options.AddRepository<UserSubscribe, EfCoreUserSubscribeRepository>(); |
options.AddRepository<UserSubscribe, EfCoreUserSubscribeRepository>(); |
||||
|
|
||||
options.AddRepository<ChatGroup, EfCoreGroupRepository>(); |
options.AddRepository<ChatGroup, EfCoreGroupRepository>(); |
||||
options.AddRepository<UserChatGroup, EfCoreUserChatGroupRepository>(); |
options.AddRepository<UserChatGroup, EfCoreUserChatGroupRepository>(); |
||||
options.AddRepository<UserChatCard, EfCoreUserChatCardRepository>(); |
options.AddRepository<UserChatCard, EfCoreUserChatCardRepository>(); |
||||
options.AddRepository<UserChatSetting, EfCoreUserChatSettingRepository>(); |
options.AddRepository<UserChatSetting, EfCoreUserChatSettingRepository>(); |
||||
|
|
||||
options.AddRepository<UserChatFriend, EfCoreUserChatFriendRepository>(); |
options.AddRepository<UserChatFriend, EfCoreUserChatFriendRepository>(); |
||||
|
|
||||
options.AddDefaultRepositories(includeAllEntities: true); |
options.AddDefaultRepositories(includeAllEntities: true); |
||||
}); |
}); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,15 +1,15 @@ |
|||||
using LINGYUN.Abp.MessageService.Chat; |
using LINGYUN.Abp.MessageService.Chat; |
||||
using LINGYUN.Abp.MessageService.Group; |
using LINGYUN.Abp.MessageService.Groups; |
||||
using Microsoft.EntityFrameworkCore; |
using Microsoft.EntityFrameworkCore; |
||||
using Volo.Abp.Data; |
using Volo.Abp.Data; |
||||
using Volo.Abp.EntityFrameworkCore; |
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.EntityFrameworkCore |
namespace LINGYUN.Abp.MessageService.EntityFrameworkCore |
||||
{ |
{ |
||||
[ConnectionStringName(AbpMessageServiceDbProperties.ConnectionStringName)] |
[ConnectionStringName(AbpMessageServiceDbProperties.ConnectionStringName)] |
||||
public interface IMessageServiceDbContext : IEfCoreDbContext |
public interface IMessageServiceDbContext : IEfCoreDbContext |
||||
{ |
{ |
||||
DbSet<UserChatCard> UserChatCards { get; set; } |
DbSet<UserChatCard> UserChatCards { get; set; } |
||||
DbSet<UserGroupCard> UserGroupCards { get; set; } |
DbSet<UserGroupCard> UserGroupCards { get; set; } |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,30 +1,30 @@ |
|||||
using LINGYUN.Abp.MessageService.Chat; |
using LINGYUN.Abp.MessageService.Chat; |
||||
using LINGYUN.Abp.MessageService.Group; |
using LINGYUN.Abp.MessageService.Groups; |
||||
using Microsoft.EntityFrameworkCore; |
using Microsoft.EntityFrameworkCore; |
||||
using Volo.Abp.Data; |
using Volo.Abp.Data; |
||||
using Volo.Abp.EntityFrameworkCore; |
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.EntityFrameworkCore |
namespace LINGYUN.Abp.MessageService.EntityFrameworkCore |
||||
{ |
{ |
||||
[ConnectionStringName(AbpMessageServiceDbProperties.ConnectionStringName)] |
[ConnectionStringName(AbpMessageServiceDbProperties.ConnectionStringName)] |
||||
public class MessageServiceDbContext : AbpDbContext<MessageServiceDbContext>, IMessageServiceDbContext |
public class MessageServiceDbContext : AbpDbContext<MessageServiceDbContext>, IMessageServiceDbContext |
||||
{ |
{ |
||||
public DbSet<UserChatCard> UserChatCards { get; set; } |
public DbSet<UserChatCard> UserChatCards { get; set; } |
||||
public DbSet<UserGroupCard> UserGroupCards { get; set; } |
public DbSet<UserGroupCard> UserGroupCards { get; set; } |
||||
|
|
||||
public MessageServiceDbContext(DbContextOptions<MessageServiceDbContext> options) |
public MessageServiceDbContext(DbContextOptions<MessageServiceDbContext> options) |
||||
: base(options) |
: base(options) |
||||
{ |
{ |
||||
} |
} |
||||
protected override void OnModelCreating(ModelBuilder modelBuilder) |
protected override void OnModelCreating(ModelBuilder modelBuilder) |
||||
{ |
{ |
||||
modelBuilder.ConfigureMessageService(options => |
modelBuilder.ConfigureMessageService(options => |
||||
{ |
{ |
||||
options.TablePrefix = AbpMessageServiceDbProperties.DefaultTablePrefix; |
options.TablePrefix = AbpMessageServiceDbProperties.DefaultTablePrefix; |
||||
options.Schema = AbpMessageServiceDbProperties.DefaultSchema; |
options.Schema = AbpMessageServiceDbProperties.DefaultSchema; |
||||
}); |
}); |
||||
|
|
||||
base.OnModelCreating(modelBuilder); |
base.OnModelCreating(modelBuilder); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,190 +1,191 @@ |
|||||
using LINGYUN.Abp.MessageService.Chat; |
using LINGYUN.Abp.MessageService.Chat; |
||||
using LINGYUN.Abp.MessageService.Group; |
using LINGYUN.Abp.MessageService.Groups; |
||||
using LINGYUN.Abp.MessageService.Notifications; |
using LINGYUN.Abp.MessageService.Notifications; |
||||
using LINGYUN.Abp.MessageService.Subscriptions; |
using LINGYUN.Abp.MessageService.Subscriptions; |
||||
using Microsoft.EntityFrameworkCore; |
using Microsoft.EntityFrameworkCore; |
||||
using System; |
using System; |
||||
using Volo.Abp; |
using Volo.Abp; |
||||
using Volo.Abp.EntityFrameworkCore.Modeling; |
using Volo.Abp.EntityFrameworkCore.Modeling; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.EntityFrameworkCore |
namespace LINGYUN.Abp.MessageService.EntityFrameworkCore |
||||
{ |
{ |
||||
public static class MessageServiceDbContextModelCreatingExtensions |
public static class MessageServiceDbContextModelCreatingExtensions |
||||
{ |
{ |
||||
public static void ConfigureMessageService( |
public static void ConfigureMessageService( |
||||
this ModelBuilder builder, |
this ModelBuilder builder, |
||||
Action<MessageServiceModelBuilderConfigurationOptions> optionsAction = null) |
Action<MessageServiceModelBuilderConfigurationOptions> optionsAction = null) |
||||
{ |
{ |
||||
Check.NotNull(builder, nameof(builder)); |
Check.NotNull(builder, nameof(builder)); |
||||
|
|
||||
var options = new MessageServiceModelBuilderConfigurationOptions(); |
var options = new MessageServiceModelBuilderConfigurationOptions(); |
||||
|
|
||||
optionsAction?.Invoke(options); |
optionsAction?.Invoke(options); |
||||
|
|
||||
builder.Entity<Notification>(b => |
builder.Entity<Notification>(b => |
||||
{ |
{ |
||||
b.ToTable(options.TablePrefix + "Notifications", options.Schema); |
b.ToTable(options.TablePrefix + "Notifications", options.Schema); |
||||
|
|
||||
b.Property(p => p.NotificationName).HasMaxLength(NotificationConsts.MaxNameLength).IsRequired(); |
b.Property(p => p.NotificationName).HasMaxLength(NotificationConsts.MaxNameLength).IsRequired(); |
||||
b.Property(p => p.NotificationTypeName).HasMaxLength(NotificationConsts.MaxTypeNameLength).IsRequired(); |
b.Property(p => p.NotificationTypeName).HasMaxLength(NotificationConsts.MaxTypeNameLength).IsRequired(); |
||||
b.Property(p => p.NotificationData).HasMaxLength(NotificationConsts.MaxDataLength).IsRequired(); |
b.Property(p => p.NotificationData).HasMaxLength(NotificationConsts.MaxDataLength).IsRequired(); |
||||
|
|
||||
b.ConfigureByConvention(); |
b.ConfigureByConvention(); |
||||
|
|
||||
b.HasIndex(p => new { p.TenantId, p.NotificationName }); |
b.HasIndex(p => new { p.TenantId, p.NotificationName }); |
||||
}); |
}); |
||||
|
|
||||
builder.Entity<UserNotification>(b => |
builder.Entity<UserNotification>(b => |
||||
{ |
{ |
||||
b.ToTable(options.TablePrefix + "UserNotifications", options.Schema); |
b.ToTable(options.TablePrefix + "UserNotifications", options.Schema); |
||||
|
|
||||
b.ConfigureByConvention(); |
b.ConfigureByConvention(); |
||||
|
|
||||
b.HasIndex(p => new { p.TenantId, p.UserId, p.NotificationId }) |
b.HasIndex(p => new { p.TenantId, p.UserId, p.NotificationId }) |
||||
.HasName("IX_Tenant_User_Notification_Id"); |
.HasDatabaseName("IX_Tenant_User_Notification_Id"); |
||||
}); |
}); |
||||
|
|
||||
builder.Entity<UserSubscribe>(b => |
builder.Entity<UserSubscribe>(b => |
||||
{ |
{ |
||||
b.ToTable(options.TablePrefix + "UserSubscribes", options.Schema); |
b.ToTable(options.TablePrefix + "UserSubscribes", options.Schema); |
||||
|
|
||||
b.Property(p => p.NotificationName).HasMaxLength(SubscribeConsts.MaxNotificationNameLength).IsRequired(); |
b.Property(p => p.NotificationName).HasMaxLength(SubscribeConsts.MaxNotificationNameLength).IsRequired(); |
||||
b.Property(p => p.UserName) |
b.Property(p => p.UserName) |
||||
.HasMaxLength(SubscribeConsts.MaxUserNameLength) |
.HasMaxLength(SubscribeConsts.MaxUserNameLength) |
||||
.HasDefaultValue("/")// 不是必须的
|
.HasDefaultValue("/")// 不是必须的
|
||||
.IsRequired(); |
.IsRequired(); |
||||
|
|
||||
b.ConfigureByConvention(); |
b.ConfigureByConvention(); |
||||
|
|
||||
b.HasIndex(p => new { p.TenantId, p.UserId, p.NotificationName }) |
b.HasIndex(p => new { p.TenantId, p.UserId, p.NotificationName }) |
||||
.HasName("IX_Tenant_User_Notification_Name") |
.HasDatabaseName("IX_Tenant_User_Notification_Name") |
||||
.IsUnique(); |
.IsUnique(); |
||||
}); |
}); |
||||
|
|
||||
builder.Entity<UserMessage>(b => |
builder.Entity<UserMessage>(b => |
||||
{ |
{ |
||||
b.ToTable(options.TablePrefix + "UserMessages", options.Schema); |
b.ToTable(options.TablePrefix + "UserMessages", options.Schema); |
||||
|
|
||||
b.Property(p => p.SendUserName).HasMaxLength(MessageConsts.MaxSendUserNameLength).IsRequired(); |
b.Property(p => p.SendUserName).HasMaxLength(MessageConsts.MaxSendUserNameLength).IsRequired(); |
||||
b.Property(p => p.Content).HasMaxLength(MessageConsts.MaxContentLength).IsRequired(); |
b.Property(p => p.Content).HasMaxLength(MessageConsts.MaxContentLength).IsRequired(); |
||||
|
|
||||
b.ConfigureByConvention(); |
b.ConfigureByConvention(); |
||||
|
|
||||
b.HasIndex(p => new { p.TenantId, p.ReceiveUserId }); |
b.HasIndex(p => new { p.TenantId, p.ReceiveUserId }); |
||||
}); |
}); |
||||
|
|
||||
builder.Entity<GroupMessage>(b => |
builder.Entity<GroupMessage>(b => |
||||
{ |
{ |
||||
b.ToTable(options.TablePrefix + "GroupMessages", options.Schema); |
b.ToTable(options.TablePrefix + "GroupMessages", options.Schema); |
||||
|
|
||||
b.Property(p => p.SendUserName).HasMaxLength(MessageConsts.MaxSendUserNameLength).IsRequired(); |
b.Property(p => p.SendUserName).HasMaxLength(MessageConsts.MaxSendUserNameLength).IsRequired(); |
||||
b.Property(p => p.Content).HasMaxLength(MessageConsts.MaxContentLength).IsRequired(); |
b.Property(p => p.Content).HasMaxLength(MessageConsts.MaxContentLength).IsRequired(); |
||||
|
|
||||
b.ConfigureByConvention(); |
b.ConfigureByConvention(); |
||||
|
|
||||
b.HasIndex(p => new { p.TenantId, p.GroupId }); |
b.HasIndex(p => new { p.TenantId, p.GroupId }); |
||||
}); |
}); |
||||
|
|
||||
builder.Entity<UserChatFriend>(b => |
builder.Entity<UserChatFriend>(b => |
||||
{ |
{ |
||||
b.ToTable(options.TablePrefix + "UserChatFriends", options.Schema); |
b.ToTable(options.TablePrefix + "UserChatFriends", options.Schema); |
||||
|
|
||||
b.Property(p => p.RemarkName).HasMaxLength(UserChatFriendConsts.MaxRemarkNameLength); |
b.Property(p => p.RemarkName).HasMaxLength(UserChatFriendConsts.MaxRemarkNameLength); |
||||
b.Property(p => p.Description).HasMaxLength(UserChatFriendConsts.MaxDescriptionLength); |
b.Property(p => p.Description).HasMaxLength(UserChatFriendConsts.MaxDescriptionLength); |
||||
|
|
||||
b.ConfigureByConvention(); |
b.ConfigureByConvention(); |
||||
|
|
||||
b.HasIndex(p => new { p.TenantId, p.UserId, p.FrientId }); |
b.HasIndex(p => new { p.TenantId, p.UserId, p.FrientId }); |
||||
}); |
}); |
||||
|
|
||||
builder.Entity<UserChatCard>(b => |
builder.Entity<UserChatCard>(b => |
||||
{ |
{ |
||||
b.ToTable(options.TablePrefix + "UserChatCards", options.Schema); |
b.ToTable(options.TablePrefix + "UserChatCards", options.Schema); |
||||
|
|
||||
b.Property(p => p.UserName).HasMaxLength(UserChatCardConsts.MaxUserNameLength).IsRequired(); |
b.Property(p => p.UserName).HasMaxLength(UserChatCardConsts.MaxUserNameLength).IsRequired(); |
||||
|
|
||||
b.Property(p => p.AvatarUrl).HasMaxLength(UserChatCardConsts.MaxAvatarUrlLength); |
b.Property(p => p.AvatarUrl).HasMaxLength(UserChatCardConsts.MaxAvatarUrlLength); |
||||
b.Property(p => p.Description).HasMaxLength(UserChatCardConsts.MaxDescriptionLength); |
b.Property(p => p.Description).HasMaxLength(UserChatCardConsts.MaxDescriptionLength); |
||||
b.Property(p => p.NickName).HasMaxLength(UserChatCardConsts.MaxNickNameLength); |
b.Property(p => p.NickName).HasMaxLength(UserChatCardConsts.MaxNickNameLength); |
||||
b.Property(p => p.Sign).HasMaxLength(UserChatCardConsts.MaxSignLength); |
b.Property(p => p.Sign).HasMaxLength(UserChatCardConsts.MaxSignLength); |
||||
|
|
||||
b.ConfigureByConvention(); |
b.ConfigureByConvention(); |
||||
|
|
||||
b.HasIndex(p => new { p.TenantId, p.UserId }); |
b.HasIndex(p => new { p.TenantId, p.UserId }); |
||||
}); |
}); |
||||
|
|
||||
builder.Entity<UserGroupCard>(b => |
builder.Entity<UserGroupCard>(b => |
||||
{ |
{ |
||||
b.ToTable(options.TablePrefix + "UserGroupCards", options.Schema); |
b.ToTable(options.TablePrefix + "UserGroupCards", options.Schema); |
||||
|
|
||||
b.Property(p => p.NickName).HasMaxLength(UserChatCardConsts.MaxNickNameLength); |
b.Property(p => p.NickName).HasMaxLength(UserChatCardConsts.MaxNickNameLength); |
||||
|
|
||||
b.ConfigureByConvention(); |
b.ConfigureByConvention(); |
||||
|
|
||||
b.HasIndex(p => new { p.TenantId, p.UserId }); |
b.HasIndex(p => new { p.TenantId, p.UserId }); |
||||
}); |
}); |
||||
|
|
||||
|
|
||||
builder.Entity<UserChatSetting>(b => |
builder.Entity<UserChatSetting>(b => |
||||
{ |
{ |
||||
b.ToTable(options.TablePrefix + "UserChatSettings", options.Schema); |
b.ToTable(options.TablePrefix + "UserChatSettings", options.Schema); |
||||
|
|
||||
b.ConfigureByConvention(); |
b.ConfigureByConvention(); |
||||
|
|
||||
b.HasIndex(p => new { p.TenantId, p.UserId }); |
b.HasIndex(p => new { p.TenantId, p.UserId }); |
||||
}); |
}); |
||||
|
|
||||
//builder.Entity<UserSpecialFocus>(b =>
|
//builder.Entity<UserSpecialFocus>(b =>
|
||||
//{
|
//{
|
||||
// b.ToTable(options.TablePrefix + "UserSpecialFocuss", options.Schema);
|
// b.ToTable(options.TablePrefix + "UserSpecialFocuss", options.Schema);
|
||||
|
|
||||
// b.ConfigureMultiTenant();
|
// b.ConfigureMultiTenant();
|
||||
|
|
||||
// b.HasIndex(p => new { p.TenantId, p.UserId });
|
// b.HasIndex(p => new { p.TenantId, p.UserId });
|
||||
//});
|
//});
|
||||
|
|
||||
//builder.Entity<UserChatBlack>(b =>
|
//builder.Entity<UserChatBlack>(b =>
|
||||
//{
|
//{
|
||||
// b.ToTable(options.TablePrefix + "UserChatBlacks", options.Schema);
|
// b.ToTable(options.TablePrefix + "UserChatBlacks", options.Schema);
|
||||
|
|
||||
// b.ConfigureMultiTenant();
|
// b.ConfigureMultiTenant();
|
||||
|
|
||||
// b.HasIndex(p => new { p.TenantId, p.UserId });
|
// b.HasIndex(p => new { p.TenantId, p.UserId });
|
||||
//});
|
//});
|
||||
|
|
||||
builder.Entity<GroupChatBlack>(b => |
builder.Entity<GroupChatBlack>(b => |
||||
{ |
{ |
||||
b.ToTable(options.TablePrefix + "GroupChatBlacks", options.Schema); |
b.ToTable(options.TablePrefix + "GroupChatBlacks", options.Schema); |
||||
|
|
||||
b.ConfigureByConvention(); |
b.ConfigureByConvention(); |
||||
|
|
||||
b.HasIndex(p => new { p.TenantId, p.GroupId }); |
b.HasIndex(p => new { p.TenantId, p.GroupId }); |
||||
}); |
}); |
||||
|
|
||||
builder.Entity<ChatGroup>(b => |
builder.Entity<ChatGroup>(b => |
||||
{ |
{ |
||||
b.ToTable(options.TablePrefix + "ChatGroups", options.Schema); |
b.ToTable(options.TablePrefix + "ChatGroups", options.Schema); |
||||
|
|
||||
b.Property(p => p.Name).HasMaxLength(ChatGroupConsts.MaxNameLength).IsRequired(); |
b.Property(p => p.Name).HasMaxLength(ChatGroupConsts.MaxNameLength).IsRequired(); |
||||
|
|
||||
b.Property(p => p.Tag).HasMaxLength(ChatGroupConsts.MaxTagLength); |
b.Property(p => p.Tag).HasMaxLength(ChatGroupConsts.MaxTagLength); |
||||
b.Property(p => p.Notice).HasMaxLength(ChatGroupConsts.MaxNoticeLength); |
b.Property(p => p.Notice).HasMaxLength(ChatGroupConsts.MaxNoticeLength); |
||||
b.Property(p => p.Address).HasMaxLength(ChatGroupConsts.MaxAddressLength); |
b.Property(p => p.Address).HasMaxLength(ChatGroupConsts.MaxAddressLength); |
||||
b.Property(p => p.Description).HasMaxLength(ChatGroupConsts.MaxDescriptionLength); |
b.Property(p => p.Description).HasMaxLength(ChatGroupConsts.MaxDescriptionLength); |
||||
|
b.Property(p => p.AvatarUrl).HasMaxLength(ChatGroupConsts.MaxAvatarUrlLength); |
||||
b.ConfigureByConvention(); |
|
||||
|
b.ConfigureByConvention(); |
||||
b.HasIndex(p => new { p.TenantId, p.Name }); |
|
||||
}); |
b.HasIndex(p => new { p.TenantId, p.Name }); |
||||
|
}); |
||||
builder.Entity<UserChatGroup>(b => |
|
||||
{ |
builder.Entity<UserChatGroup>(b => |
||||
b.ToTable(options.TablePrefix + "UserChatGroups", options.Schema); |
{ |
||||
|
b.ToTable(options.TablePrefix + "UserChatGroups", options.Schema); |
||||
b.ConfigureByConvention(); |
|
||||
|
b.ConfigureByConvention(); |
||||
b.HasIndex(p => new { p.TenantId, p.GroupId, p.UserId }); |
|
||||
}); |
b.HasIndex(p => new { p.TenantId, p.GroupId, p.UserId }); |
||||
} |
}); |
||||
} |
} |
||||
} |
} |
||||
|
} |
||||
|
|||||
@ -1,58 +1,84 @@ |
|||||
using LINGYUN.Abp.MessageService.EntityFrameworkCore; |
using LINGYUN.Abp.MessageService.EntityFrameworkCore; |
||||
using Microsoft.EntityFrameworkCore; |
using Microsoft.EntityFrameworkCore; |
||||
using System; |
using System; |
||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||
using System.Linq; |
using System.Linq; |
||||
using System.Threading; |
using System.Linq.Dynamic.Core; |
||||
using System.Threading.Tasks; |
using System.Threading; |
||||
using Volo.Abp.DependencyInjection; |
using System.Threading.Tasks; |
||||
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
using Volo.Abp.DependencyInjection; |
||||
using Volo.Abp.EntityFrameworkCore; |
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
namespace LINGYUN.Abp.MessageService.Group |
|
||||
{ |
namespace LINGYUN.Abp.MessageService.Groups |
||||
public class EfCoreGroupRepository : EfCoreRepository<IMessageServiceDbContext, ChatGroup, long>, |
{ |
||||
IGroupRepository, ITransientDependency |
public class EfCoreGroupRepository : EfCoreRepository<IMessageServiceDbContext, ChatGroup, long>, |
||||
{ |
IGroupRepository, ITransientDependency |
||||
public EfCoreGroupRepository( |
{ |
||||
IDbContextProvider<IMessageServiceDbContext> dbContextProvider) |
public EfCoreGroupRepository( |
||||
: base(dbContextProvider) |
IDbContextProvider<IMessageServiceDbContext> dbContextProvider) |
||||
{ |
: base(dbContextProvider) |
||||
} |
{ |
||||
|
} |
||||
public virtual async Task<ChatGroup> FindByIdAsync( |
|
||||
long id, |
public virtual async Task<int> GetCountAsync( |
||||
CancellationToken cancellationToken = default) |
string filter = null, |
||||
{ |
CancellationToken cancellationToken = default) |
||||
return await (await GetDbSetAsync()) |
{ |
||||
.Where(x => x.GroupId.Equals(id)) |
return await (await GetDbSetAsync()) |
||||
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); |
.WhereIf(!filter.IsNullOrWhiteSpace(), x => |
||||
} |
x.Name.Contains(filter) || x.Tag.Contains(filter)) |
||||
|
.CountAsync(GetCancellationToken(cancellationToken)); |
||||
public virtual async Task<List<UserGroupCard>> GetGroupAdminAsync( |
} |
||||
long id, |
|
||||
CancellationToken cancellationToken = default) |
public virtual async Task<List<ChatGroup>> GetListAsync( |
||||
{ |
string filter = null, |
||||
var dbContext = await GetDbContextAsync(); |
string sorting = nameof(ChatGroup.Name), |
||||
var groupAdmins = await (from gp in dbContext.Set<ChatGroup>() |
int skipCount = 0, |
||||
join ucg in dbContext.Set<UserChatGroup>() |
int maxResultCount = 10, |
||||
on gp.GroupId equals ucg.GroupId |
CancellationToken cancellationToken = default) |
||||
join ugc in dbContext.Set<UserGroupCard>() |
{ |
||||
on ucg.UserId equals ugc.UserId |
return await (await GetDbSetAsync()) |
||||
where ugc.IsAdmin |
.WhereIf(!filter.IsNullOrWhiteSpace(), x => |
||||
select ugc) |
x.Name.Contains(filter) || x.Tag.Contains(filter)) |
||||
.ToListAsync(GetCancellationToken(cancellationToken)); |
.OrderBy(sorting ?? nameof(ChatGroup.Name)) |
||||
return groupAdmins; |
.PageBy(skipCount, maxResultCount) |
||||
} |
.ToListAsync(GetCancellationToken(cancellationToken)); |
||||
|
} |
||||
public virtual async Task<bool> UserHasBlackedAsync( |
|
||||
long id, |
public virtual async Task<ChatGroup> FindByIdAsync( |
||||
Guid formUserId, |
long id, |
||||
CancellationToken cancellationToken = default) |
CancellationToken cancellationToken = default) |
||||
{ |
{ |
||||
var userHasBlack = await (await GetDbContextAsync()).Set<GroupChatBlack>() |
return await (await GetDbSetAsync()) |
||||
.AnyAsync(x => x.GroupId.Equals(id) && x.ShieldUserId.Equals(formUserId), GetCancellationToken(cancellationToken)); |
.Where(x => x.GroupId.Equals(id)) |
||||
return userHasBlack; |
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); |
||||
} |
} |
||||
} |
|
||||
} |
public virtual async Task<List<UserGroupCard>> GetGroupAdminAsync( |
||||
|
long id, |
||||
|
CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var dbContext = await GetDbContextAsync(); |
||||
|
var groupAdmins = await (from gp in dbContext.Set<ChatGroup>() |
||||
|
join ucg in dbContext.Set<UserChatGroup>() |
||||
|
on gp.GroupId equals ucg.GroupId |
||||
|
join ugc in dbContext.Set<UserGroupCard>() |
||||
|
on ucg.UserId equals ugc.UserId |
||||
|
where ugc.IsAdmin |
||||
|
select ugc) |
||||
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
||||
|
return groupAdmins; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<bool> UserHasBlackedAsync( |
||||
|
long id, |
||||
|
Guid formUserId, |
||||
|
CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var userHasBlack = await (await GetDbContextAsync()).Set<GroupChatBlack>() |
||||
|
.AnyAsync(x => x.GroupId.Equals(id) && x.ShieldUserId.Equals(formUserId), GetCancellationToken(cancellationToken)); |
||||
|
return userHasBlack; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,21 +1,30 @@ |
|||||
using Microsoft.Extensions.DependencyInjection; |
using LINGYUN.Abp.MessageService.Localization; |
||||
using Volo.Abp.AspNetCore.Mvc; |
using Microsoft.Extensions.DependencyInjection; |
||||
using Volo.Abp.Modularity; |
using Volo.Abp.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc.Localization; |
||||
namespace LINGYUN.Abp.MessageService |
using Volo.Abp.Modularity; |
||||
{ |
|
||||
[DependsOn( |
namespace LINGYUN.Abp.MessageService |
||||
typeof(AbpMessageServiceApplicationContractsModule), |
{ |
||||
typeof(AbpAspNetCoreMvcModule) |
[DependsOn( |
||||
)] |
typeof(AbpMessageServiceApplicationContractsModule), |
||||
public class AbpMessageServiceHttpApiModule : AbpModule |
typeof(AbpAspNetCoreMvcModule) |
||||
{ |
)] |
||||
public override void PreConfigureServices(ServiceConfigurationContext context) |
public class AbpMessageServiceHttpApiModule : AbpModule |
||||
{ |
{ |
||||
PreConfigure<IMvcBuilder>(mvcBuilder => |
public override void PreConfigureServices(ServiceConfigurationContext context) |
||||
{ |
{ |
||||
mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpMessageServiceHttpApiModule).Assembly); |
PreConfigure<IMvcBuilder>(mvcBuilder => |
||||
}); |
{ |
||||
} |
mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpMessageServiceHttpApiModule).Assembly); |
||||
} |
}); |
||||
} |
|
||||
|
PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.AddAssemblyResource( |
||||
|
typeof(MessageServiceResource), // 用于本地化的资源
|
||||
|
typeof(AbpMessageServiceApplicationContractsModule).Assembly); // Dto所在程序集
|
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|||||
@ -1,53 +1,61 @@ |
|||||
using LINGYUN.Abp.IM.Contract; |
using LINGYUN.Abp.IM.Contract; |
||||
using Microsoft.AspNetCore.Mvc; |
using Microsoft.AspNetCore.Mvc; |
||||
using System.Threading.Tasks; |
using System; |
||||
using Volo.Abp; |
using System.Threading.Tasks; |
||||
using Volo.Abp.Application.Dtos; |
using Volo.Abp; |
||||
using Volo.Abp.AspNetCore.Mvc; |
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
namespace LINGYUN.Abp.MessageService.Chat |
|
||||
{ |
namespace LINGYUN.Abp.MessageService.Chat |
||||
[RemoteService(Name = AbpMessageServiceConsts.RemoteServiceName)] |
{ |
||||
[Route("api/im/my-friends")] |
[RemoteService(Name = AbpMessageServiceConsts.RemoteServiceName)] |
||||
public class MyFriendController : AbpController, IMyFriendAppService |
[Route("api/im/my-friends")] |
||||
{ |
public class MyFriendController : AbpController, IMyFriendAppService |
||||
protected IMyFriendAppService MyFriendAppService { get; } |
{ |
||||
|
protected IMyFriendAppService MyFriendAppService { get; } |
||||
public MyFriendController(IMyFriendAppService myFriendAppService) |
|
||||
{ |
public MyFriendController(IMyFriendAppService myFriendAppService) |
||||
MyFriendAppService = myFriendAppService; |
{ |
||||
} |
MyFriendAppService = myFriendAppService; |
||||
|
} |
||||
[HttpPost] |
|
||||
public virtual async Task CreateAsync(MyFriendCreateDto input) |
[HttpPost] |
||||
{ |
public virtual async Task CreateAsync(MyFriendCreateDto input) |
||||
await MyFriendAppService.CreateAsync(input); |
{ |
||||
} |
await MyFriendAppService.CreateAsync(input); |
||||
|
} |
||||
[HttpPost] |
|
||||
[Route("add-request")] |
[HttpPost] |
||||
public virtual async Task AddRequestAsync(MyFriendAddRequestDto input) |
[Route("add-request")] |
||||
{ |
public virtual async Task AddRequestAsync(MyFriendAddRequestDto input) |
||||
await MyFriendAppService.AddRequestAsync(input); |
{ |
||||
} |
await MyFriendAppService.AddRequestAsync(input); |
||||
|
} |
||||
[HttpDelete] |
|
||||
public virtual async Task DeleteAsync(MyFriendOperationDto input) |
[HttpDelete] |
||||
{ |
public virtual async Task DeleteAsync(MyFriendOperationDto input) |
||||
await MyFriendAppService.DeleteAsync(input); |
{ |
||||
} |
await MyFriendAppService.DeleteAsync(input); |
||||
|
} |
||||
[HttpGet] |
|
||||
[Route("all")] |
[HttpGet] |
||||
public virtual async Task<ListResultDto<UserFriend>> GetAllListAsync(GetMyFriendsDto input) |
[Route("{friendId}")] |
||||
{ |
public virtual async Task<UserFriend> GetAsync(Guid friendId) |
||||
return await MyFriendAppService.GetAllListAsync(input); |
{ |
||||
} |
return await MyFriendAppService.GetAsync(friendId); |
||||
|
} |
||||
[HttpGet] |
|
||||
public virtual async Task<PagedResultDto<UserFriend>> GetListAsync(MyFriendGetByPagedDto input) |
[HttpGet] |
||||
{ |
[Route("all")] |
||||
return await MyFriendAppService.GetListAsync(input); |
public virtual async Task<ListResultDto<UserFriend>> GetAllListAsync(GetMyFriendsDto input) |
||||
} |
{ |
||||
} |
return await MyFriendAppService.GetAllListAsync(input); |
||||
} |
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
public virtual async Task<PagedResultDto<UserFriend>> GetListAsync(MyFriendGetByPagedDto input) |
||||
|
{ |
||||
|
return await MyFriendAppService.GetListAsync(input); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|||||
@ -0,0 +1,35 @@ |
|||||
|
using LINGYUN.Abp.IM.Groups; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Groups |
||||
|
{ |
||||
|
[RemoteService(Name = AbpMessageServiceConsts.RemoteServiceName)] |
||||
|
[Route("api/im/groups")] |
||||
|
public class GroupController : AbpController, IGroupAppService |
||||
|
{ |
||||
|
private readonly IGroupAppService _service; |
||||
|
|
||||
|
public GroupController(IGroupAppService service) |
||||
|
{ |
||||
|
_service = service; |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("{groupId}")] |
||||
|
public virtual async Task<Group> GetAsync(string groupId) |
||||
|
{ |
||||
|
return await _service.GetAsync(groupId); |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("search")] |
||||
|
public virtual async Task<PagedResultDto<Group>> SearchAsync(GroupSearchInput input) |
||||
|
{ |
||||
|
return await _service.SearchAsync(input); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,55 @@ |
|||||
|
using LINGYUN.Abp.IM.Groups; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Groups |
||||
|
{ |
||||
|
[RemoteService(Name = AbpMessageServiceConsts.RemoteServiceName)] |
||||
|
[Route("api/im/user-groups")] |
||||
|
public class UserGroupController : AbpController, IUserGroupAppService |
||||
|
{ |
||||
|
private readonly IUserGroupAppService _service; |
||||
|
|
||||
|
public UserGroupController(IUserGroupAppService service) |
||||
|
{ |
||||
|
_service = service; |
||||
|
} |
||||
|
|
||||
|
[HttpPost] |
||||
|
[Route("join")] |
||||
|
public virtual async Task ApplyJoinGroupAsync(UserJoinGroupDto input) |
||||
|
{ |
||||
|
await _service.ApplyJoinGroupAsync(input); |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
public virtual async Task<PagedResultDto<GroupUserCard>> GetGroupUsersAsync(GroupUserGetByPagedDto input) |
||||
|
{ |
||||
|
return await _service.GetGroupUsersAsync(input); |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("me")] |
||||
|
public virtual async Task<ListResultDto<Group>> GetMyGroupsAsync() |
||||
|
{ |
||||
|
return await _service.GetMyGroupsAsync(); |
||||
|
} |
||||
|
|
||||
|
[HttpPut] |
||||
|
[Route("accept")] |
||||
|
public virtual async Task GroupAcceptUserAsync(GroupAcceptUserDto input) |
||||
|
{ |
||||
|
await _service.GroupAcceptUserAsync(input); |
||||
|
} |
||||
|
|
||||
|
[HttpPut] |
||||
|
[Route("remove")] |
||||
|
public virtual async Task GroupRemoveUserAsync(GroupRemoveUserDto input) |
||||
|
{ |
||||
|
await _service.GroupRemoveUserAsync(input); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,622 @@ |
|||||
|
// <auto-generated />
|
||||
|
using System; |
||||
|
using LINGYUN.Abp.MessageService.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Infrastructure; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Migrations |
||||
|
{ |
||||
|
[DbContext(typeof(MessageServiceHostMigrationsDbContext))] |
||||
|
[Migration("20211110144233_Add-Field-Online-Avatar")] |
||||
|
partial class AddFieldOnlineAvatar |
||||
|
{ |
||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
#pragma warning disable 612, 618
|
||||
|
modelBuilder |
||||
|
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 64) |
||||
|
.HasAnnotation("ProductVersion", "5.0.12"); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatCard", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<int>("Age") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("AvatarUrl") |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)"); |
||||
|
|
||||
|
b.Property<DateTime?>("Birthday") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("varchar(50)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastOnlineTime") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<string>("NickName") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<int>("Sex") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("Sign") |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)"); |
||||
|
|
||||
|
b.Property<int>("State") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("UserName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId"); |
||||
|
|
||||
|
b.ToTable("AppUserChatCards"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatFriend", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<bool>("Black") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("varchar(50)"); |
||||
|
|
||||
|
b.Property<bool>("DontDisturb") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<Guid>("FrientId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("RemarkName") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<bool>("SpecialFocus") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<byte>("Status") |
||||
|
.HasColumnType("tinyint unsigned"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId", "FrientId"); |
||||
|
|
||||
|
b.ToTable("AppUserChatFriends"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatSetting", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<bool>("AllowAddFriend") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("AllowAnonymous") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("AllowReceiveMessage") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("AllowSendMessage") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("RequireAddFriendValition") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId"); |
||||
|
|
||||
|
b.ToTable("AppUserChatSettings"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserMessage", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<string>("Content") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(1048576) |
||||
|
.HasColumnType("longtext"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<long>("MessageId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<Guid>("ReceiveUserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<sbyte>("SendState") |
||||
|
.HasColumnType("tinyint"); |
||||
|
|
||||
|
b.Property<string>("SendUserName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<int>("Type") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "ReceiveUserId"); |
||||
|
|
||||
|
b.ToTable("AppUserMessages"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.ChatGroup", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("Address") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<Guid>("AdminUserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<bool>("AllowAnonymous") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("AllowSendMessage") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("AvatarUrl") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<long>("GroupId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<int>("MaxUserCount") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(20) |
||||
|
.HasColumnType("varchar(20)"); |
||||
|
|
||||
|
b.Property<string>("Notice") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("Tag") |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "Name"); |
||||
|
|
||||
|
b.ToTable("AppChatGroups"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupChatBlack", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<long>("GroupId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<Guid>("ShieldUserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "GroupId"); |
||||
|
|
||||
|
b.ToTable("AppGroupChatBlacks"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupMessage", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<string>("Content") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(1048576) |
||||
|
.HasColumnType("longtext"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<long>("GroupId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<long>("MessageId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<sbyte>("SendState") |
||||
|
.HasColumnType("tinyint"); |
||||
|
|
||||
|
b.Property<string>("SendUserName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<int>("Type") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "GroupId"); |
||||
|
|
||||
|
b.ToTable("AppGroupMessages"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserChatGroup", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<long>("GroupId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "GroupId", "UserId"); |
||||
|
|
||||
|
b.ToTable("AppUserChatGroups"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserGroupCard", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<bool>("IsAdmin") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("NickName") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<DateTime?>("SilenceEnd") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId"); |
||||
|
|
||||
|
b.ToTable("AppUserGroupCards"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.Notification", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<DateTime?>("ExpirationTime") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<string>("NotificationData") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(1048576) |
||||
|
.HasColumnType("longtext"); |
||||
|
|
||||
|
b.Property<long>("NotificationId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("NotificationName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("varchar(100)"); |
||||
|
|
||||
|
b.Property<string>("NotificationTypeName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)"); |
||||
|
|
||||
|
b.Property<sbyte>("Severity") |
||||
|
.HasColumnType("tinyint"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<int>("Type") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "NotificationName"); |
||||
|
|
||||
|
b.ToTable("AppNotifications"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.UserNotification", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<long>("NotificationId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<int>("ReadStatus") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId", "NotificationId") |
||||
|
.HasDatabaseName("IX_Tenant_User_Notification_Id"); |
||||
|
|
||||
|
b.ToTable("AppUserNotifications"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Subscriptions.UserSubscribe", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<string>("NotificationName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("varchar(100)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("UserName") |
||||
|
.IsRequired() |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasDefaultValue("/"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId", "NotificationName") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("IX_Tenant_User_Notification_Name"); |
||||
|
|
||||
|
b.ToTable("AppUserSubscribes"); |
||||
|
}); |
||||
|
#pragma warning restore 612, 618
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Migrations |
||||
|
{ |
||||
|
public partial class AddFieldOnlineAvatar : Migration |
||||
|
{ |
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.AddColumn<DateTime>( |
||||
|
name: "LastOnlineTime", |
||||
|
table: "AppUserChatCards", |
||||
|
type: "datetime(6)", |
||||
|
nullable: true); |
||||
|
|
||||
|
migrationBuilder.AddColumn<int>( |
||||
|
name: "State", |
||||
|
table: "AppUserChatCards", |
||||
|
type: "int", |
||||
|
nullable: false, |
||||
|
defaultValue: 0); |
||||
|
|
||||
|
migrationBuilder.AddColumn<string>( |
||||
|
name: "AvatarUrl", |
||||
|
table: "AppChatGroups", |
||||
|
type: "varchar(128)", |
||||
|
maxLength: 128, |
||||
|
nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
} |
||||
|
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "LastOnlineTime", |
||||
|
table: "AppUserChatCards"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "State", |
||||
|
table: "AppUserChatCards"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "AvatarUrl", |
||||
|
table: "AppChatGroups"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue