75 changed files with 1413 additions and 354 deletions
@ -0,0 +1,22 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IM.Group |
||||
|
{ |
||||
|
public class GroupUserCard : UserCard |
||||
|
{ |
||||
|
public long GroupId { get; set; } |
||||
|
public bool IsAdmin { get; set; } |
||||
|
public bool IsSuperAdmin { get; set; } |
||||
|
public IDictionary<string, bool> Permissions { get; set; } |
||||
|
public GroupUserCard() |
||||
|
{ |
||||
|
Permissions = new Dictionary<string, bool>(); |
||||
|
} |
||||
|
|
||||
|
public bool IsGrant(string key) |
||||
|
{ |
||||
|
return Permissions.Any(x => x.Equals(key) && x.Value); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IM |
||||
|
{ |
||||
|
public class UserCard |
||||
|
{ |
||||
|
public Guid? TenantId { get; set; } |
||||
|
public Guid UserId { get; set; } |
||||
|
|
||||
|
#region 下一个版本细粒度的用户资料 与Identity集成
|
||||
|
|
||||
|
public string UserName { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 头像
|
||||
|
/// </summary>
|
||||
|
public string AvatarlUrl { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 昵称
|
||||
|
/// </summary>
|
||||
|
public string NickName { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 年龄
|
||||
|
/// </summary>
|
||||
|
public int Arg { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 性别
|
||||
|
/// </summary>
|
||||
|
public string Sex { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 国家
|
||||
|
/// </summary>
|
||||
|
public string Countriy { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 省份
|
||||
|
/// </summary>
|
||||
|
public string Province { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 城市
|
||||
|
/// </summary>
|
||||
|
public string City { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 签名
|
||||
|
/// </summary>
|
||||
|
public string Sign { get; set; } |
||||
|
|
||||
|
#endregion
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.0</TargetFramework> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="2.9.0" /> |
||||
|
<PackageReference Include="Volo.Abp.Authorization" Version="2.9.0" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<None Remove="LINGYUN\Abp\MessageService\Localization\ApplicationContracts\en.json" /> |
||||
|
<None Remove="LINGYUN\Abp\MessageService\Localization\ApplicationContracts\zh-Hans.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<EmbeddedResource Include="LINGYUN\Abp\MessageService\Localization\ApplicationContracts\en.json" /> |
||||
|
<EmbeddedResource Include="LINGYUN\Abp\MessageService\Localization\ApplicationContracts\zh-Hans.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\common\LINGYUN.Abp.IM\LINGYUN.Abp.IM.csproj" /> |
||||
|
<ProjectReference Include="..\..\common\LINGYUN.Abp.Notifications\LINGYUN.Abp.Notifications.csproj" /> |
||||
|
<ProjectReference Include="..\..\message\LINGYUN.Abp.MessageService.Domain.Shared\LINGYUN.Abp.MessageService.Domain.Shared.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,26 @@ |
|||||
|
using LINGYUN.Abp.MessageService.Localization; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.VirtualFileSystem; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService |
||||
|
{ |
||||
|
[DependsOn(typeof(AbpMessageServiceDomainSharedModule))] |
||||
|
public class AbpMessageServiceApplicationContrantsModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<AbpVirtualFileSystemOptions>(options => |
||||
|
{ |
||||
|
options.FileSets.AddEmbedded<AbpMessageServiceApplicationContrantsModule>(); |
||||
|
}); |
||||
|
|
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Resources |
||||
|
.Get<MessageServiceResource>() |
||||
|
.AddVirtualJson("/LINGYUN/Abp/MessageService/Localization/ApplicationContracts"); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
namespace LINGYUN.Abp.MessageService |
||||
|
{ |
||||
|
public class AbpMessageServiceConsts |
||||
|
{ |
||||
|
public const string RemoteServiceName = "MessageService"; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
namespace LINGYUN.Abp.MessageService.Chat |
||||
|
{ |
||||
|
public class ChatMessageSendResultDto |
||||
|
{ |
||||
|
public string MessageId { get; } |
||||
|
public ChatMessageSendResultDto(string messageId) |
||||
|
{ |
||||
|
MessageId = messageId; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Chat |
||||
|
{ |
||||
|
public class GroupAcceptUserDto |
||||
|
{ |
||||
|
[Required] |
||||
|
public Guid UserId { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
public long GroupId { get; set; } |
||||
|
|
||||
|
public bool AllowAccept { get; set; } = true; |
||||
|
|
||||
|
[StringLength(64)] |
||||
|
public string RejectReason { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
using LINGYUN.Abp.IM.Messages; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Chat |
||||
|
{ |
||||
|
public class GroupMessageGetByPagedDto : PagedAndSortedResultRequestDto |
||||
|
{ |
||||
|
[Required] |
||||
|
public long GroupId { get; set; } |
||||
|
public string Filter { get; set; } |
||||
|
public MessageType? MessageType { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Chat |
||||
|
{ |
||||
|
public class GroupRemoveUserDto |
||||
|
{ |
||||
|
[Required] |
||||
|
public Guid UserId { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
public long GroupId { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Chat |
||||
|
{ |
||||
|
public class GroupUserGetByPagedDto : PagedAndSortedResultRequestDto |
||||
|
{ |
||||
|
[Required] |
||||
|
public long GroupId { get; set; } |
||||
|
|
||||
|
public string Filter { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Chat |
||||
|
{ |
||||
|
public class UserGroupGetByGroupIdDto |
||||
|
{ |
||||
|
[Required] |
||||
|
public long GroupId { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Chat |
||||
|
{ |
||||
|
public class UserJoinGroupDto |
||||
|
{ |
||||
|
[Required] |
||||
|
public long GroupId { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
[StringLength(100)] |
||||
|
public string JoinInfo { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
using LINGYUN.Abp.IM.Messages; |
||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Chat |
||||
|
{ |
||||
|
public class UserMessageGetByPagedDto : PagedAndSortedResultRequestDto |
||||
|
{ |
||||
|
[Required] |
||||
|
public Guid ReceiveUserId { get; set; } |
||||
|
public string Filter { get; set; } |
||||
|
public MessageType? MessageType { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,61 @@ |
|||||
|
using LINGYUN.Abp.IM.Group; |
||||
|
using LINGYUN.Abp.IM.Messages; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Chat |
||||
|
{ |
||||
|
public interface IChatAppService : IApplicationService |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 发送消息
|
||||
|
/// </summary>
|
||||
|
/// <param name="chatMessage"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task<ChatMessageSendResultDto> SendMessageAsync(ChatMessage chatMessage); |
||||
|
/// <summary>
|
||||
|
/// 申请加入群组
|
||||
|
/// </summary>
|
||||
|
/// <param name="userJoinGroup"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task ApplyJoinGroupAsync(UserJoinGroupDto userJoinGroup); |
||||
|
/// <summary>
|
||||
|
/// 获取我的群组
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
Task<ListResultDto<Group>> GetMyGroupsAsync(); |
||||
|
/// <summary>
|
||||
|
/// 获取群组用户
|
||||
|
/// </summary>
|
||||
|
/// <param name="groupUserGetByPaged"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task<PagedResultDto<UserGroup>> GetGroupUsersAsync(GroupUserGetByPagedDto groupUserGetByPaged); |
||||
|
/// <summary>
|
||||
|
/// 处理用户群组申请
|
||||
|
/// </summary>
|
||||
|
/// <param name="groupAcceptUser"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task GroupAcceptUserAsync(GroupAcceptUserDto groupAcceptUser); |
||||
|
/// <summary>
|
||||
|
/// 群组移除用户
|
||||
|
/// </summary>
|
||||
|
/// <param name="groupRemoveUser"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task GroupRemoveUserAsync(GroupRemoveUserDto groupRemoveUser); |
||||
|
/// <summary>
|
||||
|
/// 获取群组消息
|
||||
|
/// </summary>
|
||||
|
/// <param name="groupMessageGetByPaged"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task<PagedResultDto<ChatMessage>> GetGroupMessageAsync(GroupMessageGetByPagedDto groupMessageGetByPaged); |
||||
|
/// <summary>
|
||||
|
/// 获取我的消息
|
||||
|
/// </summary>
|
||||
|
/// <param name="userMessageGetByPaged"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task<PagedResultDto<ChatMessage>> GetMyChatMessageAsync(UserMessageGetByPagedDto userMessageGetByPaged); |
||||
|
|
||||
|
//TOTO: 还应该有获取我的未读消息 获取我的未读群组消息
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "en", |
||||
|
"texts": { |
||||
|
"Permission:MessageService": "Message service", |
||||
|
"Permission:Notification": "Notification", |
||||
|
"Permission:Delete": "Delete" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "zh-Hans", |
||||
|
"texts": { |
||||
|
"Permission:MessageService": "消息服务", |
||||
|
"Permission:Notification": "通知管理", |
||||
|
"Permission:Delete": "删除" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Notifications |
||||
|
{ |
||||
|
public class NotificationGetByIdDto |
||||
|
{ |
||||
|
[Required] |
||||
|
public long NotificationId { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
using LINGYUN.Abp.Notifications; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Notifications |
||||
|
{ |
||||
|
public class UserNotificationChangeReadStateDto |
||||
|
{ |
||||
|
[Required] |
||||
|
public long NotificationId { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
public NotificationReadState ReadState { get; set; } = NotificationReadState.Read; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Notifications |
||||
|
{ |
||||
|
public class UserNotificationGetByNameDto |
||||
|
{ |
||||
|
[Required] |
||||
|
[StringLength(NotificationConsts.MaxNameLength)] |
||||
|
public string NotificationName { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
using LINGYUN.Abp.Notifications; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Notifications |
||||
|
{ |
||||
|
public class UserNotificationGetByPagedDto : PagedAndSortedResultRequestDto |
||||
|
{ |
||||
|
public string Filter { get; set; } |
||||
|
|
||||
|
public NotificationReadState ReadState { get; set; } = NotificationReadState.Read; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
using LINGYUN.Abp.Notifications; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Notifications |
||||
|
{ |
||||
|
public interface INotificationAppService : IApplicationService |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 查询通知明细
|
||||
|
/// </summary>
|
||||
|
/// <param name="notificationGetById"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task<NotificationInfo> GetAsync(NotificationGetByIdDto notificationGetById); |
||||
|
/// <summary>
|
||||
|
/// 删除通知
|
||||
|
/// </summary>
|
||||
|
/// <param name="notificationGetById"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task DeleteAsync(NotificationGetByIdDto notificationGetById); |
||||
|
/// <summary>
|
||||
|
/// 删除用户通知
|
||||
|
/// </summary>
|
||||
|
/// <param name="notificationGetById"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task DeleteUserNotificationAsync(NotificationGetByIdDto notificationGetById); |
||||
|
/// <summary>
|
||||
|
/// 变更通知阅读状态
|
||||
|
/// </summary>
|
||||
|
/// <param name="userNotificationChangeRead"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task ChangeUserNotificationReadStateAsync(UserNotificationChangeReadStateDto userNotificationChangeRead); |
||||
|
/// <summary>
|
||||
|
/// 获取用户通知列表
|
||||
|
/// </summary>
|
||||
|
/// <param name="userNotificationGetByPaged"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task<PagedResultDto<NotificationInfo>> GetUserNotificationsAsync(UserNotificationGetByPagedDto userNotificationGetByPaged); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
namespace LINGYUN.Abp.MessageService.Permissions |
||||
|
{ |
||||
|
public class MessageServicePermissions |
||||
|
{ |
||||
|
public const string GroupName = "MessageService"; |
||||
|
|
||||
|
public class Notification |
||||
|
{ |
||||
|
public const string Default = GroupName + ".Notification"; |
||||
|
|
||||
|
public const string Delete = Default + ".Delete"; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
using LINGYUN.Abp.MessageService.Localization; |
||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using Volo.Abp.Localization; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Permissions |
||||
|
{ |
||||
|
public class MessageServicePermissionsDefinitionProvider : PermissionDefinitionProvider |
||||
|
{ |
||||
|
public override void Define(IPermissionDefinitionContext context) |
||||
|
{ |
||||
|
var group = context.AddGroup(MessageServicePermissions.GroupName, L("Permission:MessageService")); |
||||
|
|
||||
|
var noticeGroup = group.AddPermission(MessageServicePermissions.Notification.Default, L("Permission:Notification")); |
||||
|
noticeGroup.AddChild(MessageServicePermissions.Notification.Delete, L("Permission:Delete")); |
||||
|
} |
||||
|
|
||||
|
private static LocalizableString L(string name) |
||||
|
{ |
||||
|
return LocalizableString.Create<MessageServiceResource>(name); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
using LINGYUN.Abp.MessageService.Notifications; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Subscriptions |
||||
|
{ |
||||
|
public class SubscriptionsGetByNameDto |
||||
|
{ |
||||
|
[Required] |
||||
|
[StringLength(NotificationConsts.MaxNameLength)] |
||||
|
public string NotificationName { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Subscriptions |
||||
|
{ |
||||
|
public class SubscriptionsGetByPagedDto : PagedAndSortedResultRequestDto |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,35 @@ |
|||||
|
using LINGYUN.Abp.Notifications; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Subscriptions |
||||
|
{ |
||||
|
public interface ISubscriptionAppService : IApplicationService |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 是否已订阅消息
|
||||
|
/// </summary>
|
||||
|
/// <param name="subscriptionsGetByName"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task<bool> IsSubscribedAsync(SubscriptionsGetByNameDto subscriptionsGetByName); |
||||
|
/// <summary>
|
||||
|
/// 订阅消息
|
||||
|
/// </summary>
|
||||
|
/// <param name="subscriptionsGetByName"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task SubscribeAsync(SubscriptionsGetByNameDto subscriptionsGetByName); |
||||
|
/// <summary>
|
||||
|
/// 退订消息
|
||||
|
/// </summary>
|
||||
|
/// <param name="subscriptionsGetByName"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task UnSubscribeAsync(SubscriptionsGetByNameDto subscriptionsGetByName); |
||||
|
/// <summary>
|
||||
|
/// 获取订阅列表
|
||||
|
/// </summary>
|
||||
|
/// <param name="subscriptionsGetByPaged"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task<PagedResultDto<NotificationSubscriptionInfo>> GetSubscribedsAsync(SubscriptionsGetByPagedDto subscriptionsGetByPaged); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(AbpMessageServiceApplicationContrantsModule), |
||||
|
typeof(AbpMessageServiceDomainModule))] |
||||
|
public class AbpMessageServiceApplicationModule : AbpModule |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.0</TargetFramework> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.Ddd.Application" Version="2.9.0" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\LINGYUN.Abp.MessageService.Application.Contracts\LINGYUN.Abp.MessageService.Application.Contracts.csproj" /> |
||||
|
<ProjectReference Include="..\LINGYUN.Abp.MessageService.Domain\LINGYUN.Abp.MessageService.Domain.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,127 @@ |
|||||
|
using LINGYUN.Abp.IM.Group; |
||||
|
using LINGYUN.Abp.IM.Messages; |
||||
|
using System.Collections.Immutable; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.Users; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Chat |
||||
|
{ |
||||
|
public class ChatAppService : ApplicationService, IChatAppService |
||||
|
{ |
||||
|
private IMessageSender _messageSender; |
||||
|
protected IMessageSender MessageSender => LazyGetRequiredService(ref _messageSender); |
||||
|
|
||||
|
private readonly IUserGroupStore _userGroupStore; |
||||
|
private readonly IMessageStore _messageStore; |
||||
|
|
||||
|
public ChatAppService( |
||||
|
IMessageStore messageStore, |
||||
|
IUserGroupStore userGroupStore) |
||||
|
{ |
||||
|
_messageStore = messageStore; |
||||
|
_userGroupStore = userGroupStore; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<PagedResultDto<ChatMessage>> GetMyChatMessageAsync(UserMessageGetByPagedDto userMessageGetByPaged) |
||||
|
{ |
||||
|
var chatMessageCount = await _messageStore |
||||
|
.GetChatMessageCountAsync(CurrentTenant.Id, CurrentUser.GetId(), userMessageGetByPaged.ReceiveUserId, |
||||
|
userMessageGetByPaged.Filter, userMessageGetByPaged.MessageType); |
||||
|
|
||||
|
var chatMessages = await _messageStore |
||||
|
.GetChatMessageAsync(CurrentTenant.Id, CurrentUser.GetId(), userMessageGetByPaged.ReceiveUserId, |
||||
|
userMessageGetByPaged.Filter, userMessageGetByPaged.Sorting, userMessageGetByPaged.MessageType, |
||||
|
userMessageGetByPaged.SkipCount, userMessageGetByPaged.MaxResultCount); |
||||
|
|
||||
|
return new PagedResultDto<ChatMessage>(chatMessageCount, chatMessages); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<PagedResultDto<ChatMessage>> GetGroupMessageAsync(GroupMessageGetByPagedDto groupMessageGetByPaged) |
||||
|
{ |
||||
|
var groupMessageCount = await _messageStore |
||||
|
.GetGroupMessageCountAsync(CurrentTenant.Id, groupMessageGetByPaged.GroupId, |
||||
|
groupMessageGetByPaged.Filter, groupMessageGetByPaged.MessageType); |
||||
|
|
||||
|
var groupMessages = await _messageStore |
||||
|
.GetGroupMessageAsync(CurrentTenant.Id, groupMessageGetByPaged.GroupId, |
||||
|
groupMessageGetByPaged.Filter, groupMessageGetByPaged.Sorting, groupMessageGetByPaged.MessageType, |
||||
|
groupMessageGetByPaged.SkipCount, groupMessageGetByPaged.MaxResultCount); |
||||
|
|
||||
|
return new PagedResultDto<ChatMessage>(groupMessageCount, groupMessages); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<PagedResultDto<UserGroup>> GetGroupUsersAsync(GroupUserGetByPagedDto groupUserGetByPaged) |
||||
|
{ |
||||
|
var groupUserCount = await _userGroupStore.GetGroupUsersCountAsync(CurrentTenant.Id, |
||||
|
groupUserGetByPaged.GroupId, groupUserGetByPaged.Filter); |
||||
|
|
||||
|
var groupUsers = await _userGroupStore.GetGroupUsersAsync(CurrentTenant.Id, |
||||
|
groupUserGetByPaged.GroupId, groupUserGetByPaged.Filter, groupUserGetByPaged.Sorting, |
||||
|
groupUserGetByPaged.SkipCount, groupUserGetByPaged.MaxResultCount); |
||||
|
|
||||
|
return new PagedResultDto<UserGroup>(groupUserCount, groupUsers); |
||||
|
} |
||||
|
|
||||
|
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 groupAcceptUser) |
||||
|
{ |
||||
|
var myGroupCard = await _userGroupStore |
||||
|
.GetUserGroupCardAsync(CurrentTenant.Id, groupAcceptUser.GroupId, CurrentUser.GetId()); |
||||
|
if (myGroupCard == null) |
||||
|
{ |
||||
|
// 当前登录用户不再用户组
|
||||
|
throw new UserFriendlyException(""); |
||||
|
} |
||||
|
if (!myGroupCard.IsGrant(nameof(ChatGroupAdmin.AllowAddPeople))) |
||||
|
{ |
||||
|
// 当前登录用户没有加人权限
|
||||
|
throw new UserFriendlyException(""); |
||||
|
} |
||||
|
await _userGroupStore |
||||
|
.AddUserToGroupAsync(CurrentTenant.Id, groupAcceptUser.UserId, groupAcceptUser.GroupId, CurrentUser.GetId()); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task GroupRemoveUserAsync(GroupRemoveUserDto groupRemoveUser) |
||||
|
{ |
||||
|
var myGroupCard = await _userGroupStore |
||||
|
.GetUserGroupCardAsync(CurrentTenant.Id, groupRemoveUser.GroupId, CurrentUser.GetId()); |
||||
|
if (myGroupCard == null) |
||||
|
{ |
||||
|
// 当前登录用户不再用户组
|
||||
|
throw new UserFriendlyException(""); |
||||
|
} |
||||
|
if (!myGroupCard.IsGrant(nameof(ChatGroupAdmin.AllowKickPeople))) |
||||
|
{ |
||||
|
// 当前登录用户没有踢人权限
|
||||
|
throw new UserFriendlyException(""); |
||||
|
} |
||||
|
await _userGroupStore |
||||
|
.RemoveUserFormGroupAsync(CurrentTenant.Id, groupRemoveUser.UserId, groupRemoveUser.GroupId); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<ChatMessageSendResultDto> SendMessageAsync(ChatMessage chatMessage) |
||||
|
{ |
||||
|
// TODO:向其他租户发送消息?
|
||||
|
chatMessage.TenantId = chatMessage.TenantId ?? CurrentTenant.Id; |
||||
|
|
||||
|
await MessageSender.SendMessageAsync(chatMessage); |
||||
|
|
||||
|
return new ChatMessageSendResultDto(chatMessage.MessageId); |
||||
|
} |
||||
|
|
||||
|
public virtual Task ApplyJoinGroupAsync(UserJoinGroupDto userJoinGroup) |
||||
|
{ |
||||
|
// TOTO 发送通知?
|
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,68 @@ |
|||||
|
using LINGYUN.Abp.MessageService.Permissions; |
||||
|
using LINGYUN.Abp.Notifications; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.Users; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Notifications |
||||
|
{ |
||||
|
[Authorize] |
||||
|
public class NotificationAppService : ApplicationService, INotificationAppService |
||||
|
{ |
||||
|
private readonly INotificationRepository _notificationRepository; |
||||
|
private readonly IUserNotificationRepository _userNotificationRepository; |
||||
|
public NotificationAppService( |
||||
|
INotificationRepository notificationRepository, |
||||
|
IUserNotificationRepository userNotificationRepository) |
||||
|
{ |
||||
|
_notificationRepository = notificationRepository; |
||||
|
_userNotificationRepository = userNotificationRepository; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task ChangeUserNotificationReadStateAsync(UserNotificationChangeReadStateDto userNotificationChangeRead) |
||||
|
{ |
||||
|
await _userNotificationRepository.ChangeUserNotificationReadStateAsync( |
||||
|
CurrentUser.GetId(), userNotificationChangeRead.NotificationId, userNotificationChangeRead.ReadState); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
[Authorize(MessageServicePermissions.Notification.Delete)] |
||||
|
public virtual async Task DeleteAsync(NotificationGetByIdDto notificationGetById) |
||||
|
{ |
||||
|
await _notificationRepository.DeleteAsync(notificationGetById.NotificationId); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task DeleteUserNotificationAsync(NotificationGetByIdDto notificationGetById) |
||||
|
{ |
||||
|
var notify = await _userNotificationRepository |
||||
|
.GetByIdAsync(CurrentUser.GetId(), notificationGetById.NotificationId); |
||||
|
await _userNotificationRepository.DeleteAsync(notify.Id); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<NotificationInfo> GetAsync(NotificationGetByIdDto notificationGetById) |
||||
|
{ |
||||
|
var notification = await _notificationRepository.GetByIdAsync(notificationGetById.NotificationId); |
||||
|
|
||||
|
return ObjectMapper.Map<Notification, NotificationInfo>(notification); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<PagedResultDto<NotificationInfo>> GetUserNotificationsAsync(UserNotificationGetByPagedDto userNotificationGetByPaged) |
||||
|
{ |
||||
|
var notificationCount = await _userNotificationRepository |
||||
|
.GetCountAsync(CurrentUser.GetId(), userNotificationGetByPaged.Filter, |
||||
|
userNotificationGetByPaged.ReadState); |
||||
|
|
||||
|
var notifications = await _userNotificationRepository |
||||
|
.GetNotificationsAsync(CurrentUser.GetId(), userNotificationGetByPaged.Filter, |
||||
|
userNotificationGetByPaged.Sorting, userNotificationGetByPaged.ReadState, |
||||
|
userNotificationGetByPaged.SkipCount, userNotificationGetByPaged.MaxResultCount |
||||
|
); |
||||
|
|
||||
|
return new PagedResultDto<NotificationInfo>(notificationCount, |
||||
|
ObjectMapper.Map<List<Notification>, List<NotificationInfo>>(notifications)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,65 @@ |
|||||
|
using LINGYUN.Abp.Notifications; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.Users; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Subscriptions |
||||
|
{ |
||||
|
[Authorize] |
||||
|
public class SubscriptionAppService : ApplicationService, ISubscriptionAppService |
||||
|
{ |
||||
|
private readonly IUserSubscribeRepository _userSubscribeRepository; |
||||
|
|
||||
|
public SubscriptionAppService( |
||||
|
IUserSubscribeRepository userSubscribeRepository) |
||||
|
{ |
||||
|
_userSubscribeRepository = userSubscribeRepository; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<PagedResultDto<NotificationSubscriptionInfo>> GetSubscribedsAsync(SubscriptionsGetByPagedDto subscriptionsGetByPaged) |
||||
|
{ |
||||
|
var userSubscribedCount = await _userSubscribeRepository.GetCountAsync(CurrentUser.GetId()); |
||||
|
|
||||
|
var userSubscribes = await _userSubscribeRepository |
||||
|
.GetUserSubscribesAsync(CurrentUser.GetId(), subscriptionsGetByPaged.Sorting, |
||||
|
subscriptionsGetByPaged.SkipCount, subscriptionsGetByPaged.MaxResultCount); |
||||
|
|
||||
|
return new PagedResultDto<NotificationSubscriptionInfo>(userSubscribedCount, |
||||
|
ObjectMapper.Map<List<UserSubscribe>, List<NotificationSubscriptionInfo>>(userSubscribes)); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<bool> IsSubscribedAsync(SubscriptionsGetByNameDto subscriptionsGetByName) |
||||
|
{ |
||||
|
var isSubscribed = await _userSubscribeRepository |
||||
|
.UserSubscribeExistsAysnc(subscriptionsGetByName.NotificationName, CurrentUser.GetId()); |
||||
|
|
||||
|
return isSubscribed; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task SubscribeAsync(SubscriptionsGetByNameDto subscriptionsGetByName) |
||||
|
{ |
||||
|
var isSubscribed = await _userSubscribeRepository |
||||
|
.UserSubscribeExistsAysnc(subscriptionsGetByName.NotificationName, CurrentUser.GetId()); |
||||
|
if (!isSubscribed) |
||||
|
{ |
||||
|
UserSubscribe userSubscribe = new UserSubscribe( |
||||
|
subscriptionsGetByName.NotificationName, |
||||
|
CurrentUser.GetId(), CurrentUser.UserName, CurrentTenant.Id); |
||||
|
|
||||
|
await _userSubscribeRepository.InsertAsync(userSubscribe, true); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public virtual async Task UnSubscribeAsync(SubscriptionsGetByNameDto subscriptionsGetByName) |
||||
|
{ |
||||
|
var userSubscribe = await _userSubscribeRepository.GetUserSubscribeAsync(subscriptionsGetByName.NotificationName, CurrentUser.GetId()); |
||||
|
if (userSubscribe != null) |
||||
|
{ |
||||
|
await _userSubscribeRepository.DeleteAsync(userSubscribe.Id, true); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,4 +1,4 @@ |
|||||
namespace LINGYUN.Abp.MessageService.Messages |
namespace LINGYUN.Abp.MessageService.Chat |
||||
{ |
{ |
||||
public class ChatGroupConsts |
public class ChatGroupConsts |
||||
{ |
{ |
||||
@ -1,4 +1,4 @@ |
|||||
namespace LINGYUN.Abp.MessageService.Messages |
namespace LINGYUN.Abp.MessageService.Chat |
||||
{ |
{ |
||||
public class MessageConsts |
public class MessageConsts |
||||
{ |
{ |
||||
@ -1,10 +1,8 @@ |
|||||
using System; |
using System; |
||||
using System.Collections.Generic; |
|
||||
using System.Linq; |
|
||||
using Volo.Abp.Domain.Entities.Auditing; |
using Volo.Abp.Domain.Entities.Auditing; |
||||
using Volo.Abp.MultiTenancy; |
using Volo.Abp.MultiTenancy; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Messages |
namespace LINGYUN.Abp.MessageService.Chat |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 聊天群组
|
/// 聊天群组
|
||||
@ -1,7 +1,7 @@ |
|||||
using LINGYUN.Abp.IM.Messages; |
using LINGYUN.Abp.IM.Messages; |
||||
using System; |
using System; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Messages |
namespace LINGYUN.Abp.MessageService.Chat |
||||
{ |
{ |
||||
public class GroupMessage : Message |
public class GroupMessage : Message |
||||
{ |
{ |
||||
@ -0,0 +1,30 @@ |
|||||
|
using LINGYUN.Abp.IM.Messages; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Chat |
||||
|
{ |
||||
|
public interface IMessageRepository |
||||
|
{ |
||||
|
Task<UserMessage> InsertUserMessageAsync(UserMessage userMessage, bool saveChangs = false); |
||||
|
|
||||
|
Task<GroupMessage> InsertGroupMessageAsync(GroupMessage groupMessage, bool saveChangs = false); |
||||
|
|
||||
|
Task<UserMessage> GetUserMessageAsync(long id); |
||||
|
|
||||
|
Task<GroupMessage> GetGroupMessageAsync(long id); |
||||
|
|
||||
|
Task<long> GetUserMessagesCountAsync(Guid sendUserId, Guid receiveUserId, string filter = "", MessageType? type = null); |
||||
|
|
||||
|
Task<List<UserMessage>> GetUserMessagesAsync(Guid sendUserId, Guid receiveUserId, string filter = "", string sorting = nameof(UserMessage.MessageId), MessageType? type = null, int skipCount = 1, int maxResultCount = 10); |
||||
|
|
||||
|
Task<long> GetGroupMessagesCountAsync(long groupId, string filter = "", MessageType? type = null); |
||||
|
|
||||
|
Task<List<GroupMessage>> GetGroupMessagesAsync(long groupId, string filter = "", string sorting = nameof(UserMessage.MessageId), MessageType? type = null, int skipCount = 1, int maxResultCount = 10); |
||||
|
|
||||
|
Task<long> GetUserGroupMessagesCountAsync(Guid sendUserId, long groupId, string filter = "", MessageType? type = null); |
||||
|
|
||||
|
Task<List<GroupMessage>> GetUserGroupMessagesAsync(Guid sendUserId, long groupId, string filter = "", string sorting = nameof(UserMessage.MessageId), MessageType? type = null, int skipCount = 1, int maxResultCount = 10); |
||||
|
} |
||||
|
} |
||||
@ -1,7 +1,7 @@ |
|||||
using LINGYUN.Abp.IM.Messages; |
using LINGYUN.Abp.IM.Messages; |
||||
using System; |
using System; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Messages |
namespace LINGYUN.Abp.MessageService.Chat |
||||
{ |
{ |
||||
public class UserMessage : Message |
public class UserMessage : Message |
||||
{ |
{ |
||||
@ -1,24 +0,0 @@ |
|||||
using LINGYUN.Abp.IM.Messages; |
|
||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Threading.Tasks; |
|
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Messages |
|
||||
{ |
|
||||
public interface IMessageRepository |
|
||||
{ |
|
||||
Task<UserMessage> InsertUserMessageAsync(UserMessage userMessage, bool saveChangs = false); |
|
||||
|
|
||||
Task<GroupMessage> InsertGroupMessageAsync(GroupMessage groupMessage, bool saveChangs = false); |
|
||||
|
|
||||
Task<UserMessage> GetUserMessageAsync(long id); |
|
||||
|
|
||||
Task<GroupMessage> GetGroupMessageAsync(long id); |
|
||||
|
|
||||
Task<List<UserMessage>> GetUserMessagesAsync(Guid sendUserId, Guid receiveUserId, string filter = "", MessageType type = MessageType.Text, int skipCount = 1, int maxResultCount = 10); |
|
||||
|
|
||||
Task<List<GroupMessage>> GetGroupMessagesAsync(long groupId, string filter = "", MessageType type = MessageType.Text, int skipCount = 1, int maxResultCount = 10); |
|
||||
|
|
||||
Task<List<GroupMessage>> GetUserGroupMessagesAsync(Guid sendUserId, long groupId, string filter = "", MessageType type = MessageType.Text, int skipCount = 1, int maxResultCount = 10); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,78 @@ |
|||||
|
using LINGYUN.Abp.IM.Group; |
||||
|
using LINGYUN.Abp.IM.Messages; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Chat |
||||
|
{ |
||||
|
[RemoteService(Name = AbpMessageServiceConsts.RemoteServiceName)] |
||||
|
[Route("api/chat")] |
||||
|
public class ChatController : AbpController, IChatAppService |
||||
|
{ |
||||
|
private readonly IChatAppService _chatAppService; |
||||
|
|
||||
|
public ChatController(IChatAppService chatAppService) |
||||
|
{ |
||||
|
_chatAppService = chatAppService; |
||||
|
} |
||||
|
|
||||
|
[HttpPost] |
||||
|
[Route("groups/join")] |
||||
|
public virtual async Task ApplyJoinGroupAsync(UserJoinGroupDto userJoinGroup) |
||||
|
{ |
||||
|
await _chatAppService.ApplyJoinGroupAsync(userJoinGroup); |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("messages/group")] |
||||
|
public virtual async Task<PagedResultDto<ChatMessage>> GetGroupMessageAsync(GroupMessageGetByPagedDto groupMessageGetByPaged) |
||||
|
{ |
||||
|
return await _chatAppService.GetGroupMessageAsync(groupMessageGetByPaged); |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("groups/users")] |
||||
|
public virtual async Task<PagedResultDto<UserGroup>> GetGroupUsersAsync(GroupUserGetByPagedDto groupUserGetByPaged) |
||||
|
{ |
||||
|
return await _chatAppService.GetGroupUsersAsync(groupUserGetByPaged); |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("messages/me")] |
||||
|
public virtual async Task<PagedResultDto<ChatMessage>> GetMyChatMessageAsync(UserMessageGetByPagedDto userMessageGetByPaged) |
||||
|
{ |
||||
|
return await _chatAppService.GetMyChatMessageAsync(userMessageGetByPaged); |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("groups/me")] |
||||
|
public virtual async Task<ListResultDto<Group>> GetMyGroupsAsync() |
||||
|
{ |
||||
|
return await _chatAppService.GetMyGroupsAsync(); |
||||
|
} |
||||
|
|
||||
|
[HttpPost] |
||||
|
[Route("groups/users/accept")] |
||||
|
public virtual async Task GroupAcceptUserAsync(GroupAcceptUserDto groupAcceptUser) |
||||
|
{ |
||||
|
await _chatAppService.GroupAcceptUserAsync(groupAcceptUser); |
||||
|
} |
||||
|
|
||||
|
[HttpDelete] |
||||
|
[Route("groups/users/remove")] |
||||
|
public virtual async Task GroupRemoveUserAsync(GroupRemoveUserDto groupRemoveUser) |
||||
|
{ |
||||
|
await _chatAppService.GroupRemoveUserAsync(groupRemoveUser); |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("messages/send")] |
||||
|
public virtual async Task<ChatMessageSendResultDto> SendMessageAsync(ChatMessage chatMessage) |
||||
|
{ |
||||
|
return await _chatAppService.SendMessageAsync(chatMessage); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,56 @@ |
|||||
|
using LINGYUN.Abp.Notifications; |
||||
|
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.Notifications |
||||
|
{ |
||||
|
[RemoteService(Name = AbpMessageServiceConsts.RemoteServiceName)] |
||||
|
[Route("api/notifications")] |
||||
|
public class NotificationController : AbpController, INotificationAppService |
||||
|
{ |
||||
|
private readonly INotificationAppService _notificationAppService; |
||||
|
public NotificationController( |
||||
|
INotificationAppService notificationAppService) |
||||
|
{ |
||||
|
_notificationAppService = notificationAppService; |
||||
|
} |
||||
|
|
||||
|
[HttpPut] |
||||
|
[Route("ChangeReadState")] |
||||
|
public virtual async Task ChangeUserNotificationReadStateAsync(UserNotificationChangeReadStateDto userNotificationChangeRead) |
||||
|
{ |
||||
|
await _notificationAppService.ChangeUserNotificationReadStateAsync(userNotificationChangeRead); |
||||
|
} |
||||
|
|
||||
|
[HttpDelete] |
||||
|
[Route("{NotificationId}")] |
||||
|
public virtual async Task DeleteAsync(NotificationGetByIdDto notificationGetById) |
||||
|
{ |
||||
|
await _notificationAppService.DeleteAsync(notificationGetById); |
||||
|
} |
||||
|
|
||||
|
[HttpDelete] |
||||
|
[Route("User/{NotificationId}")] |
||||
|
public virtual async Task DeleteUserNotificationAsync(NotificationGetByIdDto notificationGetById) |
||||
|
{ |
||||
|
await _notificationAppService.DeleteUserNotificationAsync(notificationGetById); |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("{NotificationId}")] |
||||
|
public virtual async Task<NotificationInfo> GetAsync(NotificationGetByIdDto notificationGetById) |
||||
|
{ |
||||
|
return await _notificationAppService.GetAsync(notificationGetById); |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("User/{NotificationId}")] |
||||
|
public virtual async Task<PagedResultDto<NotificationInfo>> GetUserNotificationsAsync(UserNotificationGetByPagedDto userNotificationGetByPaged) |
||||
|
{ |
||||
|
return await _notificationAppService.GetUserNotificationsAsync(userNotificationGetByPaged); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
using LINGYUN.Abp.Notifications; |
||||
|
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.Subscriptions |
||||
|
{ |
||||
|
[RemoteService(Name = AbpMessageServiceConsts.RemoteServiceName)] |
||||
|
[Route("api/subscribes")] |
||||
|
public class SubscriptionController : AbpController, ISubscriptionAppService |
||||
|
{ |
||||
|
private readonly ISubscriptionAppService _subscriptionAppService; |
||||
|
|
||||
|
public SubscriptionController( |
||||
|
ISubscriptionAppService subscriptionAppService) |
||||
|
{ |
||||
|
_subscriptionAppService = subscriptionAppService; |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
public virtual async Task<PagedResultDto<NotificationSubscriptionInfo>> GetSubscribedsAsync(SubscriptionsGetByPagedDto subscriptionsGetByPaged) |
||||
|
{ |
||||
|
return await _subscriptionAppService.GetSubscribedsAsync(subscriptionsGetByPaged); |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("IsSubscribed/{NotificationName}")] |
||||
|
public virtual async Task<bool> IsSubscribedAsync(SubscriptionsGetByNameDto subscriptionsGetByName) |
||||
|
{ |
||||
|
return await _subscriptionAppService.IsSubscribedAsync(subscriptionsGetByName); |
||||
|
} |
||||
|
|
||||
|
[HttpPost] |
||||
|
public virtual async Task SubscribeAsync(SubscriptionsGetByNameDto subscriptionsGetByName) |
||||
|
{ |
||||
|
await _subscriptionAppService.SubscribeAsync(subscriptionsGetByName); |
||||
|
} |
||||
|
|
||||
|
[HttpDelete] |
||||
|
public virtual async Task UnSubscribeAsync(SubscriptionsGetByNameDto subscriptionsGetByName) |
||||
|
{ |
||||
|
await _subscriptionAppService.UnSubscribeAsync(subscriptionsGetByName); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,268 +0,0 @@ |
|||||
using Microsoft.Extensions.DependencyInjection; |
|
||||
using Microsoft.Extensions.Localization; |
|
||||
using Microsoft.Extensions.Logging; |
|
||||
using Microsoft.Extensions.Options; |
|
||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Globalization; |
|
||||
using System.Linq; |
|
||||
using System.Threading.Tasks; |
|
||||
using Volo.Abp.Application.Services; |
|
||||
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; |
|
||||
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; |
|
||||
using Volo.Abp.AspNetCore.Mvc.MultiTenancy; |
|
||||
using Volo.Abp.Authorization.Permissions; |
|
||||
using Volo.Abp.Clients; |
|
||||
using Volo.Abp.DependencyInjection; |
|
||||
using Volo.Abp.EventBus.Local; |
|
||||
using Volo.Abp.Features; |
|
||||
using Volo.Abp.Localization; |
|
||||
using Volo.Abp.MultiTenancy; |
|
||||
using Volo.Abp.PermissionManagement; |
|
||||
using Volo.Abp.Settings; |
|
||||
using Volo.Abp.Users; |
|
||||
|
|
||||
namespace LINGYUN.Platform.AspNetCore.Mvc.ApplicationConfigurations |
|
||||
{ |
|
||||
[Dependency(ServiceLifetime.Transient)] |
|
||||
[ExposeServices(typeof(IAbpApplicationConfigurationAppService))] |
|
||||
public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApplicationConfigurationAppService |
|
||||
{ |
|
||||
private readonly AbpLocalizationOptions _localizationOptions; |
|
||||
private readonly AbpMultiTenancyOptions _multiTenancyOptions; |
|
||||
private readonly IServiceProvider _serviceProvider; |
|
||||
private readonly ISettingProvider _settingProvider; |
|
||||
private readonly ISettingDefinitionManager _settingDefinitionManager; |
|
||||
private readonly IFeatureDefinitionManager _featureDefinitionManager; |
|
||||
private readonly IPermissionGrantRepository _permissionGrantRepository; |
|
||||
private readonly IPermissionDefinitionManager _permissionDefinitionManager; |
|
||||
private readonly ILanguageProvider _languageProvider; |
|
||||
private readonly ICachedObjectExtensionsDtoService _cachedObjectExtensionsDtoService; |
|
||||
|
|
||||
private ICurrentClient _currentClient; |
|
||||
|
|
||||
protected ICurrentClient CurrentClient => LazyGetRequiredService(ref _currentClient); |
|
||||
|
|
||||
private ILocalEventBus _localEventBus; |
|
||||
//用于发布权限事件,每次请求此接口后,通过事件总线来缓存权限
|
|
||||
protected ILocalEventBus LocalEventBus => LazyGetRequiredService(ref _localEventBus); |
|
||||
|
|
||||
public AbpApplicationConfigurationAppService( |
|
||||
IOptions<AbpLocalizationOptions> localizationOptions, |
|
||||
IOptions<AbpMultiTenancyOptions> multiTenancyOptions, |
|
||||
IServiceProvider serviceProvider, |
|
||||
ISettingProvider settingProvider, |
|
||||
ISettingDefinitionManager settingDefinitionManager, |
|
||||
IFeatureDefinitionManager featureDefinitionManager, |
|
||||
IPermissionGrantRepository permissionGrantRepository, |
|
||||
IPermissionDefinitionManager permissionDefinitionManager, |
|
||||
ILanguageProvider languageProvider, |
|
||||
ICachedObjectExtensionsDtoService cachedObjectExtensionsDtoService) |
|
||||
{ |
|
||||
_serviceProvider = serviceProvider; |
|
||||
_settingProvider = settingProvider; |
|
||||
_settingDefinitionManager = settingDefinitionManager; |
|
||||
_featureDefinitionManager = featureDefinitionManager; |
|
||||
_permissionGrantRepository = permissionGrantRepository; |
|
||||
_permissionDefinitionManager = permissionDefinitionManager; |
|
||||
_languageProvider = languageProvider; |
|
||||
_cachedObjectExtensionsDtoService = cachedObjectExtensionsDtoService; |
|
||||
_localizationOptions = localizationOptions.Value; |
|
||||
_multiTenancyOptions = multiTenancyOptions.Value; |
|
||||
} |
|
||||
|
|
||||
public virtual async Task<ApplicationConfigurationDto> GetAsync() |
|
||||
{ |
|
||||
//TODO: Optimize & cache..?
|
|
||||
|
|
||||
Logger.LogDebug("Executing AbpApplicationConfigurationAppService.GetAsync()..."); |
|
||||
|
|
||||
var result = new ApplicationConfigurationDto |
|
||||
{ |
|
||||
Auth = await GetAuthConfigAsync(), |
|
||||
Features = await GetFeaturesConfigAsync(), |
|
||||
Localization = await GetLocalizationConfigAsync(), |
|
||||
CurrentUser = GetCurrentUser(), |
|
||||
Setting = await GetSettingConfigAsync(), |
|
||||
MultiTenancy = GetMultiTenancy(), |
|
||||
CurrentTenant = GetCurrentTenant(), |
|
||||
ObjectExtensions = _cachedObjectExtensionsDtoService.Get() |
|
||||
}; |
|
||||
|
|
||||
Logger.LogDebug("Executed AbpApplicationConfigurationAppService.GetAsync()."); |
|
||||
|
|
||||
return result; |
|
||||
} |
|
||||
|
|
||||
protected virtual CurrentTenantDto GetCurrentTenant() |
|
||||
{ |
|
||||
return new CurrentTenantDto() |
|
||||
{ |
|
||||
Id = CurrentTenant.Id, |
|
||||
Name = CurrentTenant.Name, |
|
||||
IsAvailable = CurrentTenant.IsAvailable |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
protected virtual MultiTenancyInfoDto GetMultiTenancy() |
|
||||
{ |
|
||||
return new MultiTenancyInfoDto |
|
||||
{ |
|
||||
IsEnabled = _multiTenancyOptions.IsEnabled |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
protected virtual CurrentUserDto GetCurrentUser() |
|
||||
{ |
|
||||
return new CurrentUserDto |
|
||||
{ |
|
||||
IsAuthenticated = CurrentUser.IsAuthenticated, |
|
||||
Id = CurrentUser.Id, |
|
||||
TenantId = CurrentUser.TenantId, |
|
||||
UserName = CurrentUser.UserName, |
|
||||
Email = CurrentUser.Email |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
protected virtual async Task<ApplicationAuthConfigurationDto> GetAuthConfigAsync() |
|
||||
{ |
|
||||
var authConfig = new ApplicationAuthConfigurationDto(); |
|
||||
|
|
||||
var permissions = _permissionDefinitionManager.GetPermissions(); |
|
||||
|
|
||||
IEnumerable<PermissionGrant> grantPermissions = new List<PermissionGrant>(); |
|
||||
|
|
||||
// TODO: 重写为每次调用接口都在数据库统一查询权限
|
|
||||
// 待框架改进权限Provider机制后再移除
|
|
||||
|
|
||||
// 如果用户已登录,获取用户和角色权限
|
|
||||
if (CurrentUser.IsAuthenticated) |
|
||||
{ |
|
||||
var userPermissions = await _permissionGrantRepository.GetListAsync(UserPermissionValueProvider.ProviderName, |
|
||||
CurrentUser.GetId().ToString()); |
|
||||
grantPermissions = grantPermissions.Union(userPermissions); |
|
||||
foreach(var userRole in CurrentUser.Roles) |
|
||||
{ |
|
||||
var rolePermissions = await _permissionGrantRepository.GetListAsync(RolePermissionValueProvider.ProviderName, |
|
||||
userRole); |
|
||||
grantPermissions = grantPermissions.Union(rolePermissions); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// 如果客户端已验证,获取客户端权限
|
|
||||
if(CurrentClient.IsAuthenticated) |
|
||||
{ |
|
||||
var clientPermissions = await _permissionGrantRepository.GetListAsync(ClientPermissionValueProvider.ProviderName, |
|
||||
CurrentClient.Id); |
|
||||
grantPermissions = grantPermissions.Union(clientPermissions); |
|
||||
} |
|
||||
|
|
||||
foreach(var permission in permissions) |
|
||||
{ |
|
||||
authConfig.Policies[permission.Name] = true; |
|
||||
if(grantPermissions.Any(p => p.Name.Equals(permission.Name))) |
|
||||
{ |
|
||||
authConfig.GrantedPolicies[permission.Name] = true; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return authConfig; |
|
||||
} |
|
||||
|
|
||||
protected virtual async Task<ApplicationLocalizationConfigurationDto> GetLocalizationConfigAsync() |
|
||||
{ |
|
||||
var localizationConfig = new ApplicationLocalizationConfigurationDto(); |
|
||||
|
|
||||
localizationConfig.Languages.AddRange(await _languageProvider.GetLanguagesAsync()); |
|
||||
|
|
||||
foreach (var resource in _localizationOptions.Resources.Values) |
|
||||
{ |
|
||||
var dictionary = new Dictionary<string, string>(); |
|
||||
|
|
||||
var localizer = _serviceProvider.GetRequiredService( |
|
||||
typeof(IStringLocalizer<>).MakeGenericType(resource.ResourceType) |
|
||||
) as IStringLocalizer; |
|
||||
|
|
||||
foreach (var localizedString in localizer.GetAllStrings()) |
|
||||
{ |
|
||||
dictionary[localizedString.Name] = localizedString.Value; |
|
||||
} |
|
||||
|
|
||||
localizationConfig.Values[resource.ResourceName] = dictionary; |
|
||||
} |
|
||||
|
|
||||
localizationConfig.CurrentCulture = GetCurrentCultureInfo(); |
|
||||
|
|
||||
if (_localizationOptions.DefaultResourceType != null) |
|
||||
{ |
|
||||
localizationConfig.DefaultResourceName = LocalizationResourceNameAttribute.GetName( |
|
||||
_localizationOptions.DefaultResourceType |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
return localizationConfig; |
|
||||
} |
|
||||
|
|
||||
private static CurrentCultureDto GetCurrentCultureInfo() |
|
||||
{ |
|
||||
return new CurrentCultureDto |
|
||||
{ |
|
||||
Name = CultureInfo.CurrentUICulture.Name, |
|
||||
DisplayName = CultureInfo.CurrentUICulture.DisplayName, |
|
||||
EnglishName = CultureInfo.CurrentUICulture.EnglishName, |
|
||||
NativeName = CultureInfo.CurrentUICulture.NativeName, |
|
||||
IsRightToLeft = CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft, |
|
||||
CultureName = CultureInfo.CurrentUICulture.TextInfo.CultureName, |
|
||||
TwoLetterIsoLanguageName = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName, |
|
||||
ThreeLetterIsoLanguageName = CultureInfo.CurrentUICulture.ThreeLetterISOLanguageName, |
|
||||
DateTimeFormat = new DateTimeFormatDto |
|
||||
{ |
|
||||
CalendarAlgorithmType = CultureInfo.CurrentUICulture.DateTimeFormat.Calendar.AlgorithmType.ToString(), |
|
||||
DateTimeFormatLong = CultureInfo.CurrentUICulture.DateTimeFormat.LongDatePattern, |
|
||||
ShortDatePattern = CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern, |
|
||||
FullDateTimePattern = CultureInfo.CurrentUICulture.DateTimeFormat.FullDateTimePattern, |
|
||||
DateSeparator = CultureInfo.CurrentUICulture.DateTimeFormat.DateSeparator, |
|
||||
ShortTimePattern = CultureInfo.CurrentUICulture.DateTimeFormat.ShortTimePattern, |
|
||||
LongTimePattern = CultureInfo.CurrentUICulture.DateTimeFormat.LongTimePattern, |
|
||||
} |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
private async Task<ApplicationSettingConfigurationDto> GetSettingConfigAsync() |
|
||||
{ |
|
||||
var result = new ApplicationSettingConfigurationDto |
|
||||
{ |
|
||||
Values = new Dictionary<string, string>() |
|
||||
}; |
|
||||
|
|
||||
foreach (var settingDefinition in _settingDefinitionManager.GetAll()) |
|
||||
{ |
|
||||
if (!settingDefinition.IsVisibleToClients) |
|
||||
{ |
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
result.Values[settingDefinition.Name] = await _settingProvider.GetOrNullAsync(settingDefinition.Name); |
|
||||
} |
|
||||
|
|
||||
return result; |
|
||||
} |
|
||||
|
|
||||
protected virtual async Task<ApplicationFeatureConfigurationDto> GetFeaturesConfigAsync() |
|
||||
{ |
|
||||
var result = new ApplicationFeatureConfigurationDto(); |
|
||||
|
|
||||
foreach (var featureDefinition in _featureDefinitionManager.GetAll()) |
|
||||
{ |
|
||||
if (!featureDefinition.IsVisibleToClients) |
|
||||
{ |
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
result.Values[featureDefinition.Name] = await FeatureChecker.GetOrNullAsync(featureDefinition.Name); |
|
||||
} |
|
||||
|
|
||||
return result; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,115 @@ |
|||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; |
||||
|
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; |
||||
|
using Volo.Abp.Authorization; |
||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using Volo.Abp.Clients; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Features; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
using Volo.Abp.PermissionManagement; |
||||
|
using Volo.Abp.Settings; |
||||
|
using Volo.Abp.Timing; |
||||
|
using Volo.Abp.Users; |
||||
|
|
||||
|
namespace LINGYUN.Platform.AspNetCore.Mvc.ApplicationConfigurations |
||||
|
{ |
||||
|
[Dependency(ServiceLifetime.Transient, ReplaceServices = true)] |
||||
|
[ExposeServices(typeof(IAbpApplicationConfigurationAppService), typeof(AbpApplicationConfigurationAppService))] |
||||
|
public class ApplicationConfigurationAppService : AbpApplicationConfigurationAppService |
||||
|
{ |
||||
|
private readonly IPermissionGrantRepository _permissionGrantRepository; |
||||
|
private readonly IPermissionDefinitionManager _permissionDefinitionManager; |
||||
|
|
||||
|
private ICurrentClient _currentClient; |
||||
|
|
||||
|
protected ICurrentClient CurrentClient => LazyGetRequiredService(ref _currentClient); |
||||
|
|
||||
|
public ApplicationConfigurationAppService( |
||||
|
IOptions<AbpLocalizationOptions> localizationOptions, |
||||
|
IOptions<AbpMultiTenancyOptions> multiTenancyOptions, |
||||
|
IServiceProvider serviceProvider, |
||||
|
IAbpAuthorizationPolicyProvider abpAuthorizationPolicyProvider, |
||||
|
IAuthorizationService authorizationService, |
||||
|
ICurrentUser currentUser, |
||||
|
ISettingProvider settingProvider, |
||||
|
ISettingDefinitionManager settingDefinitionManager, |
||||
|
IFeatureDefinitionManager featureDefinitionManager, |
||||
|
ILanguageProvider languageProvider, |
||||
|
ITimezoneProvider timezoneProvider, |
||||
|
IOptions<AbpClockOptions> abpClockOptions, |
||||
|
ICachedObjectExtensionsDtoService cachedObjectExtensionsDtoService, |
||||
|
IPermissionGrantRepository permissionGrantRepository, |
||||
|
IPermissionDefinitionManager permissionDefinitionManager) |
||||
|
: base( |
||||
|
localizationOptions, |
||||
|
multiTenancyOptions, |
||||
|
serviceProvider, |
||||
|
abpAuthorizationPolicyProvider, |
||||
|
authorizationService, |
||||
|
currentUser, |
||||
|
settingProvider, |
||||
|
settingDefinitionManager, |
||||
|
featureDefinitionManager, |
||||
|
languageProvider, |
||||
|
timezoneProvider, |
||||
|
abpClockOptions, |
||||
|
cachedObjectExtensionsDtoService) |
||||
|
{ |
||||
|
_permissionGrantRepository = permissionGrantRepository; |
||||
|
_permissionDefinitionManager = permissionDefinitionManager; |
||||
|
|
||||
|
} |
||||
|
protected override async Task<ApplicationAuthConfigurationDto> GetAuthConfigAsync() |
||||
|
{ |
||||
|
var authConfig = new ApplicationAuthConfigurationDto(); |
||||
|
|
||||
|
var permissions = _permissionDefinitionManager.GetPermissions(); |
||||
|
|
||||
|
IEnumerable<PermissionGrant> grantPermissions = new List<PermissionGrant>(); |
||||
|
|
||||
|
// TODO: 重写为每次调用接口都在数据库统一查询权限
|
||||
|
// 待框架改进权限Provider机制后再移除
|
||||
|
|
||||
|
// 如果用户已登录,获取用户和角色权限
|
||||
|
if (CurrentUser.IsAuthenticated) |
||||
|
{ |
||||
|
var userPermissions = await _permissionGrantRepository.GetListAsync(UserPermissionValueProvider.ProviderName, |
||||
|
CurrentUser.GetId().ToString()); |
||||
|
grantPermissions = grantPermissions.Union(userPermissions); |
||||
|
foreach(var userRole in CurrentUser.Roles) |
||||
|
{ |
||||
|
var rolePermissions = await _permissionGrantRepository.GetListAsync(RolePermissionValueProvider.ProviderName, |
||||
|
userRole); |
||||
|
grantPermissions = grantPermissions.Union(rolePermissions); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 如果客户端已验证,获取客户端权限
|
||||
|
if(CurrentClient.IsAuthenticated) |
||||
|
{ |
||||
|
var clientPermissions = await _permissionGrantRepository.GetListAsync(ClientPermissionValueProvider.ProviderName, |
||||
|
CurrentClient.Id); |
||||
|
grantPermissions = grantPermissions.Union(clientPermissions); |
||||
|
} |
||||
|
|
||||
|
foreach(var permission in permissions) |
||||
|
{ |
||||
|
authConfig.Policies[permission.Name] = true; |
||||
|
if(grantPermissions.Any(p => p.Name.Equals(permission.Name))) |
||||
|
{ |
||||
|
authConfig.GrantedPolicies[permission.Name] = true; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return authConfig; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue