|
@@ -7,6 +7,7 @@ using GxPress.Entity;
|
|
|
using GxPress.EnumConst;
|
|
|
using GxPress.Repository.Interface;
|
|
|
using GxPress.Repository.Interface.AdminVerify;
|
|
|
+using GxPress.Repository.Interface.DepartmentUser;
|
|
|
using GxPress.Request.App.AdminVerify;
|
|
|
using GxPress.Request.App.Middle;
|
|
|
using GxPress.Service.Interface.AdminVerify;
|
|
@@ -24,9 +25,10 @@ namespace GxPress.Service.Implement.AdminVerify
|
|
|
private readonly IGroupChatRepository _groupChatRepository;
|
|
|
private readonly IMiddleRepository _middleRepository;
|
|
|
private readonly IGroupUserRepository _groupUserRepository;
|
|
|
+ private readonly IDepartmentUserRepository departmentUserRepository;
|
|
|
public AdminVerifyInsetService(IAdminVerifyRepository adminVerifyRepository, IUserRepository userRepository,
|
|
|
IDepartmentRepository departmentRepository, IMiddleService middleService, IGroupRepository groupRepository,
|
|
|
- IGroupChatRepository groupChatRepository, IMiddleRepository middleRepository, IGroupUserRepository groupUserRepository)
|
|
|
+ IGroupChatRepository groupChatRepository, IMiddleRepository middleRepository, IGroupUserRepository groupUserRepository, IDepartmentUserRepository departmentUserRepository)
|
|
|
{
|
|
|
_adminVerifyRepository = adminVerifyRepository;
|
|
|
_userRepository = userRepository;
|
|
@@ -36,6 +38,7 @@ namespace GxPress.Service.Implement.AdminVerify
|
|
|
_groupChatRepository = groupChatRepository;
|
|
|
_middleRepository = middleRepository;
|
|
|
_groupUserRepository = groupUserRepository;
|
|
|
+ this.departmentUserRepository = departmentUserRepository;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -50,7 +53,8 @@ namespace GxPress.Service.Implement.AdminVerify
|
|
|
var userDto = await _userRepository.GetAsync(request.UserId);
|
|
|
//获取员工所有信息
|
|
|
var users = await _userRepository.GetAllAsync(Q.WhereIn(nameof(Entity.User.Id), request.UserIds));
|
|
|
- var departments = await _departmentRepository.GetAllAsync(Q.WhereIn(nameof(Entity.Department.Id), users.Select(n => n.DepartmentId)));
|
|
|
+ var departmentUsers = await departmentUserRepository.GetDepartmentUsersByUserIdsAsync(request.UserIds);
|
|
|
+ var departments = await _departmentRepository.GetAllAsync(Q.WhereIn(nameof(Entity.Department.Id), departmentUsers.Select(n => n.DepartmentId)));
|
|
|
foreach (var userId in request.UserIds)
|
|
|
{
|
|
|
var adminVerify = new Entity.AdminVerify();
|
|
@@ -59,7 +63,11 @@ namespace GxPress.Service.Implement.AdminVerify
|
|
|
var user = users.FirstOrDefault(n => n.Id == userId);
|
|
|
if (user == null)
|
|
|
continue;
|
|
|
- var department = departments.FirstOrDefault(n => n.Id == user.DepartmentId);
|
|
|
+ var department = new Entity.Department();
|
|
|
+ if (departmentUsers.FirstOrDefault(n => n.UserId == user.Id) != null)
|
|
|
+ {
|
|
|
+ department = departments.FirstOrDefault(m => m.Id == departmentUsers.FirstOrDefault(n => n.UserId == user.Id).DepartmentId);
|
|
|
+ }
|
|
|
var group = await _groupRepository.GetAsync(request.SourceId);
|
|
|
//查询是否存在
|
|
|
adminVerify = await _adminVerifyRepository.GetAsync(Q.Where(nameof(Entity.AdminVerify.AdminId), userId).Where(nameof(Entity.AdminVerify.SourceType), request.SourceType).Where(nameof(Entity.AdminVerify.SourceId), group.Id).WhereIn(nameof(Entity.AdminVerify.DisposeType), new List<int> { 0, 1 }));
|