response

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERROR   = 7
	SUCCESS = 0
)

Variables

View Source
var Message = map[Code]string{
	ServerBusy: "服务器忙ing...",

	SuccessStart:        "成功码开始!",
	SuccessAdd:          "添加成功!",
	SuccessFirst:        "获取数据成功!",
	SuccessCreated:      "创建成功!",
	SuccessUpdated:      "更新成功!",
	SuccessDeleted:      "删除成功!",
	SuccessGetList:      "获取列表数据成功!",
	SuccessOperation:    "操作成功!",
	SuccessBatchDeleted: "批量删除成功!",
	SuccessEnd:          "成功码结束!",

	ErrorStart:        "失败码开始!",
	ErrorAdd:          "添加失败!",
	ErrorFirst:        "获取数据失败!",
	ErrorCreated:      "创建失败!",
	ErrorUpdated:      "更新失败!",
	ErrorDeleted:      "删除失败!",
	ErrorGetList:      "获取列表数据失败!",
	ErrorOperation:    "操作失败!",
	ErrorBatchDeleted: "批量删除失败!",
	ErrorEnd:          "失败码结束!",
}

Functions

This section is empty.

Types

type Code

type Code int
const (
	// ServerBusy 基础码
	ServerBusy Code = iota

	// SuccessStart 成功开始标记
	SuccessStart

	SuccessAdd
	SuccessFirst
	SuccessCreated
	SuccessDeleted
	SuccessUpdated
	SuccessGetList
	SuccessOperation
	SuccessBatchDeleted

	// SuccessEnd 成功结束标记
	SuccessEnd

	// ErrorStart 失败开始标记
	ErrorStart

	ErrorAdd
	ErrorFirst
	ErrorCreated
	ErrorUpdated
	ErrorDeleted
	ErrorGetList
	ErrorOperation
	ErrorBatchDeleted

	// ErrorEnd 失败结束标记
	ErrorEnd
)

func (Code) Message

func (c Code) Message() string

Message code 对应 massage Author [SliverHorn](https://github.com/SliverHorn)

type Handler

type Handler struct{}

func (*Handler) Handler

func (h *Handler) Handler() func(handler handler) func(r *ghttp.Request)

type Response

type Response struct {
	Code        int         `json:"code" swaggertype:"string" example:"int 状态码(成功:0, 失败:7)"`
	MessageCode Code        `json:"-"`
	Data        interface{} `json:"data" swaggertype:"string" example:"object 数据"`
	Error       error       `json:"-"`
	Err         string      `json:"err,omitempty" example:"错误信息"`
	Message     string      `json:"msg" example:"消息"`
}

Jump to

Keyboard shortcuts

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