package response type ErrCode struct { Code int Msg string } const ( SUCCESS = 200 AUTHORIZATION_EXPIRED = 401 INVALID_TOKEN = 403 NOT_FOUND = 404 ERROR = 500 PLATFORM_ERROR = 1001 // 第三方错误 REDIS_ERROR = 1002 // 缓存错误 VALIDATOR_ERROR = 1003 // validator校验器错误 DEBUG_ERROR = 1004 // DEBUG的错误信息 DB_ERROR = 1005 // DB异常 PERMISSION_NOT_ALLOWED = 1006 DATA_NOT_FOUND = 9000 NEED_REGIST = 9001 SIGN_ERROR = 9002 ACCOUNT_FORBID = 9003 USER_MOBILE_NOT_BIND = 10002 ) var ErrorCodeMessage = map[int]string{ SUCCESS: "操作成功", ERROR: "服务器异常", NOT_FOUND: "无操作权限", AUTHORIZATION_EXPIRED: "凭证已失效,请重新登录", INVALID_TOKEN: "凭证无效,请重新登录", PLATFORM_ERROR: "第三方调用异常", REDIS_ERROR: "服务器异常[1002]", VALIDATOR_ERROR: "参数输入错误,请仔细检查", DEBUG_ERROR: "服务器异常", DB_ERROR: "服务器异常[1005]", PERMISSION_NOT_ALLOWED: "您没有权限进行该操作", DATA_NOT_FOUND: "该项不存在", NEED_REGIST: "服务人员不存在,请先补充资料", SIGN_ERROR: "签名错误", ACCOUNT_FORBID: "您的账号已被禁用", } var ( ErrSuccess = &ErrCode{Code: SUCCESS, Msg: ErrorCodeMessage[SUCCESS]} Err = &ErrCode{Code: ERROR, Msg: ErrorCodeMessage[ERROR]} ErrNotFound = &ErrCode{Code: NOT_FOUND, Msg: ErrorCodeMessage[NOT_FOUND]} ErrAuthorizationExpired = &ErrCode{Code: AUTHORIZATION_EXPIRED, Msg: ErrorCodeMessage[AUTHORIZATION_EXPIRED]} ErrInvalidToken = &ErrCode{Code: INVALID_TOKEN, Msg: ErrorCodeMessage[INVALID_TOKEN]} ErrPlatform = &ErrCode{Code: PLATFORM_ERROR, Msg: ErrorCodeMessage[PLATFORM_ERROR]} ErrRedis = &ErrCode{Code: REDIS_ERROR, Msg: ErrorCodeMessage[REDIS_ERROR]} ErrValidator = &ErrCode{Code: VALIDATOR_ERROR, Msg: ErrorCodeMessage[VALIDATOR_ERROR]} ErrDebug = &ErrCode{Code: DEBUG_ERROR, Msg: ErrorCodeMessage[DEBUG_ERROR]} ErrDatabase = &ErrCode{Code: DB_ERROR, Msg: ErrorCodeMessage[DB_ERROR]} ErrPermissionNotAllowed = &ErrCode{Code: PERMISSION_NOT_ALLOWED, Msg: ErrorCodeMessage[PERMISSION_NOT_ALLOWED]} ErrDataNotFound = &ErrCode{Code: DATA_NOT_FOUND, Msg: ErrorCodeMessage[DATA_NOT_FOUND]} ErrNeedRegist = &ErrCode{Code: NEED_REGIST, Msg: ErrorCodeMessage[NEED_REGIST]} ErrSign = &ErrCode{Code: SIGN_ERROR, Msg: ErrorCodeMessage[SIGN_ERROR]} ErrAccountForbid = &ErrCode{Code: ACCOUNT_FORBID, Msg: ErrorCodeMessage[ACCOUNT_FORBID]} )