|
@@ -16,13 +16,17 @@ namespace GxPress.Service.Implement.UserMiddle
|
|
|
private readonly IAddressBookGroupUserRepository _addressBookGroupUserRepository;
|
|
|
private readonly IAddressBookGroupRepository _addressBookGroupRepository;
|
|
|
private readonly IDepartmentRepository _departmentRepository;
|
|
|
- public UserMiddleService(IUserMiddleRepository userMiddleRepository, IUserRepository userRepository, IAddressBookGroupUserRepository addressBookGroupUserRepository, IDepartmentRepository departmentRepository, IAddressBookGroupRepository addressBookGroupRepository)
|
|
|
+ private readonly IGroupChatUserRepository groupChatUserRepository;
|
|
|
+ private readonly IGroupUserRepository groupUserRepository;
|
|
|
+ public UserMiddleService(IUserMiddleRepository userMiddleRepository, IUserRepository userRepository, IAddressBookGroupUserRepository addressBookGroupUserRepository, IDepartmentRepository departmentRepository, IAddressBookGroupRepository addressBookGroupRepository, IGroupChatUserRepository groupChatUserRepository, IGroupUserRepository groupUserRepository)
|
|
|
{
|
|
|
_userMiddleRepoitory = userMiddleRepository;
|
|
|
_userRepoitory = userRepository;
|
|
|
_addressBookGroupUserRepository = addressBookGroupUserRepository;
|
|
|
_departmentRepository = departmentRepository;
|
|
|
_addressBookGroupRepository = addressBookGroupRepository;
|
|
|
+ this.groupChatUserRepository = groupChatUserRepository;
|
|
|
+ this.groupUserRepository = groupUserRepository;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 添加用户中间表
|
|
@@ -39,6 +43,7 @@ namespace GxPress.Service.Implement.UserMiddle
|
|
|
var userMiddleDto = new Entity.UserMiddle.UserMiddle();
|
|
|
userMiddleDto.SourceId = userMiddle.SourceId;
|
|
|
userMiddleDto.SourceType = userMiddle.SourceType;
|
|
|
+ userMiddleDto.SourceTypeValue = userMiddle.SourceTypeValue;
|
|
|
userMiddleDto.MiddleType = userMiddle.MiddleType;
|
|
|
userMiddleDto.SourceName = userMiddle.SourceName;
|
|
|
userMiddleDto.DataSourceId = userMiddle.DataSourceId;
|
|
@@ -61,12 +66,12 @@ namespace GxPress.Service.Implement.UserMiddle
|
|
|
return await _userMiddleRepoitory.DeleteAsync(query);
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 删除收件人
|
|
|
- /// </summary>
|
|
|
- /// <param name="dataSourceId"></param>
|
|
|
- /// <param name="middleType">类型类型 1 通知 2话题 3 收藏 4笔记 5 普通站内信 6匿名站内信 7小组 10:通知收件人 20:通知抄送人 30:站内信收集人 40:站内信抄送人 400 会议纪要</param>
|
|
|
- /// <returns></returns>
|
|
|
+ /// <summary>
|
|
|
+ /// 删除收件人
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dataSourceId"></param>
|
|
|
+ /// <param name="middleType">类型类型 1 通知 2话题 3 收藏 4笔记 5 普通站内信 6匿名站内信 7小组 10:通知收件人 20:通知抄送人 30:站内信收集人 40:站内信抄送人 400 会议纪要</param>
|
|
|
+ /// <returns></returns>
|
|
|
public async Task<bool> DeleteAsync(int dataSourceId, int middleType)
|
|
|
{
|
|
|
return await _userMiddleRepoitory.DeleteAsync(Q.Where(nameof(Entity.UserMiddle.UserMiddle.DataSourceId), dataSourceId).Where(nameof(Entity.UserMiddle.UserMiddle.MiddleType), middleType));
|
|
@@ -91,9 +96,7 @@ namespace GxPress.Service.Implement.UserMiddle
|
|
|
List<Entity.User> users = new List<Entity.User>();
|
|
|
var userIds = new List<int>();
|
|
|
userIds = userMiddles.Where(n => n.SourceType == 0).Select(n => n.SourceId).ToList();
|
|
|
- if (userIds.Count() > 0)
|
|
|
- //获取用户
|
|
|
- users.AddRange(await _userRepoitory.GetAllAsync(Q.WhereIn(nameof(Entity.User.Id), userIds)));
|
|
|
+
|
|
|
foreach (var userMiddle in userMiddles)
|
|
|
{
|
|
|
if (userMiddle.SourceType != 0)
|
|
@@ -102,13 +105,48 @@ namespace GxPress.Service.Implement.UserMiddle
|
|
|
{
|
|
|
if (userMiddle.SourceId == 0)
|
|
|
//获取所有用户
|
|
|
- users.AddRange(await _userRepoitory.GetAllAsync(Q.Where(nameof(Entity.User.Id), ">", 0)));
|
|
|
+ userIds.AddRange(await _userRepoitory.GetAllIntsAsync(Q.Select(nameof(Entity.User.Id)).Where(nameof(Entity.User.Id), ">", 0)));
|
|
|
else
|
|
|
{
|
|
|
//递归获取部门
|
|
|
var departments = new List<Entity.Department>();
|
|
|
departments = await _departmentRepository.GetDepartmentById(userMiddle.SourceId, departments);
|
|
|
- users.AddRange(await _userRepoitory.GetAllAsync(Q.WhereIn(nameof(Entity.User.DepartmentId), departments.Select(n => n.Id))));
|
|
|
+ userIds.AddRange(await _userRepoitory.GetAllIntsAsync(Q.WhereIn(nameof(Entity.User.DepartmentId), departments.Select(n => n.Id))));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (userMiddle.SourceType == 2)
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// 我的小组
|
|
|
+ /// </summary>
|
|
|
+ /// <value></value>
|
|
|
+ if (userMiddle.SourceTypeValue == 1)
|
|
|
+ {
|
|
|
+ if (userMiddle.SourceId == 0)
|
|
|
+ {
|
|
|
+ userIds.AddRange(await groupUserRepository.GetGroupUserByUserIdAsync(userId));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var groupUsers = await groupUserRepository.GetAllAsync(Q.Where(nameof(Entity.GroupUser.GroupId), userMiddle.SourceId));
|
|
|
+ userIds.AddRange(groupUsers.Select(n => n.UserId));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 我的群聊
|
|
|
+ /// </summary>
|
|
|
+ /// <value></value>
|
|
|
+ if (userMiddle.SourceTypeValue == 2)
|
|
|
+ {
|
|
|
+ if (userMiddle.SourceId == 0)
|
|
|
+ {
|
|
|
+ userIds.AddRange(await groupChatUserRepository.GetUserIdsAsync(userId));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var groupChatUsers = await groupChatUserRepository.GetAllAsync(Q.Where(nameof(Entity.GroupChatUser.GroupChatId), userMiddle.SourceId));
|
|
|
+ userIds.AddRange(groupChatUsers.Select(n => n.UserId));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (userMiddle.SourceType == 3)
|
|
@@ -117,21 +155,20 @@ namespace GxPress.Service.Implement.UserMiddle
|
|
|
{
|
|
|
var addressBookGroups = await _addressBookGroupRepository.GetAllAsync(Q.Where(nameof(Entity.AddressBookGroup.UserId), userId));
|
|
|
var addressBookGroupUsers = await _addressBookGroupUserRepository.GetAllAsync(Q.WhereIn(nameof(Entity.AddressBookGroupUser.AddressBookGroupId), addressBookGroups.Select(n => n.Id)));
|
|
|
- userIds = addressBookGroupUsers.Select(n => n.UserId).ToList();
|
|
|
- //获取用户
|
|
|
- users.AddRange(await _userRepoitory.GetAllAsync(Q.WhereIn(nameof(Entity.User.Id), userIds)));
|
|
|
+ userIds.AddRange(addressBookGroupUsers.Select(n => n.UserId).ToList());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//获取自建分组
|
|
|
var addressBookGroupUsers = await _addressBookGroupUserRepository.GetAllAsync(Q.Where(nameof(Entity.AddressBookGroupUser.AddressBookGroupId), userMiddle.SourceId));
|
|
|
- userIds = addressBookGroupUsers.Select(n => n.UserId).ToList();
|
|
|
- //获取用户
|
|
|
- users.AddRange(await _userRepoitory.GetAllAsync(Q.WhereIn(nameof(Entity.User.Id), userIds)));
|
|
|
+ userIds.AddRange(addressBookGroupUsers.Select(n => n.UserId).ToList());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (userIds.Count() > 0)
|
|
|
+ //获取用户
|
|
|
+ users.AddRange(await _userRepoitory.GetAllAsync(Q.WhereIn(nameof(Entity.User.Id), userIds)));
|
|
|
users = users.Distinct().ToList();
|
|
|
return users;
|
|
|
}
|