common

package
v0.0.0-...-b89eba7 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(data string, v interface{}) error

Decode 将json格式的数据解析到结构体,并进行校验 参数: data: json格式的数据,v: 绑定的结构体 返回: 错误信息

Types

type List

type List struct {
	List  interface{} `json:"list"`  // 数据
	Total int         `json:"total"` // 总数
}

List 列表

type Pager

type Pager struct {
	Page     int32 `json:"page" form:"page"`           // 第几页
	PageSize int32 `json:"page_size" form:"page_size"` // 每页大小
}

Pager 分页

type State

type State struct {
	Code int         `json:"status_code"`    // 状态码,0-成功,其他值-失败
	Msg  string      `json:"status_msg"`     // 返回状态描述
	Data interface{} `json:"data,omitempty"` // 失败时返回空
}

State 状态码

func NewState

func NewState(merr errcode.Err, datas ...interface{}) *State

NewState 创建一个标准回复格式 参数: merr 错误信息(可为nil) datas 数据(存在只选择第一个值) 返回: 标准的回复格式结构

func (*State) Json

func (s *State) Json() ([]byte, error)

Json 将结构体转换为json格式的数据

func (*State) JsonStr

func (s *State) JsonStr() string

JsonStr 将结构体转换为json格式的数据,如果出错,则返回空json字符串

type Token

type Token struct {
	Token     string    `json:"token"`      // token
	ExpiredAt time.Time `json:"expired_at"` // token过期时间
}

Token token

Jump to

Keyboard shortcuts

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