model

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FAILURE = 410
	SUCCESS = 200
)
View Source
const (
	CLIENT = iota
	MASTER
	SLAVER
	ANALYSE
)

Variables

View Source
var (
	ErrorUnknow               = NewErr(9999, "未知错误")
	ErrorCustom               = NewErr(9000, "")
	ErrorParseParam           = NewErr(400, "参数解析成JSON出错! %v")
	ErrorKeyParam             = NewErr(400, "[%v] %v")
	ErrorHTTPMethodNotAllowed = NewErr(http.StatusMethodNotAllowed, http.StatusText(http.StatusMethodNotAllowed))

	ErrorNotProvideOperation = NewErr(2000, "未提供的操作")
)
View Source
var (
	GitCommit = ""
	GitTag    = ""
	BuildDate = ""
)

Functions

This section is empty.

Types

type Callback

type Callback func(result Result)

type ErrorModel

type ErrorModel struct {
	Code    int                    `json:"code"`
	Message string                 `json:"message"`
	Suggest string                 `json:"suggest"`
	Params  map[string]interface{} `json:"params"`
}

func NewCustomErr

func NewCustomErr(msg string, arg ...interface{}) *ErrorModel

func NewErr

func NewErr(code int, msg string) ErrorModel

func (*ErrorModel) AddParam

func (obj *ErrorModel) AddParam(key string, val interface{})

func (ErrorModel) ToError

func (obj ErrorModel) ToError() error

type RequestModel

type RequestModel struct {
	Method string
	Url    string
	Header map[string]interface{}
	Body   interface{}
}

func NewRequestModel

func NewRequestModel(url string) RequestModel

type ResponseModel

type ResponseModel struct {
	Header  map[string]interface{}
	Status  int
	Content interface{}
	Error   ErrorModel
}

type Result

type Result struct {
	Code    int //当前状态
	Header  map[string]interface{}
	Error   *ErrorModel //输出的内容(出错的提示)
	Context interface{} //执行后的结果
}

func ErrorResult

func ErrorResult(err gErr.STError, v ...interface{}) Result

func ErrorStrResult

func ErrorStrResult(msg string, v ...interface{}) Result

func FailureResult

func FailureResult(msg string, v ...interface{}) Result

func FailureResultWithErr added in v1.0.1

func FailureResultWithErr(err error) Result

func SuccessResult

func SuccessResult(c interface{}) Result

func (Result) GetContext

func (r Result) GetContext() interface{}

func (Result) GetErrMsg

func (r Result) GetErrMsg() (int, string)

func (Result) Success

func (r Result) Success() bool

func (Result) ToError

func (r Result) ToError() error

func (Result) ToString

func (r Result) ToString() string

type ResultOperate

type ResultOperate interface {
	Success() bool
	GetErrMsg() (int, string)
	GetContext()
}

type RunStatus

type RunStatus int

RunStatus 运行状态

const (
	// RunStatusStopped 停止
	RunStatusStopped RunStatus = 0
	// RunStatusPrepare 准备中
	RunStatusPrepare RunStatus = 1
	// RunStatusRunning 当前运行中
	RunStatusRunning RunStatus = 2
	// RunStatusIdle 当前空闲中
	RunStatusIdle RunStatus = 9
)

Jump to

Keyboard shortcuts

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