Documentation
¶
Index ¶
- Constants
- func CodeMsg(code int) string
- func ErrorCheck(r *ghttp.Request, err error)
- func Fail(r *ghttp.Request)
- func FailWithData(r *ghttp.Request, data interface{})
- func FailWithDetailed(r *ghttp.Request, code int, data interface{}, message string)
- func FailWithMessage(r *ghttp.Request, message string)
- func GetTranslate(r *ghttp.Request, msg string, sl, tl string) (message string)
- func Json(r *ghttp.Request, code int, message string, data ...interface{})
- func JsonExit(r *ghttp.Request, err int, msg string, data ...interface{})
- func NullCheck(r *ghttp.Request, data ...interface{})
- func Ok(r *ghttp.Request)
- func OkDetailed(r *ghttp.Request, data interface{}, message string)
- func OkWithData(r *ghttp.Request, data interface{})
- func OkWithMessage(r *ghttp.Request, message string)
- func Result(r *ghttp.Request, code int, data interface{}, message string)
- func RoundRobin(mps map[string]string, index int) (AppId, Sign string)
- func SetAdapter(redis gcache.Adapter)
- func Translate(r *ghttp.Request, message string) (string, error)
- func TranslateCtx(ctx context.Context, message string) (string, error)
- func WithStatus(r *ghttp.Request, status int, code int, data interface{}, message string)
- type BaiduTranslateRsp
- type JsonResponse
- type Limiters
Constants ¶
View Source
const ( INVALID = -1 DB_SAVE_ERROR = -2 DB_READ_ERROR = -3 CACHE_SAVE_ERROR = -4 CACHE_READ_ERROR = -5 FILE_SAVE_ERROR = -6 LOGIN_ERROR = -7 NOT_EXISTS = -8 JSON_PARSE_FAIL = -9 TYPE_ERROR = -10 NUMBER_MATCH_ERROR = -11 EMPTY_PARAMS = -12 DATA_EXISTS = -13 AUTH_ERROR = -14 OTHER_LOGIN = -16 VERSION_INVALID = -17 CURL_ERROR = -18 RECORD_NOT_FOUND = -19 // 记录未找到 DELETE_FAILED = -20 // 删除失败 ADD_FAILED = -21 // 添加记录失败 UPDATE_FAILED = -22 // 添加记录失败 PARAM_INVALID = -995 // 参数无效 ACCESS_TOKEN_TIMEOUT = -996 SESSION_TIMEOUT = -997 UNKNOWN = -998 EXCEPTION = -999 )
View Source
const ( Buniss_Other int = 0 //0其它 Buniss_Add int = 1 //1新增 Buniss_Edit int = 2 //2修改 Buniss_Del int = 3 //3删除 Buniss_Auth int = 4 //4授权 Buniss_Export int = 5 //5导出 Buniss_Import int = 6 //6导入 Buniss_Retreat int = 7 //7强退 Buniss_Clean int = 8 //8清空数据 )
View Source
const ( Status202 int = 202 //(已接受)服务器已接受请求,但尚未处理 Status204 int = 204 //(无内容)服务器成功处理了请求,但没有返回任何内容 Status206 int = 206 //(部分内容)服务器成功处理了部分 GET 请求 Status401 int = 401 //(未授权)请求要求身份验证。对于登录后请求的网页,服务器可能返回此响应 Status403 int = 403 //(禁止)服务器拒绝请求 Status412 int = 412 //前提条件失败 Status417 int = 417 //执行失败 Status500 int = 500 //(服务器内部错误)服务器遇到错误,无法完成请求 )
View Source
const ( SUCCESS = 0 ERROR = 1 NOTLOGIN = 2 UNAUTHORIZED = 3 )
Variables ¶
This section is empty.
Functions ¶
func FailWithData ¶
func FailWithDetailed ¶
func FailWithMessage ¶
func OkDetailed ¶
func OkWithData ¶
func OkWithMessage ¶
func SetAdapter ¶
Types ¶
type BaiduTranslateRsp ¶
type JsonResponse ¶
type JsonResponse struct { Code int `json:"code"` // 错误码((0:成功, 1:失败, >1:错误码)) Data interface{} `json:"data"` // 返回数据(业务接口定义具体数据结构) Message string `json:"msg"` // 提示信息 }
数据返回通用JSON数据结构
func (JsonResponse) Json ¶
func (resp JsonResponse) Json() string
func (JsonResponse) Success ¶
func (resp JsonResponse) Success() bool
Click to show internal directories.
Click to hide internal directories.