fix 用户列表查询问题

This commit is contained in:
2024-05-23 14:45:41 +08:00
parent 9be2a5ce04
commit e0c9621e56
2 changed files with 7 additions and 7 deletions

View File

@@ -20,11 +20,11 @@ public class UserCreateRequest
/// <summary> /// <summary>
/// 厂区 /// 厂区
/// </summary> /// </summary>
[Required] [MinLength(1, ErrorMessage = "请明确厂区")]
public string Tenant { get; set; } public List<string> Tenants { get; set; }
/// <summary> /// <summary>
/// 名称 /// 名称
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }
} }

View File

@@ -30,7 +30,7 @@ public class UserService : IUserService
.LeftJoin<UserRoleEntity>((x, ur) => x.Id == ur.UserId) .LeftJoin<UserRoleEntity>((x, ur) => x.Id == ur.UserId)
.LeftJoin<RoleEntity>((x, ur, r) => ur.RoleId == r.Id) .LeftJoin<RoleEntity>((x, ur, r) => ur.RoleId == r.Id)
.LeftJoin<UserClaimEntity>((x, ur, r, c) => x.Id == c.UserId && c.ClaimType == "preferred_username") .LeftJoin<UserClaimEntity>((x, ur, r, c) => x.Id == c.UserId && c.ClaimType == "preferred_username")
.LeftJoin<UserClaimEntity>((x, ur, r, c, cc) => x.Id == c.UserId && c.ClaimType == "tenant") .LeftJoin<UserClaimEntity>((x, ur, r, c, cc) => x.Id == cc.UserId && cc.ClaimType == "tenant")
.Where(x => x.UserName != "admin") .Where(x => x.UserName != "admin")
.Where((x, ur, r, c, cc) => cc.ClaimValue == tenant) .Where((x, ur, r, c, cc) => cc.ClaimValue == tenant)
.WhereIF(request.IsOperator, (x, ur, r, c) => !SqlFunc.IsNullOrEmpty(r.Name)) .WhereIF(request.IsOperator, (x, ur, r, c) => !SqlFunc.IsNullOrEmpty(r.Name))
@@ -116,11 +116,11 @@ public class UserService : IUserService
var id = (int)await _dbContext.InsertReturnIdentityAsync(user); var id = (int)await _dbContext.InsertReturnIdentityAsync(user);
await _dbContext.InsertAsync(new UserTenantEntity await _dbContext.InsertAsync(request.Tenants.Select(x => new UserTenantEntity
{ {
TenantCode = request.Tenant, TenantCode = x,
UserId = id UserId = id
}); }).ToList());
if (request.Name.IsPresent()) if (request.Name.IsPresent())
{ {