service/api/base/response.go

25 lines
528 B
Go
Raw Normal View History

2023-12-21 22:17:40 +08:00
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,
})
}