daShangDao_getErpSendPublis.../utils/ApiResponse.go
2026-06-15 16:18:50 +08:00

23 lines
870 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package utils
import "time"
// ApiResponse 标准 API 响应结构(核心)
type ApiResponse struct {
Code int `json:"code"` // 业务状态码(非 HTTP 状态码)
Message string `json:"message"` // 提示信息(友好、明确)
Data any `json:"data"` // 返回数据(任意类型,可为 nil
Timestamp time.Time `json:"timestamp"`
}
// (可选)预定义业务状态码常量(根据项目调整)
const (
CodeSuccess = 200 // 成功
CodeParamMissing = 40001 // 参数缺失
CodeParamInvalid = 40002 // 参数无效(格式/类型错误)
CodeUnauthorized = 40101 // 未授权Token 失效/无权限)
CodeForbidden = 40301 // 禁止访问(权限不足)
CodeNotFound = 40401 // 资源不存在
CodeInternalError = 50001 // 服务器内部错误(如数据库异常)
)