PaymentCenter/app/constants/errorcode/error_code.go

64 lines
1.1 KiB
Go

package errorcode
const (
//成功
Success = 200
//参数错误
ParamError = 400
//未经授权
NotAuth = 401
//请求被禁止
Forbidden = 403
//找不到页面
NotFound = 404
//系统错误
SystemError = 500
//未登录
NotLogin = 1000
// 商户
MerchantNotFound = 1100
AppNotFound = 1200
PayChannelNotFound = 1300
)
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: "数据不存在",
NotAuth: "未经授权",
NotLogin: "未登录",
MerchantNotFound: "商户不存在",
AppNotFound: "应用不存在",
PayChannelNotFound: "支付方式不存在",
}
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 ""
}