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,
	})
}
