mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
27 lines
493 B
Go
27 lines
493 B
Go
package response
|
|
|
|
import "encoding/json"
|
|
|
|
type IResponse interface {
|
|
IsSuccess() bool
|
|
}
|
|
|
|
type BaseResponse struct {
|
|
RequestId string `json:"request_id"`
|
|
Code string `json:"code"`
|
|
Msg string `json:"msg"`
|
|
SubCode string `json:"sub_code"`
|
|
SubMsg string `json:"sub_msg"`
|
|
}
|
|
|
|
func (resp BaseResponse) IsSuccess() bool {
|
|
return len(resp.SubCode) == 0
|
|
}
|
|
|
|
func ConvertResponse(data []byte, ptr interface{}) {
|
|
err := json.Unmarshal(data, ptr)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|