types

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OK      = 0
	SUCCESS = "success"

	InvalidParams = 10000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EmptyStruct

type EmptyStruct struct{}

func NewEmptyStruct

func NewEmptyStruct() EmptyStruct

type MultiErr

type MultiErr struct {
	Errs []error
}

func (*MultiErr) AddErr

func (m *MultiErr) AddErr(args ...error)

AddErr 添加错误

func (*MultiErr) AsStdErr

func (m *MultiErr) AsStdErr() error

AsStdErr 转换为标准库错误

func (*MultiErr) Error

func (m *MultiErr) Error() string

func (*MultiErr) IsEmpty

func (m *MultiErr) IsEmpty() bool

IsEmpty 是否为空

func (*MultiErr) IsNotEmpty

func (m *MultiErr) IsNotEmpty() bool

IsNotEmpty 是否为空

type NullBool

type NullBool struct {
	sql.NullBool
}

NullBool is an alias for sql.NullBool data type

func NewBool

func NewBool(v bool) NullBool

func NewBoolNull

func NewBoolNull() NullBool

func (NullBool) Empty

func (nb NullBool) Empty() bool

Empty 判断为nil或false

func (*NullBool) Equal

func (nb *NullBool) Equal(v NullBool) bool

Equal 比较是否相等

func (*NullBool) GetValue

func (nb *NullBool) GetValue() bool

GetValue 获取值

func (*NullBool) IsNull added in v1.1.5

func (nb *NullBool) IsNull() bool

IsNull 是否是Nil

func (NullBool) MarshalJSON

func (nb NullBool) MarshalJSON() ([]byte, error)

MarshalJSON for NullBool

func (NullBool) String

func (nb NullBool) String() string

func (*NullBool) UnmarshalJSON

func (nb *NullBool) UnmarshalJSON(b []byte) error

UnmarshalJSON for NullBool

type NullFloat64

type NullFloat64 struct {
	sql.NullFloat64
}

NullFloat64 is an alias for sql.NullFloat64 data type

func NewFloat64

func NewFloat64(v float64) NullFloat64

func NewFloat64Null

func NewFloat64Null() NullFloat64

func (NullFloat64) Empty

func (nf NullFloat64) Empty() bool

Empty 判断为nil或0

func (*NullFloat64) Equal

func (nf *NullFloat64) Equal(v NullFloat64) bool

Equal 比较是否相等

func (*NullFloat64) GetValue

func (nf *NullFloat64) GetValue() float64

GetValue 获取值

func (*NullFloat64) IsNull added in v1.1.5

func (nf *NullFloat64) IsNull() bool

IsNull 是否是Nil

func (NullFloat64) MarshalJSON

func (nf NullFloat64) MarshalJSON() ([]byte, error)

MarshalJSON for NullFloat64

func (NullFloat64) String

func (nf NullFloat64) String() string

func (*NullFloat64) UnmarshalJSON

func (nf *NullFloat64) UnmarshalJSON(b []byte) error

UnmarshalJSON for NullFloat64

type NullInt

type NullInt struct {
	sql.NullInt64
}

NullInt is an alias for sql.NullInt64 data type

func NewInt

func NewInt(v int) NullInt

func NewIntNull

func NewIntNull() NullInt

func (NullInt) Empty

func (ni NullInt) Empty() bool

Empty 判断为nil或0

func (*NullInt) Equal

func (ni *NullInt) Equal(v NullInt) bool

Equal 比较是否相等

func (*NullInt) GetValue

func (ni *NullInt) GetValue() int

GetValue 获取值

func (*NullInt) IsNull added in v1.1.5

func (ni *NullInt) IsNull() bool

IsNull 是否是Nil

func (NullInt) MarshalJSON

func (ni NullInt) MarshalJSON() ([]byte, error)

MarshalJSON for NullInt

func (NullInt) String

func (ni NullInt) String() string

func (*NullInt) UnmarshalJSON

func (ni *NullInt) UnmarshalJSON(b []byte) error

UnmarshalJSON for NullInt

type NullInt64

type NullInt64 struct {
	sql.NullInt64
}

NullInt64 is an alias for sql.NullInt64 data type

func NewInt64

func NewInt64(v int64) NullInt64

func NewInt64Null

func NewInt64Null() NullInt64

func (NullInt64) Empty

func (ni NullInt64) Empty() bool

Empty 判断为nil或0

func (*NullInt64) Equal

func (ni *NullInt64) Equal(v NullInt64) bool

Equal 比较是否相等

func (*NullInt64) GetValue

func (ni *NullInt64) GetValue() int64

GetValue 获取值

func (*NullInt64) IsNull added in v1.1.5

func (ni *NullInt64) IsNull() bool

IsNull 是否是Nil

func (NullInt64) MarshalJSON

func (ni NullInt64) MarshalJSON() ([]byte, error)

MarshalJSON for NullInt64

func (NullInt64) String

func (ni NullInt64) String() string

func (*NullInt64) UnmarshalJSON

func (ni *NullInt64) UnmarshalJSON(b []byte) error

UnmarshalJSON for NullInt64

type NullString

type NullString struct {
	sql.NullString
}

NullString is an alias for sql.NullString data type

func NewEmptyStr

func NewEmptyStr() NullString

func NewStr

func NewStr(str string) NullString

func NewStrNull

func NewStrNull() NullString

func (NullString) Empty

func (ns NullString) Empty() bool

Empty 判断为nil或""

func (*NullString) Equal

func (ns *NullString) Equal(v NullString) bool

Equal 比较是否相等

func (*NullString) GetValue

func (ns *NullString) GetValue() string

GetValue 获取值

func (*NullString) IsNull added in v1.1.5

func (ns *NullString) IsNull() bool

IsNull 是否是Nil

func (NullString) MarshalJSON

func (ns NullString) MarshalJSON() ([]byte, error)

MarshalJSON for NullString

func (NullString) String

func (ns NullString) String() string

func (*NullString) UnmarshalJSON

func (ns *NullString) UnmarshalJSON(b []byte) error

UnmarshalJSON for NullString

type NullTime

type NullTime struct {
	sql.NullTime
}

NullTime is an alias for mysql.NullTime data type

func NewTime

func NewTime(t time.Time) NullTime

func NewTimeNull

func NewTimeNull() NullTime

func (NullTime) Empty

func (nt NullTime) Empty() bool

Empty 判断为nil或0

func (*NullTime) Equal

func (nt *NullTime) Equal(v NullTime) bool

Equal 比较是否相等

func (*NullTime) GetValue

func (nt *NullTime) GetValue() time.Time

GetValue 获取值

func (*NullTime) IsNull added in v1.1.5

func (nt *NullTime) IsNull() bool

IsNull 是否是Nil

func (NullTime) MarshalJSON

func (nt NullTime) MarshalJSON() ([]byte, error)

MarshalJSON for NullTime

func (NullTime) String

func (nt NullTime) String() string

func (*NullTime) TimeStamp added in v1.1.5

func (nt *NullTime) TimeStamp() int64

TimeStamp 获取时间戳, 单位: s

func (*NullTime) UnmarshalJSON

func (nt *NullTime) UnmarshalJSON(b []byte) error

UnmarshalJSON for NullTime

type Pageable

type Pageable struct {
	//TotalCount 总数量
	TotalCount int64 `json:"totalCount"`

	//TotalPage 总页数
	TotalPage int `json:"totalPage"`

	//Page 当前页数
	Page int `json:"page"`

	//PageSize 每页数量
	PageSize int `json:"pageSize"`

	//Rows 记录
	Rows interface{} `json:"rows"`

	//HasNext 是否还有下一页
	HasNext bool `json:"hasNext"`
}

func NewPageable

func NewPageable(rows interface{}, page int, pageSize int, totalCount int64) *Pageable

func (Pageable) String

func (p Pageable) String() string

type RespOpt

type RespOpt func(response *Response)

func RespWithCookies

func RespWithCookies(cookies ...*http.Cookie) RespOpt

RespWithCookies 设置Cookie

func RespWithHeader

func RespWithHeader(key, value string) RespOpt

RespWithHeader 添加header

func RespWithHeaders

func RespWithHeaders(header map[string]string) RespOpt

RespWithHeaders 添加多个header

func RespWithStatus

func RespWithStatus(statusCode int) RespOpt

RespWithStatus 设置状态码

type Response

type Response struct {
	Cookie     []*http.Cookie
	Header     map[string]string
	Result     interface{}
	StatusCode int
}

func NewCustomResp

func NewCustomResp(statusCode int, code int, message string, data interface{}) *Response

NewCustomResp 自定义返回, 配合 CustomResponse 使用

func NewResp

func NewResp(result Result, args ...RespOpt) *Response

func (*Response) AddCookie

func (r *Response) AddCookie(cookies ...*http.Cookie) *Response

AddCookie 添加Cookie

func (*Response) AddHeader

func (r *Response) AddHeader(key, value string) *Response

AddHeader 添加请求头, 如果值为"", 则被视为删除该头部

func (*Response) AddHeaders

func (r *Response) AddHeaders(headers map[string]string) *Response

AddHeaders 添加请求头

func (*Response) SetStatusCode

func (r *Response) SetStatusCode(statusCode int) *Response

SetStatusCode 设置状态码

type Result

type Result struct {
	//Code 业务状态码
	Code int `json:"code" example:"0" swaggertype:"integer"`

	//Message 信息
	Message string `json:"message" example:"Success" swaggertype:"string"`

	//Data 数据
	Data interface{} `json:"data"`
}

func NewErrResp

func NewErrResp(code int, message string) Result

func NewPageResult

func NewPageResult(page int, pageSize int, totalCount int64, rows interface{}, args ...ResultOpt) Result

func NewResult

func NewResult(data interface{}, args ...ResultOpt) Result

func (Result) String

func (r Result) String() string

type ResultOpt

type ResultOpt func(response *Result)

func ResultWithCode

func ResultWithCode(code int) ResultOpt

func ResultWithMessage

func ResultWithMessage(msg string) ResultOpt

type SimpleSet

type SimpleSet struct {
	// contains filtered or unexported fields
}

SimpleSet 非线程安全Set

func NewSimpleSet

func NewSimpleSet() *SimpleSet

func (*SimpleSet) Add

func (set *SimpleSet) Add(v interface{})

Add 添加元素

func (SimpleSet) Common

func (set SimpleSet) Common(s SimpleSet) *SimpleSet

Common 交集

func (SimpleSet) Copy

func (set SimpleSet) Copy() *SimpleSet

Copy copy自身

func (*SimpleSet) Del

func (set *SimpleSet) Del(v interface{})

Del 删除元素

func (SimpleSet) Diff

func (set SimpleSet) Diff(s SimpleSet) *SimpleSet

Diff 差集

func (SimpleSet) Float32Values

func (set SimpleSet) Float32Values() []float32

Float32Values 获取所有的值

func (SimpleSet) Float64Values

func (set SimpleSet) Float64Values() []float64

Float64Values 获取所有的值

func (SimpleSet) Has

func (set SimpleSet) Has(v interface{}) bool

Has 是否已包含

func (SimpleSet) Int32Values

func (set SimpleSet) Int32Values() []int32

Int32Values 获取所有的值

func (SimpleSet) Int64Values

func (set SimpleSet) Int64Values() []int64

Int64Values 获取所有的值

func (SimpleSet) IntValues

func (set SimpleSet) IntValues() []int

IntValues 获取所有的值

func (SimpleSet) NotHas

func (set SimpleSet) NotHas(v interface{}) bool

NotHas 是否不包含

func (SimpleSet) Size

func (set SimpleSet) Size() int

Size 获取长度

func (SimpleSet) StrValues

func (set SimpleSet) StrValues() []string

StrValues 获取所有的值

func (SimpleSet) Union

func (set SimpleSet) Union(s SimpleSet) *SimpleSet

Union 并集

func (*SimpleSet) Update

func (set *SimpleSet) Update(vs ...interface{})

Update 批量添加元素

func (SimpleSet) Values

func (set SimpleSet) Values() []interface{}

Values 获取所有的值

Jump to

Keyboard shortcuts

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