Пример #1
0
        /// <summary>
        /// 移除群组成员
        /// </summary>
        /// <param name="groupId">群组Id</param>
        /// <param name="userId">用户Id</param>
        public void DeleteGroupMember(long groupId, long userId)
        {
            GroupMember groupMember = groupMemberRepository.GetMember(groupId, userId);

            if (groupMember == null)
            {
                return;
            }

            int affectCount = groupMemberRepository.Delete(groupMember);

            if (affectCount > 0)
            {
                EventBus <GroupMember> .Instance().OnAfter(groupMember, new CommonEventArgs(EventOperationType.Instance().Delete()));

                //用户的参与群组数-1
                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(userId, OwnerDataKeys.Instance().JoinedGroupCount(), -1);
            }
        }