base

package
v0.0.0-...-edfbc91 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CtxUserNameKey = "userName"
	CtxUserIDKey   = "userID"
)

Functions

This section is empty.

Types

type DefaultListReq

type DefaultListReq struct {
	PaginationReq
	RequestMeta
	SQLSearchReq
	SQLSortReq
}

func (*DefaultListReq) Modify

func (c *DefaultListReq) Modify(ctx *gin.Context)

type DefaultResp

type DefaultResp struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Result  interface{} `json:"result"`
}

func (*DefaultResp) IsNull

func (c *DefaultResp) IsNull() bool

func (*DefaultResp) SetAccepted

func (c *DefaultResp) SetAccepted()

func (*DefaultResp) SetBadRequest

func (c *DefaultResp) SetBadRequest(message string)

func (*DefaultResp) SetCodeAndMsg

func (c *DefaultResp) SetCodeAndMsg(code int, message string)

func (*DefaultResp) SetNotFound

func (c *DefaultResp) SetNotFound(message string)

func (*DefaultResp) SetServerError

func (c *DefaultResp) SetServerError(message string)

func (*DefaultResp) SetSuccess

func (c *DefaultResp) SetSuccess()

type PaginationMeta

type PaginationMeta struct {
	Page     uint32 `json:"page,omitempty"`
	PageSize uint32 `json:"page_size,omitempty"`
	Total    uint32 `json:"total,omitempty"`
}

type PaginationReq

type PaginationReq struct {
	Page     uint32 `json:"page" form:"page"`
	PageSize uint32 `json:"page_size" form:"page_size"`
}

func (*PaginationReq) Limit

func (c *PaginationReq) Limit() int64

func (*PaginationReq) Modify

func (c *PaginationReq) Modify(ctx *gin.Context)

func (*PaginationReq) Offset

func (c *PaginationReq) Offset() int64

type PaginationResult

type PaginationResult struct {
	Items      interface{}    `json:"items"`
	Pagination PaginationMeta `json:"pagination,omitempty"`
}

type RequestMeta

type RequestMeta struct {
	RequestUserID   string          `json:"-" form:"-" uri:"-"` // 请求用户ID
	RequestUserName string          `json:"-" form:"-" uri:"-"` // 请求用户名
	Ctx             context.Context `json:"-" form:"-" uri:"-"` // 上下文
	GinCtx          *gin.Context    `json:"-" form:"-" uri:"-"` // gin上下文
}

func (*RequestMeta) GetCtx

func (b *RequestMeta) GetCtx() context.Context

func (*RequestMeta) Modify

func (b *RequestMeta) Modify(c *gin.Context)

type Response

type Response interface {
	SetSuccess()
	SetBadRequest(message string)
	SetNotFound(message string)
	SetAccepted()
	SetServerError(message string)
	SetCodeAndMsg(code int, message string)
	IsNull() bool
}

type ResponseImmediately

type ResponseImmediately struct {
}

func (ResponseImmediately) IsNull

func (r ResponseImmediately) IsNull() bool

func (ResponseImmediately) SetAccepted

func (r ResponseImmediately) SetAccepted()

func (ResponseImmediately) SetBadRequest

func (r ResponseImmediately) SetBadRequest(message string)

func (ResponseImmediately) SetCodeAndMsg

func (r ResponseImmediately) SetCodeAndMsg(code int, message string)

func (ResponseImmediately) SetNotFound

func (r ResponseImmediately) SetNotFound(message string)

func (ResponseImmediately) SetServerError

func (r ResponseImmediately) SetServerError(message string)

func (ResponseImmediately) SetSuccess

func (r ResponseImmediately) SetSuccess()

type SQLSearchReq

type SQLSearchReq struct {
	Q string `json:"q" form:"q"`
}

func (*SQLSearchReq) AddQ

func (c *SQLSearchReq) AddQ(k, v string)

func (*SQLSearchReq) QToMap

func (c *SQLSearchReq) QToMap() map[string]interface{}

func (*SQLSearchReq) SearchFilter

func (c *SQLSearchReq) SearchFilter(fuzzy bool) interface{}

type SQLSortReq

type SQLSortReq struct {
	Sort string `json:"sort" form:"sort"`
}

func (*SQLSortReq) SortFilter

func (c *SQLSortReq) SortFilter() interface{}

type SearchReqInterface

type SearchReqInterface interface {
	SearchFilter(fuzzy bool) interface{}
}

type SortReqInterface

type SortReqInterface interface {
	SortFilter() interface{}
}

type WSearchReq

type WSearchReq struct {
	W string `json:"w" form:"w"`
}

func (*WSearchReq) WordFilter

func (c *WSearchReq) WordFilter(fuzzy bool, fields ...string) interface{}

type WordReqInterface

type WordReqInterface interface {
	WordFilter(fuzzy bool, fields ...string) interface{}
}

Jump to

Keyboard shortcuts

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