mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-11-08 10:24:44 +08:00
⚠️feat: 增加排序字段
This commit is contained in:
@@ -39,7 +39,16 @@ namespace OpenAuth.App
|
||||
objs = objs.Where(request.sqlWhere);
|
||||
}
|
||||
var propertyStr = string.Join(',', columns.Select(u => u.ColumnName));
|
||||
result.Data = objs.OrderBy(u => u.Id)
|
||||
|
||||
if (!string.IsNullOrEmpty(request.sort))
|
||||
{
|
||||
var sortfields = request.sort.Split(',');
|
||||
|
||||
objs = objs.OrderBy($"{sortfields[0]} {sortfields[1]}");
|
||||
}else{
|
||||
objs = objs.OrderBy(u => u.Id);
|
||||
}
|
||||
result.Data = objs
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit).Select($"{propertyStr}").ToList();
|
||||
result.Count = await objs.CountAsync();
|
||||
|
||||
Reference in New Issue
Block a user