add 操作人
This commit is contained in:
@@ -105,4 +105,9 @@ public class DeviceTaskAssignmentResponse
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
public int CreateBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作人
|
||||
/// </summary>
|
||||
public string Creator { get; set; }
|
||||
}
|
||||
@@ -17,11 +17,15 @@ public class DeviceTaskAssignmentService : IDeviceTaskAssignmentService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ITenantApi _tenantApi;
|
||||
private readonly IUserApi _userApi;
|
||||
|
||||
public DeviceTaskAssignmentService(IDbContext dbContext, ITenantApi tenantApi)
|
||||
public DeviceTaskAssignmentService(IDbContext dbContext,
|
||||
ITenantApi tenantApi,
|
||||
IUserApi userApi)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_tenantApi = tenantApi;
|
||||
_userApi = userApi;
|
||||
}
|
||||
|
||||
public async Task<Pagination<DeviceTaskAssignmentResponse>> GetPageAsync(DeviceTaskAssignmentRequest request)
|
||||
@@ -81,6 +85,17 @@ public class DeviceTaskAssignmentService : IDeviceTaskAssignmentService
|
||||
//ignore
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var userIds = page.Data.Select(x => x.CreateBy).Distinct().ToList();
|
||||
var userInfos = await _userApi.GetUserByIdsAsync(userIds);
|
||||
page.Data.ForEach(item => item.Creator = userInfos.FirstOrDefault(x => x.Id == item.CreateBy)?.OperatorName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using Kurisu.RemoteCall.Attributes;
|
||||
|
||||
namespace Dlhis.Sys.Api;
|
||||
|
||||
[RequestResultHandler]
|
||||
[EnableRemoteClient(Name = "sys-service", BaseUrl = "${InternalRequest:SysRequestUrl}")]
|
||||
public interface IUserApi
|
||||
{
|
||||
|
||||
@@ -6,6 +6,11 @@ public class UserResponse
|
||||
|
||||
public string UserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作员名称
|
||||
/// </summary>
|
||||
public string OperatorName { get; set; }
|
||||
|
||||
public string NormalizedUserName { get; set; }
|
||||
|
||||
public string Email { get; set; }
|
||||
|
||||
@@ -90,7 +90,7 @@ public class UserService : IUserService
|
||||
Role = r.Name,
|
||||
OperatorName = c.ClaimValue,
|
||||
}, true)
|
||||
.FirstAsync();
|
||||
.SingleAsync();
|
||||
|
||||
return user;
|
||||
}
|
||||
@@ -102,8 +102,19 @@ public class UserService : IUserService
|
||||
|
||||
public async Task<List<UserResponse>> GetUserByIdsAsync(List<int> ids)
|
||||
{
|
||||
var users = await _identityDbContext.Queryable<UserEntity>().Where(x => ids.Contains(x.Id)).Select<UserResponse>().ToListAsync();
|
||||
return users;
|
||||
return await _identityDbContext.Queryable<UserEntity>()
|
||||
.LeftJoin<UserRoleEntity>((x, ur) => x.Id == ur.UserId)
|
||||
.LeftJoin<RoleEntity>((x, ur, r) => ur.RoleId == r.Id)
|
||||
.LeftJoin<UserClaimEntity>((x, ur, r, c) => x.Id == c.UserId && c.ClaimType == "preferred_username")
|
||||
.Where(x => ids.Contains(x.Id))
|
||||
.Select((x, ur, r, c) => new UserResponse
|
||||
{
|
||||
Id = x.Id,
|
||||
RoleId = ur.RoleId,
|
||||
Role = r.Name,
|
||||
OperatorName = c.ClaimValue,
|
||||
}, true)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task CreateUserAsync(UserCreateRequest request)
|
||||
|
||||
Reference in New Issue
Block a user