crud

package
v0.0.0-...-3db7ccc Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorUnknown             = 0
	ErrorNotFound            = 1
	ErrorInvalidRequest      = 2
	ErrorAuthNoSessionCookie = 3
	ErrorAuthServiceError    = 4
	ErrorAuthNoPhone         = 5
	ErrorAuthWrongPhone      = 6
	ErrorTelegramSendError   = 7
	ErrorTelegramNoBotToken  = 8
	ErrorTelegramNoChatID    = 9
	ErrorTooManyResult       = 10
	ErrorShortRequest        = 11
	ErrorEmployeeIsNull      = 12
	ErrorTimeout             = 14
)

Variables

This section is empty.

Functions

func GetIntPathParam

func GetIntPathParam[T constraints.Integer](ctx *gin.Context, key string) (ret T, err error)

func GetIntPathParamFiber

func GetIntPathParamFiber[T constraints.Integer](ctx *fiber.Ctx, key string) (ret T, err error)

func GetIntQueryParam

func GetIntQueryParam[T constraints.Integer](ctx *gin.Context, key string) (ret T, err error)

func GetRange

func GetRange(ctx *gin.Context, limitDef, offsetDef int64) rangeConf

func LoadGormDB

func LoadGormDB() *gorm.DB

func NewErrResponseRegistry

func NewErrResponseRegistry(err ...error) errRepo

NewErrResponseRegistry ...

func NewListResponse

func NewListResponse[T any](status int64, rangeInfo rangeConf, total int64, body []T) listResponse[T]

NewListResponse ...

func NewResponse

func NewResponse[T Model](status int64, body T) response[T]

NewResponse ...

func NewResponseRegistry

func NewResponseRegistry[T Model]() respOk[T]

NewResponseRegistry ...

Types

type CRud

type CRud[T Model] struct {
	ReadOneLogic   LogicFunc
	CreateOneLogic LogicFunc
	ReadManyLogic  LogicFunc
	UpdateOneLogic LogicFunc
	DeleteOneLogic LogicFunc
	// contains filtered or unexported fields
}

func Crud

func Crud[T Model](router gin.IRouter, childCrud ICrud, crudOpt ...CrudOpt) CRud[T]

func (*CRud[T]) CrudRouter

func (c *CRud[T]) CrudRouter(router gin.IRouter)

func (*CRud[T]) Migrate

func (c *CRud[T]) Migrate(addit ...any) error

type CrudOpt

type CrudOpt struct {
}

type ErrorResponser

type ErrorResponser interface {
	Match(error) errorResponse
}

ErrorResponser ...

type GormModel

type GormModel struct {
	ID        uint           `gorm:"primarykey" json:"id,omitempty"`
	CreatedAt time.Time      `json:"created_at,omitempty"`
	UpdatedAt time.Time      `json:"updated_at,omitempty"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`
}

type ICrud

type ICrud interface {
}

type LogicFunc

type LogicFunc func(ctx *gin.Context, db *gorm.DB) *gorm.DB

type Model

type Model interface {
	Identity() (fieldName string, value any)
}

type ModelBase

type ModelBase GormModel

func (ModelBase) Identity

func (m ModelBase) Identity() (fieldName string, value any)

func (ModelBase) UpdateForID

func (m ModelBase) UpdateForID(db, id any)

type Responser

type Responser[T Model] interface {
	ResponseOne(code int64, body T) response[T]
	ResponseMany(code int64, rangeInfo rangeConf, total int64, body []T) listResponse[T]
}

Responser ...

Jump to

Keyboard shortcuts

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