From 4c1c0e3a17438b27f753d748af880d794a06d582 Mon Sep 17 00:00:00 2001 From: Liujian <824010343@qq.com> Date: Mon, 12 Aug 2024 17:30:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=9B=E5=BB=BA=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=EF=BC=8C=E6=A0=87=E7=AD=BE=E6=9B=B4=E6=96=B0=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/service/dto/input.go | 19 ++++++++++--------- module/service/iml.go | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/module/service/dto/input.go b/module/service/dto/input.go index c258de5..5f49366 100644 --- a/module/service/dto/input.go +++ b/module/service/dto/input.go @@ -1,15 +1,16 @@ package service_dto type CreateService struct { - Id string `json:"id"` - Name string `json:"name"` - Prefix string `json:"prefix"` - Description string `json:"description"` - ServiceType string `json:"service_type"` - Logo string `json:"logo"` - Catalogue string `json:"catalogue" aocheck:"catalogue"` - AsApp *bool `json:"as_app"` - AsServer *bool `json:"as_server"` + Id string `json:"id"` + Name string `json:"name"` + Prefix string `json:"prefix"` + Description string `json:"description"` + ServiceType string `json:"service_type"` + Logo string `json:"logo"` + Tags []string `json:"tags"` + Catalogue string `json:"catalogue" aocheck:"catalogue"` + AsApp *bool `json:"as_app"` + AsServer *bool `json:"as_server"` } type EditService struct { diff --git a/module/service/iml.go b/module/service/iml.go index bff74cd..5869341 100644 --- a/module/service/iml.go +++ b/module/service/iml.go @@ -265,6 +265,21 @@ func (i *imlServiceModule) Create(ctx context.Context, teamID string, input *ser } input.Prefix = strings.Trim(strings.Trim(input.Prefix, " "), "/") err := i.transaction.Transaction(ctx, func(ctx context.Context) error { + if input.Tags != nil { + tags, err := i.getTagUuids(ctx, input.Tags) + if err != nil { + return err + } + for _, t := range tags { + err = i.serviceTagService.Create(ctx, &service_tag.CreateTag{ + Tid: t, + Sid: input.Id, + }) + if err != nil { + return err + } + } + } return i.serviceService.Create(ctx, mo) }) if err != nil {