29 lines
929 B
Go
29 lines
929 B
Go
|
|
/**
|
|||
|
|
* package model
|
|||
|
|
* 作用:定义统一的API响应格式
|
|||
|
|
*/
|
|||
|
|
package model
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* InterfaceInfo
|
|||
|
|
* 作用:接口信息,包含响应时间和服务器标识
|
|||
|
|
*/
|
|||
|
|
type InterfaceInfo struct {
|
|||
|
|
ResultTime string `json:"result_time"` // 响应时间,格式:XX ms
|
|||
|
|
Ecs string `json:"ecs"` // 服务器标识
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* ApiResponse
|
|||
|
|
* 作用:统一的API响应结构体
|
|||
|
|
* 说明:所有API响应都使用此格式,HTTP状态码统一返回200,错误通过code字段标识
|
|||
|
|
*/
|
|||
|
|
type ApiResponse struct {
|
|||
|
|
Code int `json:"code"` // 业务状态码:0=成功,非0=失败
|
|||
|
|
Message string `json:"message"` // 响应消息
|
|||
|
|
Result interface{} `json:"result"` // 响应数据
|
|||
|
|
Type string `json:"type"` // 响应类型:"success" 或 "error"
|
|||
|
|
InterfaceInfo InterfaceInfo `json:"interface_info"` // 接口信息
|
|||
|
|
}
|
|||
|
|
|