Files
MRCC/server/pkg/response/response.go
T

28 lines
492 B
Go
Raw Normal View History

2026-08-07 23:39:47 +08:00
package response
import "github.com/gin-gonic/gin"
// 标准响应结构
// {"code": 0, "message": "ok", "data": ...}
const codeOK = 0
const codeError = 1
// OK 返回成功响应
func OK(c *gin.Context, data any) {
c.JSON(200, gin.H{
"code": codeOK,
"message": "ok",
"data": data,
})
}
// Error 返回错误响应
func Error(c *gin.Context, httpStatus int, message string) {
c.JSON(httpStatus, gin.H{
"code": codeError,
"message": message,
"data": nil,
})
}