|
@@ -7,6 +7,10 @@ using System.Threading.Tasks;
|
|
|
using GxPress.Repository.Interface;
|
|
|
using Datory;
|
|
|
using System.Linq;
|
|
|
+using GxPress.EnumConst;
|
|
|
+using GxPress.Repository.Interface.DepartmentUser;
|
|
|
+using GxPress.Repository.Interface.Friends;
|
|
|
+
|
|
|
namespace GxPress.Service.Implement.UserMiddle
|
|
|
{
|
|
|
public class UserMiddleService : IUserMiddleService
|
|
@@ -18,7 +22,9 @@ namespace GxPress.Service.Implement.UserMiddle
|
|
|
private readonly IDepartmentRepository _departmentRepository;
|
|
|
private readonly IGroupChatUserRepository groupChatUserRepository;
|
|
|
private readonly IGroupUserRepository groupUserRepository;
|
|
|
- public UserMiddleService(IUserMiddleRepository userMiddleRepository, IUserRepository userRepository, IAddressBookGroupUserRepository addressBookGroupUserRepository, IDepartmentRepository departmentRepository, IAddressBookGroupRepository addressBookGroupRepository, IGroupChatUserRepository groupChatUserRepository, IGroupUserRepository groupUserRepository)
|
|
|
+ private readonly IDepartmentUserRepository departmentUserRepository;
|
|
|
+ private readonly IFriendsRepository friendsRepository;
|
|
|
+ public UserMiddleService(IUserMiddleRepository userMiddleRepository, IUserRepository userRepository, IAddressBookGroupUserRepository addressBookGroupUserRepository, IDepartmentRepository departmentRepository, IAddressBookGroupRepository addressBookGroupRepository, IGroupChatUserRepository groupChatUserRepository, IGroupUserRepository groupUserRepository, IDepartmentUserRepository departmentUserRepository, IFriendsRepository friendsRepository)
|
|
|
{
|
|
|
_userMiddleRepoitory = userMiddleRepository;
|
|
|
_userRepoitory = userRepository;
|
|
@@ -27,6 +33,8 @@ namespace GxPress.Service.Implement.UserMiddle
|
|
|
_addressBookGroupRepository = addressBookGroupRepository;
|
|
|
this.groupChatUserRepository = groupChatUserRepository;
|
|
|
this.groupUserRepository = groupUserRepository;
|
|
|
+ this.departmentUserRepository = departmentUserRepository;
|
|
|
+ this.friendsRepository = friendsRepository;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 添加用户中间表
|
|
@@ -99,28 +107,30 @@ namespace GxPress.Service.Implement.UserMiddle
|
|
|
|
|
|
foreach (var userMiddle in userMiddles)
|
|
|
{
|
|
|
- if (userMiddle.SourceType != 0)
|
|
|
+ if (userMiddle.SourceType != UserlinkConst.User.GetHashCode())
|
|
|
{
|
|
|
- if (userMiddle.SourceType == 1)
|
|
|
+ if (userMiddle.SourceType == UserlinkConst.Work.GetHashCode())
|
|
|
{
|
|
|
if (userMiddle.SourceId == 0)
|
|
|
//获取所有用户
|
|
|
- userIds.AddRange(await _userRepoitory.GetAllIntsAsync(Q.Select(nameof(Entity.User.Id)).Where(nameof(Entity.User.Id), ">", 0)));
|
|
|
+ userIds.AddRange(await departmentUserRepository.GetUserIdsByUserIdAsync(userId));
|
|
|
else
|
|
|
{
|
|
|
//递归获取部门
|
|
|
var departments = new List<Entity.Department>();
|
|
|
departments = await _departmentRepository.GetDepartmentById(userMiddle.SourceId, departments);
|
|
|
- userIds.AddRange(await _userRepoitory.GetAllIntsAsync(Q.WhereIn(nameof(Entity.User.DepartmentId), departments.Select(n => n.Id))));
|
|
|
+ //获取部门用户
|
|
|
+ userIds.AddRange(await departmentUserRepository.GetUserIdsByDepartmentIdsAsync(departments.Select(n => n.Id)));
|
|
|
}
|
|
|
}
|
|
|
- if (userMiddle.SourceType == 2)
|
|
|
+ //系统
|
|
|
+ if (userMiddle.SourceType == UserlinkConst.System.GetHashCode())
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 我的小组
|
|
|
/// </summary>
|
|
|
/// <value></value>
|
|
|
- if (userMiddle.SourceTypeValue == 1)
|
|
|
+ if (userMiddle.SourceTypeValue == UserlinkConst.MyGroup.GetHashCode())
|
|
|
{
|
|
|
if (userMiddle.SourceId == 0)
|
|
|
{
|
|
@@ -136,7 +146,7 @@ namespace GxPress.Service.Implement.UserMiddle
|
|
|
/// 我的群聊
|
|
|
/// </summary>
|
|
|
/// <value></value>
|
|
|
- if (userMiddle.SourceTypeValue == 2)
|
|
|
+ if (userMiddle.SourceTypeValue == UserlinkConst.MyGroupChat.GetHashCode())
|
|
|
{
|
|
|
if (userMiddle.SourceId == 0)
|
|
|
{
|
|
@@ -149,7 +159,7 @@ namespace GxPress.Service.Implement.UserMiddle
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (userMiddle.SourceType == 3)
|
|
|
+ if (userMiddle.SourceType == UserlinkConst.My.GetHashCode())
|
|
|
{
|
|
|
if (userMiddle.SourceId == 0)
|
|
|
{
|
|
@@ -164,6 +174,11 @@ namespace GxPress.Service.Implement.UserMiddle
|
|
|
userIds.AddRange(addressBookGroupUsers.Select(n => n.UserId).ToList());
|
|
|
}
|
|
|
}
|
|
|
+ if (userMiddle.SourceType == UserlinkConst.Other.GetHashCode())
|
|
|
+ {
|
|
|
+ if (userMiddle.SourceId == 0)
|
|
|
+ userIds.AddRange(await friendsRepository.GetFriendsIdsAsync(userId, 0));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (userIds.Count() > 0)
|