handlers

package
v1.23.9 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func BadRequest added in v1.23.8

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

func Created

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

func Error added in v1.23.8

func Error(c *gin.Context, code int, err error)

func Forbidden

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

func NewPageDataFromContext

func NewPageDataFromContext[T any](c *gin.Context, list []T, namefunc func(item T) string, timefunc func(item T) time.Time) response.Page[T]

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 Page

func Page[T any](total int64, list []T, page, size int64) *response.Page[T]

func Response

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

func Unauthorized

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

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 PageQueryCond

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

type QArgs

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

func Args

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

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

Jump to

Keyboard shortcuts

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