tag

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: 6 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)

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

func (*API) FindOne

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

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

func (*API) Save

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

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

func (*API) UpdateOne

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

UpdateOneTag godoc @Summary Update one an Tag @Description Update one Tag by ID @Tags tags @Accept json @Produce json @Param id path string true "Tag ID" @Param tag body UpdateDTO true "Update Tag" @Success 200 {object} DTO @Failure 400 @Failure 404 @Failure 500 @Router /tags/{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"`
}

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