Skip to content

Commit

Permalink
fix: invalid api response type
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhengYa-0110 committed Jan 20, 2025
1 parent 65b053a commit 9734995
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/controller/http/router/common/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Response struct {

// String returns the string representation of the response when Data is a byte slice.
func (r Response) String() string {
return fmt.Sprintf(`{"OPT_STATUS":%s,"DESCRIPTION":%s,"DATA":%s,"PAGE":%s}`, r.OptStatus, r.Description, string(r.Data.([]byte)), r.Page.String())
return fmt.Sprintf(`{"OPT_STATUS":"%s","DESCRIPTION":"%s","DATA":%s,"PAGE":%s}`, r.OptStatus, r.Description, string(r.Data.([]byte)), string(r.Page.Bytes()))
}

// Bytes returns the byte slice representation of the response when Data is a byte slice.
Expand All @@ -52,6 +52,11 @@ type Page struct {
TotalItem int `json:"TOTAL_ITEM"`
}

func (p Page) Bytes() []byte {
bytes, _ := json.Marshal(p)
return bytes
}

func (p Page) String() string {
bytes, _ := json.Marshal(p)
return string(bytes)
Expand Down

0 comments on commit 9734995

Please sign in to comment.