Skip to content

Commit

Permalink
fix_namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangming committed Nov 12, 2024
1 parent 6544fb4 commit 9453c44
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions store/postgresql/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"errors"
"fmt"
"github.com/polarismesh/polaris/common/utils"
"strconv"
"time"

"github.com/polarismesh/polaris/common/model"
Expand Down Expand Up @@ -283,10 +282,9 @@ func namespaceFetchRows(rows *sql.Rows) ([]*model.Namespace, error) {
defer rows.Close()

var (
out []*model.Namespace
ctimeStr, mtimeStr string
flag int
serviceExportTo string
out []*model.Namespace
flag int
serviceExportTo string
)

for rows.Next() {
Expand All @@ -297,26 +295,14 @@ func namespaceFetchRows(rows *sql.Rows) ([]*model.Namespace, error) {
&space.Token,
&space.Owner,
&flag,
&ctimeStr,
&mtimeStr,
&space.CreateTime,
&space.ModifyTime,
&serviceExportTo)
if err != nil {
log.Errorf("[Store][database] fetch namespace rows scan err: %s", err.Error())
return nil, err
}

// 将字符串转换为int64
ctimeFloat, err := strconv.ParseFloat(ctimeStr, 64)
if err != nil {
return nil, fmt.Errorf("failed to parse create_time: %v", err)
}
mtimeFloat, err := strconv.ParseFloat(mtimeStr, 64)
if err != nil {
return nil, fmt.Errorf("failed to parse modify_time: %v", err)
}
space.CreateTime = time.Unix(int64(ctimeFloat), 0)
space.ModifyTime = time.Unix(int64(mtimeFloat), 0)

space.ServiceExportTo = map[string]struct{}{}
_ = json.Unmarshal([]byte(serviceExportTo), &space.ServiceExportTo)

Expand Down

0 comments on commit 9453c44

Please sign in to comment.