rep

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: Apache-2.0 Imports: 2 Imported by: 3

Documentation

Index

Constants

View Source
const (
	Err = "9999" // 业务失败
	Ok  = "0000" // 业务成功
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code string

type Msg

type Msg struct {
	Code    string `json:"code"` // 状态码
	Message string `json:"resp"` // 附加消息
	Data    any    `json:"data"` // 响应数据
	Err     string `json:"err"`  // 错误信息
}

Msg 请求处理统一返回结果

func (*Msg) SetCode

func (msg *Msg) SetCode(code string)

func (*Msg) SetData

func (msg *Msg) SetData(data any)

func (*Msg) SetError

func (msg *Msg) SetError(err error)

func (*Msg) SetMessage

func (msg *Msg) SetMessage(m string)

func (*Msg) String

func (msg *Msg) String() string

type Page

type Page struct {
	Count int64 `json:"count"` //总数
	Rows  any   `json:"rows"`  //数据内容
}

Page 分页数据

func NewPage

func NewPage(count int64, data any) *Page

type Response

type Response struct {
	Code `json:"code"` // 状态码
	Msg  string        `json:"msg"`  // 附加消息
	Data any           `json:"data"` // 响应数据
	Err  string        `json:"err"`  // 错误信息
}

Response 请求处理统一返回结果

func Fail

func Fail(e error, message ...string) Response

Fail 业务处理失败

func Success

func Success(data any, message ...string) Response

Success 业务处理成功

Jump to

Keyboard shortcuts

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