You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2024/04/28 10:55:57 UTC
(incubator-devlake) branch main updated: fix(zentao): update storyID field in tasks reponse, make it compatiable with oss 18.11 (#7403)
This is an automated email from the ASF dual-hosted git repository.
abeizn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new f1ead30cc fix(zentao): update storyID field in tasks reponse, make it compatiable with oss 18.11 (#7403)
f1ead30cc is described below
commit f1ead30cc57ac3f872b36e65abb5c726f599a0d6
Author: Lynwee <li...@merico.dev>
AuthorDate: Sun Apr 28 18:55:49 2024 +0800
fix(zentao): update storyID field in tasks reponse, make it compatiable with oss 18.11 (#7403)
---
backend/core/models/common/string_int64.go | 78 ++++++++++++++++++++++
.../helpers/pluginhelper/api/graphql_collector.go | 2 +-
backend/plugins/zentao/models/task.go | 2 +-
3 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/backend/core/models/common/string_int64.go b/backend/core/models/common/string_int64.go
new file mode 100644
index 000000000..479996d40
--- /dev/null
+++ b/backend/core/models/common/string_int64.go
@@ -0,0 +1,78 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package common
+
+import (
+ "database/sql/driver"
+ "encoding/json"
+ "fmt"
+ "github.com/spf13/cast"
+)
+
+type StringInt64 struct {
+ v int64
+}
+
+func NewStringInt64FromAny(f interface{}) *StringInt64 {
+ return &StringInt64{
+ v: cast.ToInt64(f),
+ }
+}
+
+func (f *StringInt64) MarshalJSON() ([]byte, error) {
+ return json.Marshal(f.v)
+}
+
+func (f *StringInt64) String() string {
+ return fmt.Sprintf("%v", f.v)
+}
+
+func (f *StringInt64) UnmarshalJSON(data []byte) error {
+ var i interface{}
+ if err := json.Unmarshal(data, &i); err != nil {
+ return err
+ }
+ if v, ok := i.(string); ok && v == "" {
+ return nil
+ }
+ value, err := cast.ToInt64E(i)
+ if err != nil {
+ return err
+ }
+ f.v = value
+ return nil
+}
+
+func (f *StringInt64) Value() (driver.Value, error) {
+ if f == nil {
+ return nil, nil
+ }
+ return f.v, nil
+}
+
+func (f *StringInt64) Scan(v interface{}) error {
+ int64value, err := cast.ToInt64E(v)
+ if err != nil {
+ return err
+
+ }
+ *f = StringInt64{
+ v: int64value,
+ }
+ return nil
+}
diff --git a/backend/helpers/pluginhelper/api/graphql_collector.go b/backend/helpers/pluginhelper/api/graphql_collector.go
index a41eef950..d0adbbabb 100644
--- a/backend/helpers/pluginhelper/api/graphql_collector.go
+++ b/backend/helpers/pluginhelper/api/graphql_collector.go
@@ -90,7 +90,7 @@ type GraphqlCollector struct {
workerErrors []error
}
-// ErrFinishCollect is a error which will finish this collector
+// ErrFinishCollect is an error which will finish this collector
var ErrFinishCollect = errors.Default.New("finish collect")
// NewGraphqlCollector allocates a new GraphqlCollector with the given args.
diff --git a/backend/plugins/zentao/models/task.go b/backend/plugins/zentao/models/task.go
index 494d64aa9..e5d9d14fe 100644
--- a/backend/plugins/zentao/models/task.go
+++ b/backend/plugins/zentao/models/task.go
@@ -75,7 +75,7 @@ type ZentaoTaskRes struct {
V1 string `json:"v1"`
V2 string `json:"v2"`
Vision string `json:"vision"`
- StoryID int64 `json:"storyID"`
+ StoryID *common.StringInt64 `json:"storyID"`
StoryTitle string `json:"storyTitle"`
Branch interface {
} `json:"branch"`