collector

package
v0.0.0-...-5dc8f6f Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

func NewApi

func NewApi(service *Service, l *slog.Logger) *API

func (*API) Find

func (a *API) Find(c *gin.Context)

FilterCollectors godoc @Summary Filter Collectors @Description Filter Collectors by query paramenters @Tags collectors @Accept json @Produce json @Param name query string false "Collector name" @Param start query string false "Collector createdAt start date" @Param end query string false "Collector createdAt end date" @Success 200 {object} []DTO @Failure 400 @Failure 500 @Router /collectors [get]

func (*API) FindOne

func (a *API) FindOne(c *gin.Context)

FindOneCollector godoc @Summary Find one an Collector @Description Find one Collector by ID @Tags collectors @Accept json @Produce json @Param id path string true "Collector ID" @Success 200 {object} DTO @Failure 400 @Failure 404 @Failure 500 @Router /collectors/{id} [get]

func (*API) Save

func (a *API) Save(c *gin.Context)

SaveCollector godoc @Summary Save Collector @Description Save a collector by giver form @Tags collectors @Accept json @Produce json @Param collector body CreateDTO true "Add Collector" @Success 201 {object} DTO @Failure 500 @Router /collectors [post]

func (*API) UpdateOne

func (a *API) UpdateOne(c *gin.Context)

UpdateOneCollector godoc @Summary Update one an Collector @Description Update one Collector by ID @Tags collectors @Accept json @Produce json @Param id path string true "Collector ID" @Param collector body UpdateDTO true "Update Collector" @Success 200 {object} DTO @Failure 400 @Failure 404 @Failure 500 @Router /collectors/{id} [post]

type CreateDTO

type CreateDTO struct {
	Name string `json:"name"`
}

type DTO

type DTO struct {
	ID        string    `json:"id"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
	Name      string    `json:"name"`
}

type FindOptions

type FindOptions struct {
	Name  string
	Start string
	End   string
}

type Model

type Model struct {
	gorm.Model
	ID        uuid.UUID `gorm:"type:uuid;default:gen_random_uuid()"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt           `gorm:"index"`
	Name      string                   `gorm:"uniqueIndex"`
	Expenses  []shared.ExpenseRefModel `gorm:"foreignKey:CollectorID;references:ID"`
}

func (Model) TableName

func (Model) TableName() string

func (*Model) ToDTO

func (m *Model) ToDTO() *DTO

type Models

type Models []*Model

func (*Models) ToDTO

func (m *Models) ToDTO() []*DTO

type Repository

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

func NewRepository

func NewRepository(db *gorm.DB, l *slog.Logger) *Repository

func (*Repository) All

func (r *Repository) All() ([]*Model, error)

func (*Repository) DeleteOne

func (r *Repository) DeleteOne(id string) error

func (*Repository) Find

func (r *Repository) Find(options FindOptions) ([]*Model, error)

func (*Repository) FindOne

func (r *Repository) FindOne(id string) (*Model, error)

func (*Repository) Save

func (r *Repository) Save(user *CreateDTO) (*Model, error)

func (*Repository) UpdateOne

func (r *Repository) UpdateOne(id string, user *UpdateDTO) error

type Router

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

func NewRouter

func NewRouter(db *gorm.DB, rg *gin.RouterGroup, l *slog.Logger) *Router

func (*Router) Route

func (r *Router) Route()

type Service

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

func NewService

func NewService(repository *Repository, l *slog.Logger) *Service

func (*Service) All

func (s *Service) All() ([]*DTO, error)

func (*Service) DeleteOne

func (s *Service) DeleteOne(id string) error

func (*Service) Find

func (s *Service) Find(options FindOptions) ([]*DTO, error)

func (*Service) FindOne

func (s *Service) FindOne(id string) (*DTO, error)

func (*Service) Save

func (s *Service) Save(createDTO *CreateDTO) (*DTO, error)

func (*Service) UpdateOne

func (s *Service) UpdateOne(id string, updateDTO *UpdateDTO) (*DTO, error)

type Tabler

type Tabler interface {
	TableName() string
}

type UpdateDTO

type UpdateDTO struct {
	CreateDTO
}

Jump to

Keyboard shortcuts

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