一波更新
This commit is contained in:
97
trunk/center/common/resultstatus/resultStatus.go
Normal file
97
trunk/center/common/resultstatus/resultStatus.go
Normal file
@@ -0,0 +1,97 @@
|
||||
package resultStatus
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type StatusCode int
|
||||
|
||||
// ResultStatus
|
||||
//
|
||||
// @description: 状态码数据
|
||||
type ResultStatus struct {
|
||||
// 状态码
|
||||
code StatusCode
|
||||
|
||||
// 消息
|
||||
message string
|
||||
}
|
||||
|
||||
// Code
|
||||
//
|
||||
// @description: 状态码
|
||||
//
|
||||
// parameter:
|
||||
//
|
||||
// @receiver this: this
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @StatusCode: 状态码
|
||||
func (this *ResultStatus) Code() StatusCode {
|
||||
return this.code
|
||||
}
|
||||
|
||||
// Message
|
||||
//
|
||||
// @description: 错误信息
|
||||
//
|
||||
// parameter:
|
||||
//
|
||||
// @receiver this: this
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @string:
|
||||
func (this *ResultStatus) Message() string {
|
||||
return this.message
|
||||
}
|
||||
|
||||
// NewResultStatus
|
||||
//
|
||||
// @description: 创建新的状态码对象
|
||||
//
|
||||
// parameter:
|
||||
//
|
||||
// @_code: 错误码
|
||||
// @_message: 提示消息
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @ResultStatus: 状态码对象
|
||||
func NewResultStatus(_code StatusCode, _message string) ResultStatus {
|
||||
return ResultStatus{
|
||||
code: _code,
|
||||
message: _message,
|
||||
}
|
||||
}
|
||||
|
||||
// IsSuccess
|
||||
//
|
||||
// @description: 是否是成功
|
||||
//
|
||||
// parameter:
|
||||
//
|
||||
// @receiver this: this
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @bool: true:成功 false:失败
|
||||
func (this *ResultStatus) IsSuccess() bool {
|
||||
return this.code == Success.Code()
|
||||
}
|
||||
|
||||
// String
|
||||
//
|
||||
// @description: 打印状态码信息
|
||||
//
|
||||
// parameter:
|
||||
//
|
||||
// @receiver this: this
|
||||
//
|
||||
// return:
|
||||
//
|
||||
// @string: 状态码信息
|
||||
func (this *ResultStatus) String() string {
|
||||
return fmt.Sprintf("Code:%d,Message:%s", this.code, this.message)
|
||||
}
|
||||
105
trunk/center/common/resultstatus/resultStatusCode.go
Normal file
105
trunk/center/common/resultstatus/resultStatusCode.go
Normal file
@@ -0,0 +1,105 @@
|
||||
package resultStatus
|
||||
|
||||
// 系统错误码
|
||||
var (
|
||||
// 成功
|
||||
Success = NewResultStatus(0, "Success")
|
||||
|
||||
// 数据库错误
|
||||
DBError = NewResultStatus(-2, "DBError")
|
||||
|
||||
// 方法未定义
|
||||
MethodNotDefined = NewResultStatus(-3, "MethodNotDefined")
|
||||
|
||||
// 参数无效
|
||||
ParamInValid = NewResultStatus(-4, "ParamInValid")
|
||||
|
||||
// 参数不匹配
|
||||
ParamNotMatch = NewResultStatus(-5, "ParamNotMatch")
|
||||
|
||||
// 功能未开启
|
||||
ModuleNotOpen = NewResultStatus(-6, "ModuleNotOpen")
|
||||
|
||||
// 只支持Post
|
||||
OnlySupportPOST = NewResultStatus(-7, "OnlySupportPOST")
|
||||
|
||||
// API未定义
|
||||
APINotDefined = NewResultStatus(-8, "APINotDefined")
|
||||
|
||||
// API数据错误
|
||||
APIDataError = NewResultStatus(-9, "APIDataError")
|
||||
|
||||
// API参数错误
|
||||
APIParamError = NewResultStatus(-10, "APIParamError")
|
||||
|
||||
// IP被禁用
|
||||
IPForbid = NewResultStatus(-11, "IPForbid")
|
||||
|
||||
// 没有有效的服务器
|
||||
NoAvailableServer = NewResultStatus(-12, "NoAvailableServer")
|
||||
|
||||
// 服务器组不存在
|
||||
ServerGroupNotExists = NewResultStatus(-13, "ServerGroupNotExists")
|
||||
|
||||
// 测试接口只能debug下调用
|
||||
DebugInterface = NewResultStatus(-14, "DebugInterface")
|
||||
|
||||
// 模块不存在
|
||||
ModuleNotExists = NewResultStatus(-15, "ModuleNotExists")
|
||||
|
||||
// 未能找到指定方法
|
||||
NotSpecificMethod = NewResultStatus(-16, "NotSpecificMethod")
|
||||
|
||||
// 非指定区域
|
||||
NotMatchRegion = NewResultStatus(-17, "NotMatchRegion")
|
||||
|
||||
// 发送空数据
|
||||
SendNullData = NewResultStatus(-18, "SendNullData")
|
||||
|
||||
// 序列化失败
|
||||
MarshalDataError = NewResultStatus(-19, "MarshalDataError")
|
||||
|
||||
//未登录
|
||||
NotLogin = NewResultStatus(-20, "NotLogin")
|
||||
|
||||
// 数据错误
|
||||
DataError = NewResultStatus(-31, "DataError")
|
||||
|
||||
// 战区合并维护中,敬请期待
|
||||
MergeDataRunning = NewResultStatus(-67, "MergeDataRunning")
|
||||
|
||||
// 下载器内容未配置
|
||||
QcDownloadConfigNotExists = NewResultStatus(-68, "QcDownloadConfigNotExists")
|
||||
|
||||
// 下载器奖励已领取
|
||||
QcDownloadHasReward = NewResultStatus(-69, "QcDownloadHasReward")
|
||||
|
||||
// 下载器奖励没有奖励可领取
|
||||
QcDownloadNotReward = NewResultStatus(-70, "QcDownloadNotReward")
|
||||
|
||||
// 下载器奖励积分不足
|
||||
QcDownloadNotScore = NewResultStatus(-71, "QcDownloadNotScore")
|
||||
)
|
||||
|
||||
// 微信登录
|
||||
var (
|
||||
RequestError = NewResultStatus(-60001, "WrongRequeststatus")
|
||||
EmptyResp = NewResultStatus(-60002, "The result is empty")
|
||||
UnmarshalError = NewResultStatus(-60003, "Unmarshal is error")
|
||||
)
|
||||
|
||||
// 玩家
|
||||
var (
|
||||
|
||||
// 玩家不存在
|
||||
PlayerNotExist = NewResultStatus(-1110, "PlayerNotExist")
|
||||
|
||||
// 没有合适的玩家
|
||||
NotSuitablePlayer = NewResultStatus(-1155, "NotSuitablePlayer")
|
||||
|
||||
// 玩家阵容不存在
|
||||
PlayerSlotFormationNotExist = NewResultStatus(-1156, "PlayerSlotFormationNotExist")
|
||||
|
||||
//玩家已经下线
|
||||
PlayerIsLoginOut = NewResultStatus(-1157, "PlayerIsLoginOut")
|
||||
)
|
||||
Reference in New Issue
Block a user