XinYeYouKu/app/constants/errorcode/error_code.go

67 lines
1.3 KiB
Go
Raw Normal View History

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