fix: 🐛 用户选择器报错 (#220)

Co-authored-by: tk <fiyne1a@dingtalk.com>
This commit is contained in:
nsnail 2024-11-26 10:10:25 +08:00 committed by GitHub
parent cec96390a5
commit 71bfdaafa8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -232,17 +232,20 @@ public sealed class UserService(
{ {
req.ThrowIfInvalid(); req.ThrowIfInvalid();
var listUserExp = req.GetToListExp<Sys_User>() ?? _listUserExp; var listUserExp = req.GetToListExp<Sys_User>() ?? _listUserExp;
var select = await QueryInternalAsync(req, listUserExp == _listUserExp).ConfigureAwait(false); var includeRoles = listUserExp == _listUserExp;
var list = await select.Page(req.Page, req.PageSize) var select = await QueryInternalAsync(req, includeRoles).ConfigureAwait(false);
IEnumerable<Sys_User> list = await select.Page(req.Page, req.PageSize)
#if DBTYPE_SQLSERVER #if DBTYPE_SQLSERVER
.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait)
#endif #endif
.Count(out var total) .Count(out var total)
.ToListAsync(listUserExp) .ToListAsync(listUserExp)
.ConfigureAwait(false); .ConfigureAwait(false);
return new PagedQueryRsp<QueryUserRsp>(req.Page, req.PageSize, total if (includeRoles) {
, list.Select(x => x with { Roles = x.Roles.OrderBy(y => y.Sort).ThenBy(y => y.Id).ToList() }) list = list.Select(x => x with { Roles = x.Roles.OrderBy(y => y.Sort).ThenBy(y => y.Id).ToList() });
.Adapt<IEnumerable<QueryUserRsp>>()); }
return new PagedQueryRsp<QueryUserRsp>(req.Page, req.PageSize, total, list.Adapt<IEnumerable<QueryUserRsp>>());
} }
/// <inheritdoc /> /// <inheritdoc />