You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ly...@apache.org on 2024/04/28 10:45:33 UTC

(incubator-devlake) branch zentao-oss-18-11 created (now e1cd1309b)

This is an automated email from the ASF dual-hosted git repository.

lynwee pushed a change to branch zentao-oss-18-11
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


      at e1cd1309b fix(zentao): update storyID field in tasks reponse, make it compatiable with oss 18.11

This branch includes the following new commits:

     new e1cd1309b fix(zentao): update storyID field in tasks reponse, make it compatiable with oss 18.11

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(incubator-devlake) 01/01: fix(zentao): update storyID field in tasks reponse, make it compatiable with oss 18.11

Posted by ly...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lynwee pushed a commit to branch zentao-oss-18-11
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit e1cd1309b0d1e1510e55cfce900142f51e85c51e
Author: d4x1 <15...@qq.com>
AuthorDate: Sun Apr 28 18:45:22 2024 +0800

    fix(zentao): update storyID field in tasks reponse, make it compatiable with oss 18.11
---
 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"`