From 3f610619b5bb1a1f22b09942db23549b1772fbb1 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 2 Oct 2024 14:07:40 +0200 Subject: [PATCH] add a tool func for query --- entrypoint.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/entrypoint.go b/entrypoint.go index 500d099..86a3722 100644 --- a/entrypoint.go +++ b/entrypoint.go @@ -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"`