作者 庄敏学

排序

... ... @@ -58,18 +58,20 @@ func (l *SearchTableDataLogic) SearchTableData(req *types.SearchTableDataRequest
break
}
}
sort.Slice(response.Grid.List, func(i, j int) bool {
if _, ok := response.Grid.List[i][orderField]; ok {
if _, ok := response.Grid.List[j][orderField]; ok {
if strings.ToLower(orderBy) == "asc" {
return response.Grid.List[i][orderField] < response.Grid.List[j][orderField]
} else {
return response.Grid.List[i][orderField] > response.Grid.List[j][orderField]
if orderField != "" && orderBy != "" {
sort.Slice(response.Grid.List, func(i, j int) bool {
if _, ok := response.Grid.List[i][orderField]; ok {
if _, ok := response.Grid.List[j][orderField]; ok {
if strings.ToLower(orderBy) == "asc" {
return response.Grid.List[i][orderField] < response.Grid.List[j][orderField]
} else {
return response.Grid.List[i][orderField] > response.Grid.List[j][orderField]
}
}
}
}
return true
})
return true
})
}
resp = map[string]interface{}{
"objectId": response.ObjectId,
"fields": removeIdField(response.Fields),
... ...