genres

package
v0.0.0-...-63997f1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateGenreRequest

type CreateGenreRequest struct {
	Name string `json:"name" validate:"min=3,max=32"`
}

type DeleteGenreRequest

type DeleteGenreRequest struct {
	GenreID int `json:"-" param:"genreId" validate:"nonzero"`
}

type Genre

type Genre struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

type GetGenreRequest

type GetGenreRequest struct {
	GenreID int `json:"-" param:"genreId" validate:"nonzero"`
}

type Handler

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

func NewHandler

func NewHandler(service *Service) *Handler

func (*Handler) CreateGenre

func (h *Handler) CreateGenre(c echo.Context) error

CreateGenre @Summary Create new genre @Description Create new genre @ID create-genre @Tags genres @Param genre body CreateGenreRequest true "Genre" @Produce json @Success 201 {object} Genre "Genre" @Failure 400 {object} apperrors.Error "Invalid parameter or missing parameter" @Failure 403 {object} apperrors.Error "Insufficient permissions" @Failure 409 {object} apperrors.Error "Genre with that name already exists" @Failure 500 {object} apperrors.Error "Internal server error" @Router /genres [post]

func (*Handler) DeleteGenreByID

func (h *Handler) DeleteGenreByID(c echo.Context) error

DeleteGenreByID @Summary Delete genre by id @Description Delete genre by id @ID delete-genre-by-id @Tags genres @Param genreId path int true "Genre ID" @Produce json @Success 200 "Genre deleted (softly deleting)" @Failure 400 {object} apperrors.Error "Invalid genre id, invalid parameter or missing parameter" @Failure 403 {object} apperrors.Error "Insufficient permissions" @Failure 404 {object} apperrors.Error "Genre not found" @Failure 500 {object} apperrors.Error "Internal server error" @Router /genres/{genreId} [delete]

func (*Handler) GetGenreByID

func (h *Handler) GetGenreByID(c echo.Context) error

GetGenreByID @Summary Get genre by id @Description Get genre by id @ID get-genre-by-id @Tags genres @Param genreId path int true "Genre ID" @Produce json @Success 200 {object} Genre "Genre" @Failure 400 {object} apperrors.Error "Invalid genre id, invalid parameter or missing parameter" @Failure 404 {object} apperrors.Error "Genre not found" @Failure 500 {object} apperrors.Error "Internal server error" @Router /genres/{genreId} [get]

func (*Handler) GetGenres

func (h *Handler) GetGenres(c echo.Context) error

GetGenres @Summary Get all genres @Description Get all genres @ID get-genres @Tags genres @Produce json @Success 200 {array} Genre "Genres, or nil if none found" @Failure 500 {object} apperrors.Error "Internal server error" @Router /genres [get]

func (*Handler) UpdateGenreByID

func (h *Handler) UpdateGenreByID(c echo.Context) error

UpdateGenreByID @Summary Update genre by id @Description Update genre by id @ID update-genre-by-id @Tags genres @Param genreId path int true "Genre ID" @Param genre body UpdateGenreRequest true "Genre" @Produce json @Success 200 "Genre updated" @Failure 400 {object} apperrors.Error "Invalid genre id, invalid parameter or missing parameter" @Failure 403 {object} apperrors.Error "Insufficient permissions" @Failure 404 {object} apperrors.Error "Genre not found" @Failure 500 {object} apperrors.Error "Internal server error" @Router /genres/{genreId} [put]

type Module

type Module struct {
	Handler    *Handler
	Service    *Service
	Repository *Repository
}

func NewModule

func NewModule(db *pgxpool.Pool) *Module

type MovieGenreRelation

type MovieGenreRelation struct {
	MovieID int
	GenreID int
	OrderNo int
}

func (MovieGenreRelation) Key

func (m MovieGenreRelation) Key() any

type Repository

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

func NewRepository

func NewRepository(db *pgxpool.Pool) *Repository

func (*Repository) CreateGenre

func (r *Repository) CreateGenre(ctx context.Context, raq *CreateGenreRequest) (*Genre, error)

func (*Repository) DeleteGenreByID

func (r *Repository) DeleteGenreByID(ctx context.Context, genreID int) error

func (*Repository) GetGenreByID

func (r *Repository) GetGenreByID(ctx context.Context, id int) (*Genre, error)

func (*Repository) GetGenres

func (r *Repository) GetGenres(ctx context.Context) ([]*Genre, error)

func (*Repository) GetGenresByMovieID

func (r *Repository) GetGenresByMovieID(ctx context.Context, movieID int) ([]*Genre, error)

func (*Repository) GetRelationsByMovieID

func (r *Repository) GetRelationsByMovieID(ctx context.Context, movieID int) ([]*MovieGenreRelation, error)

func (*Repository) UpdateGenreByID

func (r *Repository) UpdateGenreByID(ctx context.Context, id int, raq *UpdateGenreRequest) error

type Service

type Service struct {
	Repository *Repository
}

func NewService

func NewService(repo *Repository) *Service

func (*Service) CreateGenre

func (s *Service) CreateGenre(ctx context.Context, raq *CreateGenreRequest) (*Genre, error)

func (*Service) DeleteGenreByID

func (s *Service) DeleteGenreByID(ctx context.Context, id int) error

func (*Service) GetGenreByID

func (s *Service) GetGenreByID(ctx context.Context, id int) (*Genre, error)

func (*Service) GetGenres

func (s *Service) GetGenres(context context.Context) ([]*Genre, error)

func (*Service) UpdateGenreByID

func (s *Service) UpdateGenreByID(ctx context.Context, id int, raq *UpdateGenreRequest) error

type UpdateGenreRequest

type UpdateGenreRequest struct {
	GenreID int    `json:"-" param:"genreId" validate:"nonzero"`
	Name    string `json:"name" validate:"min=3,max=32"`
}

Jump to

Keyboard shortcuts

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