⚠️feat: 增加排序字段

This commit is contained in:
yubaolee
2025-06-14 11:07:26 +08:00
parent ab027241bf
commit b275847f3b
3 changed files with 17 additions and 1 deletions

View File

@@ -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();