car

package
v0.0.0-...-08ef0fc Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeApi

func ServeApi(rg *gin.RouterGroup, authHandler gin.HandlerFunc, usecase *Usecase)

func ServeWeb

func ServeWeb(rg *gin.RouterGroup, usecase *Usecase)

Types

type Car

type Car struct {
	entity.Car
}

type CarCreate

type CarCreate struct {
	Brand string `json:"brand" form:"brand"`
	Color string `json:"color" form:"color"`
	Seats uint8  `json:"seats" form:"seats"`
}

type CarPatch

type CarPatch struct {
	Brand *string `json:"brand" form:"brand"`
	Color *string `json:"color" form:"color"`
	Seats *uint8  `json:"seats" form:"seats"`
}

type CarUpdate

type CarUpdate struct {
	ID        uint    `json:"id" form:"id"`
	Brand     string  `json:"brand" form:"brand"`
	Color     string  `json:"color" form:"color"`
	Seats     uint8   `json:"seats" form:"seats"`
	CreatedAt string  `json:"created_at" form:"created_at"`
	UpdatedAt string  `json:"updated_at" form:"updated_at"`
	DeletedAt *string `json:"deleted_at" form:"deleted_at"`
}

type Repo

type Repo interface {
	Get(id uint) (entity.Car, error)
	Create(model *entity.Car) error
	Update(model *entity.Car, columns ...string) error
	Save(model *entity.Car) error
	Delete(model *entity.Car) error
	Count() (int, error)
	Query(offset, limit int) ([]entity.Car, error)
}

func NewDBRepo

func NewDBRepo(db *gorm.DB) Repo

type Usecase

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

func NewUsecase

func NewUsecase(repo Repo) *Usecase

func (*Usecase) Count

func (u *Usecase) Count() (int, error)

func (*Usecase) Create

func (u *Usecase) Create(model *entity.Car) error

func (*Usecase) Delete

func (u *Usecase) Delete(id uint) (entity.Car, error)

func (*Usecase) Get

func (u *Usecase) Get(id uint) (entity.Car, error)

func (*Usecase) Query

func (u *Usecase) Query(offset, limit int) ([]entity.Car, error)

func (*Usecase) Save

func (u *Usecase) Save(model *entity.Car) error

func (*Usecase) Update

func (u *Usecase) Update(model *entity.Car, attrs ...string) error

Jump to

Keyboard shortcuts

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