Ai
2 Star 0 Fork 0

GGGGDDD/Gin-Cli-SQL

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
response.go 736 Bytes
一键复制 编辑 原始数据 按行查看 历史
GGGGDDD 提交于 2022-09-10 12:09 +08:00 . 初始化Gin脚手架
package controller
import (
"net/http"
"github.com/gin-gonic/gin"
)
type ResponseData struct {
Code MyCode `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
func ResponseError(ctx *gin.Context, c MyCode) {
rd := &ResponseData{
Code: c,
Message: c.Msg(),
Data: nil,
}
ctx.JSON(http.StatusOK, rd)
}
func ResponseErrorWithMsg(ctx *gin.Context, code MyCode, errMsg string) {
rd := &ResponseData{
Code: code,
Message: errMsg,
Data: nil,
}
ctx.JSON(http.StatusOK, rd)
}
func ResponseSuccess(ctx *gin.Context, data interface{}) {
rd := &ResponseData{
Code: CodeSuccess,
Message: CodeSuccess.Msg(),
Data: data,
}
ctx.JSON(http.StatusOK, rd)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/miaokela/gin-cli-sql.git
git@gitee.com:miaokela/gin-cli-sql.git
miaokela
gin-cli-sql
Gin-Cli-SQL
master

搜索帮助