From 01d694d009c18124393b3d6bb67b0c75e370b048 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 22 Oct 2020 15:19:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/xorm.go | 6 ++++-- web/api/curd.go | 8 ++++---- web/api/router.go | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/db/xorm.go b/db/xorm.go index 228b81b..7981a92 100644 --- a/db/xorm.go +++ b/db/xorm.go @@ -25,8 +25,10 @@ func Open() error { //同步表 return Engine.Sync2( - models.Tunnel{}, models.Link{}, models.Device{}, models.Plugin{}, - models.Project{}, models.ProjectJob{}, models.ProjectStrategy{}, + models.Tunnel{}, models.Link{}, + models.Device{}, models.Location{}, + models.Plugin{}, + models.Project{}, models.ProjectElement{}, models.ProjectJob{}, models.ProjectStrategy{}, models.Element{}, models.ElementVariable{}, models.ElementBatch{}, ) } diff --git a/web/api/curd.go b/web/api/curd.go index 949ec7c..1b2393d 100644 --- a/web/api/curd.go +++ b/web/api/curd.go @@ -30,11 +30,11 @@ func curdApiList(mod reflect.Type) gin.HandlerFunc { op := db.Engine.Limit(body.Length, body.Offset) for _, filter := range body.Filters { - if len(filter.Value) > 0 { - if len(filter.Value) == 1 { - op.And(filter.Key+"=?", filter.Value[0]) + if len(filter.Values) > 0 { + if len(filter.Values) == 1 { + op.And(filter.Key+"=?", filter.Values[0]) } else { - op.In(filter.Key, filter.Value) + op.In(filter.Key, filter.Values) } } } diff --git a/web/api/router.go b/web/api/router.go index 321b15f..61607be 100644 --- a/web/api/router.go +++ b/web/api/router.go @@ -10,8 +10,8 @@ import ( ) type paramFilter struct { - Key string `form:"key"` - Value []string `form:"value"` + Key string `form:"key"` + Values []string `form:"value"` } type paramSearch struct { -- GitLab