diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Response/DeviceTaskAssignmentResponse.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Response/DeviceTaskAssignmentResponse.cs
index e7bc9b63..2948e716 100644
--- a/Src/Dlhis.ScheduledTask/TaskAssignment/Response/DeviceTaskAssignmentResponse.cs
+++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Response/DeviceTaskAssignmentResponse.cs
@@ -105,4 +105,9 @@ public class DeviceTaskAssignmentResponse
/// 创建人
///
public int CreateBy { get; set; }
+
+ ///
+ /// 操作人
+ ///
+ public string Creator { get; set; }
}
\ No newline at end of file
diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs
index ad8cb487..2ee5aa08 100644
--- a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs
+++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs
@@ -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> 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;
}
diff --git a/Src/Dlhis.Sys.Api/IUserApi.cs b/Src/Dlhis.Sys.Api/IUserApi.cs
index 6787cd39..e4047070 100644
--- a/Src/Dlhis.Sys.Api/IUserApi.cs
+++ b/Src/Dlhis.Sys.Api/IUserApi.cs
@@ -3,6 +3,7 @@ using Kurisu.RemoteCall.Attributes;
namespace Dlhis.Sys.Api;
+[RequestResultHandler]
[EnableRemoteClient(Name = "sys-service", BaseUrl = "${InternalRequest:SysRequestUrl}")]
public interface IUserApi
{
diff --git a/Src/Dlhis.Sys.Api/Response/UserResponse.cs b/Src/Dlhis.Sys.Api/Response/UserResponse.cs
index 56b87f7d..84a1eff9 100644
--- a/Src/Dlhis.Sys.Api/Response/UserResponse.cs
+++ b/Src/Dlhis.Sys.Api/Response/UserResponse.cs
@@ -5,6 +5,11 @@ public class UserResponse
public int Id { get; set; }
public string UserName { get; set; }
+
+ ///
+ /// 操作员名称
+ ///
+ public string OperatorName { get; set; }
public string NormalizedUserName { get; set; }
diff --git a/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs b/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs
index fb58d5d8..659af492 100644
--- a/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs
+++ b/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs
@@ -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> GetUserByIdsAsync(List ids)
{
- var users = await _identityDbContext.Queryable().Where(x => ids.Contains(x.Id)).Select().ToListAsync();
- return users;
+ return await _identityDbContext.Queryable()
+ .LeftJoin((x, ur) => x.Id == ur.UserId)
+ .LeftJoin((x, ur, r) => ur.RoleId == r.Id)
+ .LeftJoin((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)