common

package
v0.0.0-...-4b144c9 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APP_CONFIG_ENV_KEY      = "APP_CONFIG_FILE"
	APP_DEVELOPMENT_ENV_KEY = "APP_DEVELOPMENT"
)
View Source
const (
	MAXIMUM_PAGE_SIZE = 64
	DEFAULT_PAGE_SIZE = 10
)

Variables

This section is empty.

Functions

func CalcPageOffset

func CalcPageOffset(pager *Pager) (offset int)

func MapList

func MapList[T, K any](list []*T, mapFunc func(*T) K) []K

func MapListDistinct

func MapListDistinct[T, K comparable](list []*T, mapFunc func(*T) K) []K

func Paginate

func Paginate(sql *gorm.DB, pager *Pager) *gorm.DB

func PaginateWithDefaultOrder

func PaginateWithDefaultOrder(c fiber.Ctx) func(db *gorm.DB) *gorm.DB

gorm paginate support

func ToFieldMap

func ToFieldMap[T any, K comparable](list *[]*T, keyFunc func(*T) K) map[K]*T

func Valid

func Valid(i interface{}) error

func ValidField

func ValidField(i interface{}, tag string) error

func WaitFor

func WaitFor(intervalMillis int, times int, completeFunc func() bool) error

Types

type BaseModel

type BaseModel struct {
	Id        uint           `gorm:"primaryKey" json:"id,omitempty" query:"id" uri:"id"`
	CreatedAt time.Time      `json:"createdAt,omitempty"`
	UpdatedAt *time.Time     `json:"updatedAt,omitempty"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt,omitempty"`
}

type Pager

type Pager struct {
	PageNum  int `json:"pageNum" gorm:"-"`
	PageSize int `json:"pageSize" gorm:"-"`
}

type StructValidator

type StructValidator struct {
	V *validator.Validate
}

func (*StructValidator) Validate

func (v *StructValidator) Validate(i interface{}) error

type TimeRange

type TimeRange struct {
	Begin *time.Time
	End   *time.Time
}

func (*TimeRange) RangeSql

func (tr *TimeRange) RangeSql(sql *gorm.DB, field string) *gorm.DB

Jump to

Keyboard shortcuts

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