curd

package
v4.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApiClear

func ApiClear[T any]() gin.HandlerFunc

func ApiCount

func ApiCount[T any]() gin.HandlerFunc

func ApiCreate

func ApiCreate[T any]() gin.HandlerFunc

func ApiCreateHook

func ApiCreateHook[T any](before, after func(m *T) error) gin.HandlerFunc

func ApiDelete

func ApiDelete[T any]() gin.HandlerFunc

func ApiDeleteHook

func ApiDeleteHook[T any](before, after func(m *T) error) gin.HandlerFunc

func ApiDisable

func ApiDisable[T any](disable bool) gin.HandlerFunc

func ApiDisableHook

func ApiDisableHook[T any](disable bool, before, after func(id any) error) gin.HandlerFunc

func ApiGet

func ApiGet[T any](fields ...string) gin.HandlerFunc

func ApiGetHook

func ApiGetHook[T any](after func(m *T) error, fields ...string) gin.HandlerFunc

func ApiGetMapHook

func ApiGetMapHook[T any](after func(m map[string]any) error, fields ...string) gin.HandlerFunc

func ApiList

func ApiList[T any](fields ...string) gin.HandlerFunc

func ApiListById added in v4.0.16

func ApiListById[T any](field string, fields ...string) gin.HandlerFunc

func ApiListByIdWith added in v4.0.16

func ApiListByIdWith[T any](field string, withs []*With, fields ...string) gin.HandlerFunc

func ApiListHook

func ApiListHook[T any](after func(datum []*T) error, fields ...string) gin.HandlerFunc

func ApiListMapHook

func ApiListMapHook[T any](after func(datum []map[string]any) error, fields ...string) gin.HandlerFunc

func ApiListWith added in v4.0.16

func ApiListWith[T any](withs []*With, fields ...string) gin.HandlerFunc

func ApiSearch

func ApiSearch[T any](fields ...string) gin.HandlerFunc

func ApiSearchHook

func ApiSearchHook[T any](after func(datum []*T) error, fields ...string) gin.HandlerFunc

func ApiSearchJoinWith added in v4.0.15

func ApiSearchJoinWith[T any](joins []*Join, withs []*With, fields ...string) gin.HandlerFunc

func ApiSearchMapHook

func ApiSearchMapHook[T any](after func(datum []map[string]any) error, fields ...string) gin.HandlerFunc

func ApiSearchWith

func ApiSearchWith[T any](withs []*With, fields ...string) gin.HandlerFunc

func ApiSearchWithHook

func ApiSearchWithHook[T any](join []*With, after func(datum []*T) error, fields ...string) gin.HandlerFunc

func ApiUpdate

func ApiUpdate[T any](fields ...string) gin.HandlerFunc

func ApiUpdateHook

func ApiUpdateHook[T any](before, after func(m *T) error, fields ...string) gin.HandlerFunc

func Error

func Error(ctx *gin.Context, err error)

func Fail

func Fail(ctx *gin.Context, err string)

func GenerateID added in v4.0.10

func GenerateID[T any]() func(data *T) error

func GenerateKSUID

func GenerateKSUID[T any]() func(data *T) error

func GenerateUuidKey

func GenerateUuidKey(data interface{}) error

func GenerateXID added in v4.0.10

func GenerateXID[T any]() func(data *T) error

func List

func List(ctx *gin.Context, data interface{}, total int64)

func Noop

func Noop(ctx *gin.Context)

func OK

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

func ParseParamId

func ParseParamId(ctx *gin.Context)

func ParseParamStringId

func ParseParamStringId(ctx *gin.Context)

Types

type Join

type Join struct {
	Table        string //表名
	LocaleField  string //主表字段
	ForeignField string //附表字段(外键)
	Field        string //附件查询字段
	Arg          string //filter 参数
}

type ParamId

type ParamId struct {
	Id int64 `uri:"id"`
}

type ParamList

type ParamList struct {
	Skip  int `form:"skip" json:"skip"`
	Limit int `form:"limit" json:"limit"`
}

func (*ParamList) BindQuery added in v4.0.12

func (body *ParamList) BindQuery(ctx *gin.Context) error

func (*ParamList) ToQuery

func (body *ParamList) ToQuery() *xorm.Session

type ParamSearch

type ParamSearch struct {
	Skip     int                    `form:"skip" json:"skip"`
	Limit    int                    `form:"limit" json:"limit"`
	Sort     map[string]int         `form:"sort" json:"sort"`
	Filters  map[string]interface{} `form:"filter" json:"filter"`
	Keywords map[string]string      `form:"keyword" json:"keyword"`
}

func (*ParamSearch) ToJoinQuery

func (body *ParamSearch) ToJoinQuery(table string) *xorm.Session

func (*ParamSearch) ToQuery

func (body *ParamSearch) ToQuery() *xorm.Session

type ParamStringId

type ParamStringId struct {
	Id string `uri:"id"`
}

type ReplyData

type ReplyData[T any] struct {
	Data  T      `json:"data"`
	Error string `json:"error,omitempty"`
}

type ReplyList

type ReplyList[T any] struct {
	Data  []T    `json:"data"`
	Total int64  `json:"total"`
	Error string `json:"error,omitempty"`
}

type With added in v4.0.15

type With struct {
	Table        string //表名
	LocaleField  string //主表字段
	ForeignField string //附表字段(外键)
	Field        string //取字段 TODO 可以改为数组
	As           string //赋值
}

Jump to

Keyboard shortcuts

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