service

package
v0.0.0-...-73db963 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entity

type Entity interface {
	TableName() string
}

type IRepository

type IRepository interface {
	FindOne(ctx *gin.Context, entity Entity, id int, dbTransaction *gorm.DB) error
	FindAll(ctx *gin.Context, entities any, options *OptionQuery, dbTransaction *gorm.DB) (*utils.Pagination, error)
	Create(ctx *gin.Context, form Entity, dbTransaction *gorm.DB) (Entity, error)
	Update(ctx *gin.Context, id int, form Entity, dbTransaction *gorm.DB) (Entity, error)
	Delete(ctx *gin.Context, id int, dbTransaction *gorm.DB) error
	CustomQuery(ctx *gin.Context) *gorm.DB
}

func NewRepository

func NewRepository(entity Entity, db *gorm.DB) IRepository

type OptionQuery

type OptionQuery struct {
	Page   int
	Limit  int
	Filter map[string]any
	Search []string
	Order  string
}

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

func (*Repository) Create

func (r *Repository) Create(ctx *gin.Context, form Entity, dbTransaction *gorm.DB) (Entity, error)

func (*Repository) CustomQuery

func (r *Repository) CustomQuery(ctx *gin.Context) *gorm.DB

func (*Repository) Delete

func (r *Repository) Delete(ctx *gin.Context, id int, dbTransaction *gorm.DB) error

func (*Repository) FindAll

func (r *Repository) FindAll(ctx *gin.Context, entities any, options *OptionQuery, dbTransaction *gorm.DB) (*utils.Pagination, error)

func (*Repository) FindOne

func (r *Repository) FindOne(ctx *gin.Context, entity Entity, id int, dbTransaction *gorm.DB) error

func (*Repository) Update

func (r *Repository) Update(ctx *gin.Context, id int, form Entity, dbTransaction *gorm.DB) (Entity, error)

type Services

type Services struct {
	UserService  IRepository
	TokenService IRepository
}

func Init

func Init(db *gorm.DB) *Services

Jump to

Keyboard shortcuts

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