Offset + Limit
This commit is contained in:
@@ -2,6 +2,7 @@ package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
@@ -36,12 +37,16 @@ func (o *PurchaseController) Post() {
|
||||
// @Title GetAll
|
||||
// @Description find compute by id
|
||||
// @Param is_draft query string false "draft wished"
|
||||
// @Param offset query string false "offset wished"
|
||||
// @Param limit query string false "limit wished"
|
||||
// @Success 200 {compute} models.compute
|
||||
// @router / [get]
|
||||
func (o *PurchaseController) GetAll() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
isDraft := o.Ctx.Input.Query("is_draft")
|
||||
o.Data["json"] = oclib.NewRequest(purchase_collection, user, peerID, groups, nil).LoadAll(isDraft == "true")
|
||||
offset, _ := strconv.Atoi(o.Ctx.Input.Query("offset"))
|
||||
limit, _ := strconv.Atoi(o.Ctx.Input.Query("limit"))
|
||||
o.Data["json"] = oclib.NewRequest(purchase_collection, user, peerID, groups, nil).LoadAll(isDraft == "true", int64(offset), int64(limit))
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -49,13 +54,17 @@ func (o *PurchaseController) GetAll() {
|
||||
// @Description find compute by key word
|
||||
// @Param search path string true "the search you want to get"
|
||||
// @Param is_draft query string false "draft wished"
|
||||
// @Param offset query string false "offset wished"
|
||||
// @Param limit query string false "limit wished"
|
||||
// @Success 200 {compute} models.compute
|
||||
// @router /search/:search [get]
|
||||
func (o *PurchaseController) Search() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
isDraft := o.Ctx.Input.Query("is_draft")
|
||||
search := o.Ctx.Input.Param(":search")
|
||||
o.Data["json"] = oclib.NewRequest(purchase_collection, user, peerID, groups, nil).Search(nil, search, isDraft == "true")
|
||||
offset, _ := strconv.Atoi(o.Ctx.Input.Query("offset"))
|
||||
limit, _ := strconv.Atoi(o.Ctx.Input.Query("limit"))
|
||||
o.Data["json"] = oclib.NewRequest(purchase_collection, user, peerID, groups, nil).Search(nil, search, isDraft == "true", int64(offset), int64(limit))
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user