You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package nerr
|
|
|
|
|
|
|
|
// TODO 后期做成配置式的
|
|
|
|
|
|
|
|
var message map[uint32]string
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
message = make(map[uint32]string)
|
|
|
|
message[OK] = "成功"
|
|
|
|
message[ServerCommonError] = "服务器开小差了,请稍后再试。"
|
|
|
|
message[RequestParamError] = "请求参数错误。"
|
|
|
|
message[TokenExpireError] = "令牌失效了,请重新登录。"
|
|
|
|
message[TokenGenerateError] = "令牌生成错误,请重试。"
|
|
|
|
message[DBError] = "数据库繁忙,请稍后再试。"
|
|
|
|
message[DBUpdateAffectedZeroError] = "更新数据影响行数为0" // 不一定是错误
|
|
|
|
message[CopyError] = "数据转换失败,请稍后再试。"
|
|
|
|
// 业务
|
|
|
|
message[UserIntegralNotEnoughError] = "用户积分不足"
|
|
|
|
}
|
|
|
|
|
|
|
|
func MapErrMsg(code uint32) string {
|
|
|
|
if msg, ok := message[code]; ok {
|
|
|
|
return msg
|
|
|
|
} else {
|
|
|
|
return "服务器开小差啦,稍后再来试一试"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func IsCodeErr(code uint32) bool {
|
|
|
|
if _, ok := message[code]; ok {
|
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|