add a tool func for query
This commit is contained in:
parent
c309d97623
commit
3f610619b5
@ -3,6 +3,7 @@ package oclib
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"runtime/debug"
|
||||
|
||||
@ -25,6 +26,7 @@ import (
|
||||
"cloud.o-forge.io/core/oc-lib/models/workflow_execution"
|
||||
"cloud.o-forge.io/core/oc-lib/models/workspace"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
"github.com/beego/beego/v2/server/web/context"
|
||||
"github.com/goraz/onion"
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
@ -65,6 +67,20 @@ func (d LibDataEnum) EnumIndex() int {
|
||||
return int(d)
|
||||
}
|
||||
|
||||
func IsQueryParamsEquals(input *context.BeegoInput, name string, val interface{}) bool {
|
||||
path := strings.Split(input.URI(), "?")
|
||||
if len(path) >= 2 {
|
||||
uri := strings.Split(path[1], "&")
|
||||
for _, val := range uri {
|
||||
kv := strings.Split(val, "=")
|
||||
if kv[0] == name && fmt.Sprintf("%v", val) == kv[1] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// model to define the shallow data structure
|
||||
type LibDataShallow struct {
|
||||
Data []utils.ShallowDBObject `bson:"data" json:"data"`
|
||||
|
Loading…
Reference in New Issue
Block a user