service/api/base/response.go

25 lines
528 B
Go

package base
import (
"github.com/gin-gonic/gin"
"net/http"
"service/api/consts"
"service/api/errcode"
)
type BaseResponse struct {
Ret int `json:"ret"`
Data any `json:"data"`
Msg string `json:"msg"`
ErrCode errcode.ErrCode `json:"errcode"`
RequestId string `json:"request_id"`
}
func ReplyOk(ctx *gin.Context, data any) {
ctx.JSON(http.StatusOK, BaseResponse{
Ret: consts.RetCodeSuccess,
ErrCode: consts.ErrorCodeSuccess,
Data: data,
})
}