handlers

package
v1.23.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageOK           = "ok"
	MessageNotFound     = "not found"
	MessageError        = "err"
	MessageForbidden    = "forbidden"
	MessageUnauthorized = "unauthorized"
)

Variables

View Source
var (
	NoopPageFilterFunc = func(i int) bool { return true }
	NoopPageSortFunc   = func(i, j int) bool { return false }
)

Functions

func Created

func Created(c *gin.Context, data interface{})

func Forbidden

func Forbidden(c *gin.Context, data interface{})

func NoContent

func NoContent(c *gin.Context, data interface{})

func NotOK

func NotOK(c *gin.Context, err error)

func OK

func OK(c *gin.Context, data interface{})

func Response

func Response(c *gin.Context, code int, msg string, data interface{})

func Unauthorized

func Unauthorized(c *gin.Context, data interface{})

Types

type ClusterIsolatedSwitch

type ClusterIsolatedSwitch struct {
	Isolate   bool `json:"isolate"`
	ClusterID uint `json:"cluster_id" binding:"required"`
}

网络隔离用到的数据结构

type IsolatedSwitch

type IsolatedSwitch struct {
	Isolate bool `json:"isolate"`
}

type PageData

type PageData struct {
	Total       int64
	List        interface{}
	CurrentPage int64
	CurrentSize int64
}

func NewPageData

func NewPageData(list interface{}, page, size int, filterfn PageFilterFunc, sortfn PageSortFunc) PageData

func NewPageDataFromContext

func NewPageDataFromContext(c *gin.Context, fulllist interface{}, pick PageFilterFunc, sortfn PageSortFunc) PageData

func Page

func Page(total int64, list interface{}, page, size int64) *PageData

type PageFilterFunc

type PageFilterFunc func(i int) bool

type PageQueryCond

type PageQueryCond struct {
	Model                  string
	SearchFields           []string
	SortFields             []string
	PreloadFields          []string
	PreloadSensitiveFields map[string]string
	Select                 *QArgs
	Join                   *QArgs
	Where                  []*QArgs
}

type PageSortFunc

type PageSortFunc func(i, j int) bool

type QArgs

type QArgs struct {
	Query interface{}
	Args  []interface{}
}

func Args

func Args(q interface{}, args ...interface{}) *QArgs

type ResponseStruct

type ResponseStruct struct {
	Message   string
	Data      interface{}
	ErrorData interface{}
}

type URLQuery

type URLQuery struct {
	Page    string `form:"page"`
	Size    string `form:"size"`
	Order   string `form:"order"`
	Search  string `form:"search"`
	Preload string `form:"preload"`
	// contains filtered or unexported fields
}

func GetQuery

func GetQuery(c *gin.Context, sortFunc func(interface{}, string)) (*URLQuery, error)

func NewURLQuery

func NewURLQuery(sortfn func(interface{}, string)) *URLQuery

func (*URLQuery) Count

func (q *URLQuery) Count(db *gorm.DB, cond *PageQueryCond) (total int64, err error)

func (*URLQuery) MustPreload

func (q *URLQuery) MustPreload(mustpreloads []string) *URLQuery

func (*URLQuery) PageList

func (q *URLQuery) PageList(db *gorm.DB, cond *PageQueryCond, dest interface{}) (total int64, page, size int64, err error)

func (*URLQuery) PageQuery

func (q *URLQuery) PageQuery(db *gorm.DB, cond *PageQueryCond) *gorm.DB

func (*URLQuery) PageResponse

func (q *URLQuery) PageResponse(data interface{}) interface{}

Jump to

Keyboard shortcuts

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