fix 排除离职的操作人员
This commit is contained in:
@@ -30,7 +30,21 @@ public class UserService : IUserService
|
||||
public async Task<Pagination<UserResponse>> GetPageAsync(UserPageRequest request)
|
||||
{
|
||||
var tenant = _currentUser.GetStringTenantId();
|
||||
|
||||
var roleUserCodes = await _identityDbContext.Queryable<UserRoleEntity>()
|
||||
.LeftJoin<UserEntity>((x, u) => x.UserId == u.Id)
|
||||
.Select((x, u) => u.UserName)
|
||||
.ToListAsync();
|
||||
|
||||
var userCodes = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Factory == tenant).Select(x => x.Code).ToListAsync();
|
||||
var userLeaveCodes = await _dbContext.Queryable<GainfoLeaveEntity>()
|
||||
.Where(x => x.Factory == tenant)
|
||||
.Where(x => roleUserCodes.Contains(x.Code))
|
||||
.Select(x => x.Code)
|
||||
.ToListAsync();
|
||||
|
||||
var expectUserIds = await _identityDbContext.Queryable<UserEntity>().Where(x => userLeaveCodes.Contains(x.UserName)).Select(x => x.Id).ToListAsync();
|
||||
|
||||
var userIds = await _identityDbContext.Queryable<UserTenantEntity>().Where(x => x.TenantCode == tenant).Select(x => x.UserId).Distinct().ToListAsync();
|
||||
|
||||
var page = await _identityDbContext.Queryable<UserEntity>()
|
||||
@@ -45,7 +59,7 @@ public class UserService : IUserService
|
||||
|| x.PhoneNumber == request.Search
|
||||
|| c.ClaimValue == request.Search
|
||||
)
|
||||
.Where(x => userIds.Contains(x.Id) || userCodes.Contains(x.UserName))
|
||||
.Where(x => !expectUserIds.Contains(x.Id) && (userIds.Contains(x.Id) || userCodes.Contains(x.UserName)))
|
||||
.Select((x, ur, r, c) => new UserResponse
|
||||
{
|
||||
Id = x.Id,
|
||||
|
||||
Reference in New Issue
Block a user