This commit is contained in:
Fu Diwei 2025-04-18 18:20:01 +08:00
parent c10ceed753
commit 32ff658e84

View File

@ -1,6 +1,6 @@
package cdnflysdk package cdnflysdk
import "encoding/json" import "fmt"
type BaseResponse interface { type BaseResponse interface {
GetCode() string GetCode() string
@ -8,12 +8,24 @@ type BaseResponse interface {
} }
type baseResponse struct { type baseResponse struct {
Code json.Number `json:"code"` Code any `json:"code"`
Message string `json:"msg"` Message string `json:"msg"`
} }
func (r *baseResponse) GetCode() string { func (r *baseResponse) GetCode() string {
return r.Code.String() if r.Code == nil {
return ""
}
if code, ok := r.Code.(int); ok {
return fmt.Sprintf("%d", code)
}
if code, ok := r.Code.(string); ok {
return code
}
return ""
} }
func (r *baseResponse) GetMessage() string { func (r *baseResponse) GetMessage() string {