1 Star 0 Fork 1

Yietion / go-utils

forked from 可乐烛光烟 / go-utils 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
jsonData.go 809 Bytes
一键复制 编辑 原始数据 按行查看 历史
可乐烛光烟 提交于 2022-11-09 00:21 . Initial commit
/*
* @Author: i@rysa.cn
* @Date: 2021-04-16 15:25:14
* @LastEditTime: 2021-10-12 12:03:38
* @LastEditors: i@rysa.cn
* @Description:
* @FilePath: \go-utils\jsonData.go
*/
package go_utils
type JsonData struct {
Code int `json:"code"`
Data interface{} `json:"data"`
Msg string `json:"msg"`
}
func Json(code int, data interface{}, msg string) *JsonData {
return &JsonData{
Code: code,
Data: data,
Msg: msg,
}
}
func JsonNoData(code int, msg string) *JsonData {
return &JsonData{
Code: code,
Msg: msg,
}
}
func JsonErr(code int, err error) *JsonData {
return &JsonData{
Code: code,
Msg: err.Error(),
}
}
func Response(code int, err error, msg string, data interface{}) *JsonData {
if err != nil {
return JsonErr(code, err)
}
return Json(200, data, msg)
}
1
https://gitee.com/yietion/go-utils.git
git@gitee.com:yietion/go-utils.git
yietion
go-utils
go-utils
master

搜索帮助