baseProtocol

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Mysql                      = 3300 // Mysql基礎號段
	Mysql_InvalidInput         = 3301 // 無效參數
	Mysql_ResourceNotFound     = 3302 // 資源不存在
	Mysql_Unknown              = 3303 // 未知錯誤
	Mysql_InternalServiceError = 3304 // 內部服務錯誤
	Mysql_ExternalServiceError = 3305 // 外部服務錯誤
)
View Source
const CreatedSuccess = 10001 // Success : 新增成功返回
View Source
const DeletedSuccess = 10003 // Success : 刪除成功返回
View Source
const Success = 10000 // Success : 正常返回
View Source
const UnknownStatusCode = "Unknown Status Code"

UnknownStatusCode : 未知代碼(可能未宣告const或map)

View Source
const UpdatedSuccess = 10002 // Success : 更新成功返回

Variables

View Source
var ErrKeyConflict = errors.New("key conflict")

ErrKeyConflict : retStatusCode衝突

View Source
var ErrKeyOutOfRange = errors.New("key out of range")

ErrKeyOutOfRange : retStatusCode 超出可自訂範圍(自訂範圍為6位數)

Functions

func Err

func Err(statusCode int) (e error)

Err : 將 statusCode 轉為 error (自動判斷)

func Get

func Get(statusCode int) (int, error)

Get : 取得基於 retStatus 的 error / 若為 10000 則輸出 nil

func GetStatusMsg

func GetStatusMsg(statusCode int) (s string)

GetStatusMsg : 將 statusCode 轉為 error msg

func New

func New(retStatusMap map[int]GroupRetStatusCode) error

New : 新增額外的retCode

func Override

func Override(retStatusMap map[int]GroupRetStatusCode)

取代掉預設的 retStatusCode

Types

type BaseRequest

type BaseRequest struct {
	BaseUrl      string `json:"baseUrl"`
	BaseSendTime int64  `json:"baseSendTime"`
	BaseScgToken string `json:"baseScgToken"`
	MemberId     string `json:"memberId"`
}

後台端

type BaseResponse

type BaseResponse struct {
	RetStatus RetStatus `json:"retStatus"`
}

BaseResponse : 基礎回應資料結構

func (BaseResponse) Error

func (b BaseResponse) Error() string

type GameBaseRequest

type GameBaseRequest struct {
	BaseUrl      string `json:"BaseUrl"`
	BaseSendTime int64  `json:"BaseSendTime"`
	BaseScgToken string `json:"BaseScgToken"`
	MemberId     string `json:"MemberId"`
}

Game端

type GameRetStatus

type GameRetStatus struct {
	StatusCode int    `json:"StatusCode" qs:"StatusCode"`
	StatusMsg  string `json:"StatusMsg" qs:"StatusMsg"`
	SystemTime int64  `json:"SystemTime" qs:"SystemTime"`
	CheckCode  int    `json:"CheckCode" qs:"CheckCode"`
}

Game端

func CreateGame

func CreateGame(statusCode int) (retStatus *GameRetStatus)

CreateGame : 新增retStatus :後台端

type GroupRetStatusCode

type GroupRetStatusCode struct {
	CheckCode int    `json:"statusCode,omitempty"`
	StatusMsg string `json:"statusMsg"`
}

type RetStatus

type RetStatus struct {
	StatusCode int    `json:"statusCode" qs:"statusCode"`
	StatusMsg  string `json:"statusMsg" qs:"statusMsg"`
	SystemTime int64  `json:"systemTime" qs:"systemTime"`
	CheckCode  int    `json:"checkCode" qs:"checkCode"`
}

後台端

func Create

func Create(statusCode int) (retStatus *RetStatus)

Create : 新增retStatus :後台端

func CreateSuccess

func CreateSuccess() (retStatus *RetStatus)

CreateSuccess : 建立一個 Success 的 RetStatus

func (*RetStatus) Err

func (retStatus *RetStatus) Err() (e error)

Err : 將 statusCode 轉為 error (自動判斷)

func (RetStatus) Error

func (r RetStatus) Error() string

func (*RetStatus) Is

func (retStatus *RetStatus) Is(retStatusCode int) bool

IsSuccess : 判斷是否為指定 Code

func (*RetStatus) IsSuccess

func (retStatus *RetStatus) IsSuccess() bool

IsSuccess : 判斷是否為 Success

func (RetStatus) MarshalJSON

func (r RetStatus) MarshalJSON() ([]byte, error)

func (*RetStatus) SetSuccess

func (retStatus *RetStatus) SetSuccess()

SetSuccess : 設定為 Success

func (*RetStatus) Update

func (retStatus *RetStatus) Update(statusCode int)

Update : 更新retStatus

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL