youtu_ecpm/api/gin/controller/controller.go

31 lines
561 B
Go
Raw Normal View History

2025-01-18 17:56:36 +08:00
package controller
import (
"github.com/gin-gonic/gin"
"net/http"
)
type Controller struct {
}
func (c *Controller) ResponseErr(ctx *gin.Context, err error) {
ctx.JSON(http.StatusOK, gin.H{
"code": http.StatusInternalServerError,
"msg": err.Error(),
})
}
func (c *Controller) ResponseErrParam(ctx *gin.Context) {
ctx.JSON(http.StatusOK, gin.H{
"code": http.StatusBadRequest,
"msg": "请求参数错误",
})
}
func (c *Controller) ResponseOk(ctx *gin.Context) {
ctx.JSON(http.StatusOK, gin.H{
"code": http.StatusOK,
"msg": "ok",
})
}