From 824a22efad77bbe6897c07f608c92bbdc356072c Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Wed, 19 Jul 2023 11:52:47 +1000 Subject: [PATCH] Small tweaks --- backend/embed/api_docs/main.go | 10 ---------- backend/internal/api/handler/helpers.go | 15 --------------- backend/internal/entity/filters_schema.go | 5 +++-- backend/internal/model/pageinfo.go | 2 +- backend/internal/util/strings.go | 3 ++- 5 files changed, 6 insertions(+), 29 deletions(-) delete mode 100644 backend/embed/api_docs/main.go diff --git a/backend/embed/api_docs/main.go b/backend/embed/api_docs/main.go deleted file mode 100644 index 24a8c0a..0000000 --- a/backend/embed/api_docs/main.go +++ /dev/null @@ -1,10 +0,0 @@ -package doc - -import "embed" - -// SwaggerFiles contain all the files used for swagger schema generation -// -//go:embed api.swagger.json -//go:embed components -//go:embed paths -var SwaggerFiles embed.FS diff --git a/backend/internal/api/handler/helpers.go b/backend/internal/api/handler/helpers.go index e6ff9e0..d6f5e58 100644 --- a/backend/internal/api/handler/helpers.go +++ b/backend/internal/api/handler/helpers.go @@ -85,21 +85,6 @@ func getQueryVarInt(r *http.Request, varName string, required bool, defaultValue return varInt, nil } -/* -func getQueryVarBool(r *http.Request, varName string, required bool, defaultValue bool) (bool, error) { - queryValues := r.URL.Query() - varValue := queryValues.Get(varName) - - if varValue == "" && required { - return false, eris.Errorf("%v was not supplied in the request", varName) - } else if varValue == "" { - return defaultValue, nil - } - - return varValue == "true" || varValue == "1" || varValue == "on", nil -} -*/ - func getURLParamInt(r *http.Request, varName string) (uint, error) { var defaultValue uint = 0 diff --git a/backend/internal/entity/filters_schema.go b/backend/internal/entity/filters_schema.go index 059df6f..6c4fa9b 100644 --- a/backend/internal/entity/filters_schema.go +++ b/backend/internal/entity/filters_schema.go @@ -2,11 +2,12 @@ package entity import ( "fmt" - "npm/internal/logger" - "npm/internal/util" "reflect" "strings" + "npm/internal/logger" + "npm/internal/util" + "github.com/rotisserie/eris" ) diff --git a/backend/internal/model/pageinfo.go b/backend/internal/model/pageinfo.go index feb9738..7fe4ce4 100644 --- a/backend/internal/model/pageinfo.go +++ b/backend/internal/model/pageinfo.go @@ -15,7 +15,7 @@ type Sort struct { Direction string `json:"direction"` } -// TableName overrides the table name used by gorm +// GetSort ... func (p *PageInfo) GetSort(def Sort) []Sort { if p.Sort == nil { return []Sort{def} diff --git a/backend/internal/util/strings.go b/backend/internal/util/strings.go index 1e4f0a5..c3e9b70 100644 --- a/backend/internal/util/strings.go +++ b/backend/internal/util/strings.go @@ -3,10 +3,11 @@ package util import ( "bytes" "encoding/json" - "npm/internal/logger" "regexp" "strings" "unicode" + + "npm/internal/logger" ) // CleanupWhitespace will trim up and remove extra lines and stuff