From a5b6e894b47c6f3625cd5234001de7ade7f37974 Mon Sep 17 00:00:00 2001 From: Qu Xuan Date: Thu, 23 Apr 2020 17:11:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0cloudevent=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/apis/cloudevent/cloudevent.go | 16 +++++++++++++-- pkg/cloudevent/models/cloudevents.go | 29 +++++++++++++++------------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/pkg/apis/cloudevent/cloudevent.go b/pkg/apis/cloudevent/cloudevent.go index 1ad0fbc069..a53ea50402 100644 --- a/pkg/apis/cloudevent/cloudevent.go +++ b/pkg/apis/cloudevent/cloudevent.go @@ -22,9 +22,21 @@ import ( ) type CloudeventListInput struct { - apis.VirtualResourceListInput + apis.ModelBaseListInput - compute.ManagedResourceListInput + compute.CloudenvResourceListInput + + // 服务类型 + Service []string `json:"service"` + + // 订阅 + Manager []string `json:"manager"` + + // 账号 + Account []string `json:"account"` + + // 操作类型 + Action []string `json:"action"` // 操作日志起始时间 Since time.Time `json:"since"` diff --git a/pkg/cloudevent/models/cloudevents.go b/pkg/cloudevent/models/cloudevents.go index caf10a5100..03f2c567fe 100644 --- a/pkg/cloudevent/models/cloudevents.go +++ b/pkg/cloudevent/models/cloudevents.go @@ -91,19 +91,6 @@ func (manager *SCloudeventManager) ListItemFilter( return nil, errors.Wrap(err, "SVirtualResourceBaseManager.ListItemFilter") } - /* input.Cloudprovider = input.CloudproviderStr() - if len(input.Cloudprovider) > 0 { - providerObj, err := CloudproviderManager.FetchByIdOrName(userCred, input.Cloudprovider) - if err != nil { - if err == sql.ErrNoRows { - return nil, httperrors.NewResourceNotFoundError2(CloudproviderManager.Keyword(), input.Cloudprovider) - } else { - return nil, httperrors.NewGeneralError(err) - } - } - q = q.Equals("cloudprovider_id", providerObj.GetId()) - }*/ - if len(input.Providers) > 0 { q = q.In("provider", input.Providers) } @@ -112,6 +99,22 @@ func (manager *SCloudeventManager) ListItemFilter( q = q.In("brand", input.Brands) } + if len(input.Service) > 0 { + q = q.In("service", input.Service) + } + + if len(input.Manager) > 0 { + q = q.In("manager", input.Manager) + } + + if len(input.Account) > 0 { + q = q.In("account", input.Account) + } + + if len(input.Action) > 0 { + q = q.In("action", input.Action) + } + if !input.Since.IsZero() { q = q.GT("created_at", input.Since) }