Skip to content

Commit

Permalink
新增:GetPageList获取collections.PageList的元素
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Dec 12, 2023
1 parent 091d8ef commit 0df0219
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions types/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,14 @@ func ListToArray(lstValue reflect.Value) []any {
}
return items
}

// GetPageList 获取collections.PageList的元素
func GetPageList(pageList any) (any, int64) {
pageListValueOf := reflect.ValueOf(pageList)
if _, success := IsPageList(pageListValueOf); !success {
panic("ToPageList的入参必须是collections.PageList类型")
}
listValueOf := pageListValueOf.FieldByName("List")
recordCountValueOf := pageListValueOf.FieldByName("RecordCount")
return listValueOf.Interface(), recordCountValueOf.Interface().(int64)
}

0 comments on commit 0df0219

Please sign in to comment.