common

package
v0.0.0-...-f98703c Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxPageSize     = 2000
	DefaultPageSize = 20
	DefaultPage     = 1
)
View Source
const (
	BINARY = "BINARY(16)"
)

Variables

This section is empty.

Functions

func Reply

func Reply(ctx *gin.Context, err error, data ...any)

func ReplyErr

func ReplyErr(ctx *gin.Context, err error, msg ...string)

func ReplyOk

func ReplyOk(ctx *gin.Context, data ...any)

禁止 data 直接返回数组,不方便接口拓展

func ReplyWSErr

func ReplyWSErr(s *melody.Session, action string, msgUUID uuid.UUID, err error) error

func ReplyWSOk

func ReplyWSOk(s *melody.Session, action string, msgUUID uuid.UUID, data ...any) error

Types

type BinUUID

type BinUUID datatypes.BinUUID

func (BinUUID) Bytes

func (u BinUUID) Bytes() []byte

String returns the string form of the UUID.

func (BinUUID) Equals

func (u BinUUID) Equals(other BinUUID) bool

Equals returns true if bytes form of BinUUID matches other, false otherwise.

func (BinUUID) GormDBDataType

func (BinUUID) GormDBDataType(db *gorm.DB, _ *schema.Field) string

GormDBDataType gorm db data type.

func (BinUUID) GormDataType

func (BinUUID) GormDataType() string

func (BinUUID) IsEmpty

func (u BinUUID) IsEmpty() bool

IsEmpty returns true if BinUUID is nil uuid or of zero length, false otherwise.

func (*BinUUID) IsEmptyPtr

func (u *BinUUID) IsEmptyPtr() bool

IsEmptyPtr returns true if caller BinUUID ptr is nil or it's value is empty.

func (BinUUID) IsNil

func (u BinUUID) IsNil() bool

IsNil returns true if the BinUUID is nil uuid (all zeroes), false otherwise.

func (*BinUUID) IsNilPtr

func (u *BinUUID) IsNilPtr() bool

IsNilPtr returns true if caller BinUUID ptr is nil, false otherwise.

func (BinUUID) Length

func (u BinUUID) Length() int

Length returns the number of characters in string form of UUID.

func (BinUUID) LengthBytes

func (u BinUUID) LengthBytes() int

Length returns the number of characters in string form of UUID.

func (BinUUID) MarshalJSON

func (u BinUUID) MarshalJSON() ([]byte, error)

func (*BinUUID) Scan

func (u *BinUUID) Scan(value interface{}) error

Scan is the scanner function for this datatype.

func (BinUUID) String

func (u BinUUID) String() string

String returns the string form of the UUID.

func (*BinUUID) UnmarshalJSON

func (u *BinUUID) UnmarshalJSON(data []byte) error

func (BinUUID) Value

func (u BinUUID) Value() (driver.Value, error)

Value is the valuer function for this datatype.

type Error

type Error struct {
	Msg  string   `json:"msg"`
	Info []string `json:"info,omitempty"`
}

type PageMoreResp

type PageMoreResp[T any] struct {
	HasMore  bool `json:"has_more"`
	Page     int  `json:"page"`
	PageSize int  `json:"page_size"`
	Data     T    `json:"data"`
}

type PageReq

type PageReq struct {
	Page     int `json:"page" form:"page" uri:"page"`
	PageSize int `json:"page_size" form:"page_size" uri:"page_size"`
}

func (*PageReq) AddPage

func (p *PageReq) AddPage(count int)

func (*PageReq) Normalize

func (p *PageReq) Normalize()

Normalize 规范化分页参数,设置默认值和上限 应该在所有使用 PageReq 的地方调用此方法

func (*PageReq) Offest

func (p *PageReq) Offest() int

type PageReqT

type PageReqT[T any] struct {
	PageReq
	Data T `json:"data"`
}

type PageResp

type PageResp[T any] struct {
	Total    int64 `json:"total"`
	Page     int   `json:"page"`
	PageSize int   `json:"page_size"`
	Data     T     `json:"data"`
}

type Resp

type Resp struct {
	Code      code.ErrCode `json:"code"`
	Error     *Error       `json:"error,omitempty"`
	Data      any          `json:"data,omitempty"`
	Timestamp int64        `json:"timestamp,omitempty"`
}

type RespT

type RespT[T any] struct {
	Code      code.ErrCode `json:"code"`
	Error     *Error       `json:"error,omitempty"`
	Data      T            `json:"data,omitempty"`
	Timestamp int64        `json:"timestamp,omitempty"`
}

type WSData

type WSData[T any] struct {
	WsMsgType
	Data T `json:"data,omitempty"`
}

type WsMsgType

type WsMsgType struct {
	Action  string    `json:"action"`
	MsgUUID uuid.UUID `json:"msg_uuid"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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