66 lines
1.2 KiB
Go
66 lines
1.2 KiB
Go
package errorcode
|
|
|
|
const (
|
|
//成功
|
|
Success = 200
|
|
|
|
//参数错误
|
|
ParamError = 400
|
|
|
|
//未经授权
|
|
NotAuth = 401
|
|
|
|
//失效期
|
|
TokenNotValid = 402
|
|
|
|
//请求被禁止
|
|
Forbidden = 403
|
|
|
|
//找不到页面
|
|
NotFound = 404
|
|
|
|
//系统错误
|
|
SystemError = 500
|
|
|
|
//未登录
|
|
NotLogin = 1000
|
|
|
|
//抽奖中
|
|
OrderLottery = 1001
|
|
//商品不存在
|
|
OrderProductNotExist = 1002
|
|
//兴业下单失败
|
|
XINYEOrderFAIL = 1003
|
|
)
|
|
|
|
var MsgEN = map[int]string{
|
|
Success: "success",
|
|
ParamError: "param error",
|
|
NotAuth: "not authorized",
|
|
Forbidden: "forbidden",
|
|
NotFound: "not found",
|
|
SystemError: "system error",
|
|
}
|
|
var MsgZH = map[int]string{
|
|
Success: "请求成功",
|
|
ParamError: "参数错误",
|
|
NotFound: "数据不存在",
|
|
TokenNotValid: "Token无效",
|
|
NotAuth: "未经授权",
|
|
NotLogin: "未登录",
|
|
OrderLottery: "兑换中",
|
|
OrderProductNotExist: "商品不存在",
|
|
XINYEOrderFAIL: "三方下单失败",
|
|
}
|
|
var MsgMap map[string]map[int]string = map[string]map[int]string{"en": MsgZH}
|
|
|
|
func GetMsg(code int, local string) string {
|
|
if local == "" {
|
|
local = "en"
|
|
}
|
|
if msg, ok := MsgMap[local][code]; ok {
|
|
return msg
|
|
}
|
|
return ""
|
|
}
|