1 Star 1 Fork 233

sea_wave/syncd

forked from dreamans/syncd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
render.go 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
dreamans 提交于 2019-01-10 22:24 . 修改包目录
// Copyright 2018 syncd Author. All Rights Reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package syncd
import (
"net/http"
"errors"
"fmt"
"github.com/tinystack/goweb"
)
const (
CODE_OK = 0
CODE_ERR_SYSTEM = 1000
CODE_ERR_APP = 1001
CODE_ERR_PARAM = 1002
CODE_ERR_DATA_REPEAT = 1003
CODE_ERR_LOGIN_FAILED = 1004
CODE_ERR_NO_LOGIN = 1005
CODE_ERR_NO_PRIV = 1006
CODE_ERR_TASK_ERROR = 1007
CODE_ERR_USER_OR_PASS_WRONG = 1008
)
func RenderParamError(msg string) error {
return RenderCustomerError(CODE_ERR_PARAM, msg)
}
func RenderAppError(msg string) error {
return RenderCustomerError(CODE_ERR_APP, msg)
}
func RenderTaskError(msg string) error {
return RenderCustomerError(CODE_ERR_TASK_ERROR, msg)
}
func RenderCustomerError(code int, msg string) error {
return errors.New(fmt.Sprintf("%d=>%s", code, msg))
}
func RenderJson(c *goweb.Context, data interface{}) error {
c.Json(http.StatusOK, goweb.JSON{
"code": CODE_OK,
"message": "success",
"data": data,
})
return nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/sea_wave/syncd.git
git@gitee.com:sea_wave/syncd.git
sea_wave
syncd
syncd
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385