|
@@ -20,6 +20,7 @@ namespace GxPress.Repository.Implement
|
|
|
private readonly IMapper _mapper;
|
|
|
private readonly Repository<Department> _repository;
|
|
|
private readonly Repository<User> _userRepository;
|
|
|
+ private readonly Repository<Entity.DepartmentUser> departmentUserRepository;
|
|
|
|
|
|
public DepartmentRepository(IOptionsMonitor<DatabaseOptions> dbOptionsAccessor, IMapper mapper)
|
|
|
{
|
|
@@ -27,6 +28,7 @@ namespace GxPress.Repository.Implement
|
|
|
var database = new Database(databaseType, dbOptionsAccessor.CurrentValue.ConnectionString);
|
|
|
_repository = new Repository<Department>(database);
|
|
|
_userRepository = new Repository<User>(database);
|
|
|
+ departmentUserRepository = new Repository<Entity.DepartmentUser>(database);
|
|
|
_mapper = mapper;
|
|
|
}
|
|
|
|
|
@@ -217,7 +219,9 @@ namespace GxPress.Repository.Implement
|
|
|
var result = new DepartmentUserResult();
|
|
|
var departments = await GetListAsync(request);
|
|
|
result.Departments = departments;
|
|
|
- var users = await _userRepository.GetAllAsync(Q.Where(nameof(User.DepartmentId), request.DepartmentId));
|
|
|
+ //获取用户ID
|
|
|
+ var departmentUsers = await departmentUserRepository.GetAllAsync<int>(Q.WhereIn(nameof(Entity.DepartmentUser.DepartmentId), departments.Select(n => n.Id)).Select(nameof(Entity.DepartmentUser.UserId)));
|
|
|
+ var users = await _userRepository.GetAllAsync(Q.WhereIn(nameof(User.Id), departmentUsers));
|
|
|
result.Users = users.ToList();
|
|
|
for (int i = 0; i < result.Users.Count(); i++)
|
|
|
{
|
|
@@ -284,7 +288,7 @@ namespace GxPress.Repository.Implement
|
|
|
foreach (var item in list)
|
|
|
{
|
|
|
// result.Add(item);
|
|
|
- await GetDepartmentById(item.Id, departments);
|
|
|
+ await GetDepartmentById(item.Id, departments);
|
|
|
}
|
|
|
|
|
|
}
|