Skip to content

Commit

Permalink
fix: marshal json alias use pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 committed Nov 15, 2024
1 parent 6681ff1 commit 8cafa09
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions service/aiproxy/model/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ type Channel struct {
func (c *Channel) MarshalJSON() ([]byte, error) {
type Alias Channel
return json.Marshal(&struct {
Alias
*Alias
CreatedAt int64 `json:"created_at"`
AccessedAt int64 `json:"accessed_at"`
TestAt int64 `json:"test_at"`
BalanceUpdatedAt int64 `json:"balance_updated_at"`
}{
Alias: (Alias)(*c),
Alias: (*Alias)(c),
CreatedAt: c.CreatedAt.UnixMilli(),
AccessedAt: c.AccessedAt.UnixMilli(),
TestAt: c.TestAt.UnixMilli(),
Expand Down
4 changes: 2 additions & 2 deletions service/aiproxy/model/consumeerr.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ type ConsumeError struct {
func (c *ConsumeError) MarshalJSON() ([]byte, error) {
type Alias ConsumeError
return json.Marshal(&struct {
Alias
*Alias
CreatedAt int64 `json:"created_at"`
}{
Alias: (Alias)(*c),
Alias: (*Alias)(c),
CreatedAt: c.CreatedAt.UnixMilli(),
})
}
Expand Down
4 changes: 2 additions & 2 deletions service/aiproxy/model/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ type Group struct {
func (g *Group) MarshalJSON() ([]byte, error) {
type Alias Group
return json.Marshal(&struct {
Alias
*Alias
CreatedAt int64 `json:"created_at"`
AccessedAt int64 `json:"accessed_at"`
}{
Alias: (Alias)(*g),
Alias: (*Alias)(g),
CreatedAt: g.CreatedAt.UnixMilli(),
AccessedAt: g.AccessedAt.UnixMilli(),
})
Expand Down
4 changes: 2 additions & 2 deletions service/aiproxy/model/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ type Log struct {
func (l *Log) MarshalJSON() ([]byte, error) {
type Alias Log
return json.Marshal(&struct {
Alias
*Alias
CreatedAt int64 `json:"created_at"`
}{
Alias: (Alias)(*l),
Alias: (*Alias)(l),
CreatedAt: l.CreatedAt.UnixMilli(),
})
}
Expand Down
4 changes: 2 additions & 2 deletions service/aiproxy/model/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ type Token struct {
func (t *Token) MarshalJSON() ([]byte, error) {
type Alias Token
return json.Marshal(&struct {
Alias
*Alias
CreatedAt int64 `json:"created_at"`
AccessedAt int64 `json:"accessed_at"`
ExpiredAt int64 `json:"expired_at"`
}{
Alias: (Alias)(*t),
Alias: (*Alias)(t),
CreatedAt: t.CreatedAt.UnixMilli(),
AccessedAt: t.AccessedAt.UnixMilli(),
ExpiredAt: t.ExpiredAt.UnixMilli(),
Expand Down

0 comments on commit 8cafa09

Please sign in to comment.