wx-server/internal/server/httpreply/httpreply.go

28 lines
606 B
Go
Raw Permalink Normal View History

2024-06-04 21:22:50 +08:00
package httpreply
import (
"net/http"
"github.com/gin-gonic/gin"
)
const (
Code_OK = 200
Code_Err = -1
)
type ReplyData struct {
Status int `json:"status"` // 状态码 200代表成功
Message string `json:"message"` // 消息
Data any `json:"data"` // 实体数据
}
func NewDefaultReplyData() *ReplyData { return &ReplyData{Status: 200, Message: "", Data: nil} }
func NewReplyData(status int, message string, data any) *ReplyData {
return &ReplyData{Status: status, Message: message, Data: data}
}
func Reply(c *gin.Context, data *ReplyData) {
c.JSON(http.StatusOK, data)
}