Browse Source

增加map切片排序

master
loshiqi 2 years ago
parent
commit
94dc6d70d3
1 changed files with 14 additions and 0 deletions
  1. +14
    -0
      map.go

+ 14
- 0
map.go View File

@ -262,3 +262,17 @@ func MapSort(order, val, val_type string, MapDate []map[string]interface{}) ([]m
}
return res, nil
}
func MapPage(pageNum, pageSize int, MapDate []map[string]interface{}) []map[string]interface{} {
list := []map[string]interface{}{}
stat := (pageNum - 1) * pageSize
end := stat + pageSize - 1
for k, v := range MapDate {
if k >= stat && k <= end {
list = append(list, v)
}
if k > end {
break
}
}
return list
}

Loading…
Cancel
Save