Documentation ¶
Index ¶
- type CreateGenreRequest
- type DeleteGenreRequest
- type Genre
- type GetGenreRequest
- type Handler
- type Module
- type MovieGenreRelation
- type Repository
- func (r *Repository) CreateGenre(ctx context.Context, raq *CreateGenreRequest) (*Genre, error)
- func (r *Repository) DeleteGenreByID(ctx context.Context, genreID int) error
- func (r *Repository) GetGenreByID(ctx context.Context, id int) (*Genre, error)
- func (r *Repository) GetGenres(ctx context.Context) ([]*Genre, error)
- func (r *Repository) GetGenresByMovieID(ctx context.Context, movieID int) ([]*Genre, error)
- func (r *Repository) GetRelationsByMovieID(ctx context.Context, movieID int) ([]*MovieGenreRelation, error)
- func (r *Repository) UpdateGenreByID(ctx context.Context, id int, raq *UpdateGenreRequest) error
- type Service
- func (s *Service) CreateGenre(ctx context.Context, raq *CreateGenreRequest) (*Genre, error)
- func (s *Service) DeleteGenreByID(ctx context.Context, id int) error
- func (s *Service) GetGenreByID(ctx context.Context, id int) (*Genre, error)
- func (s *Service) GetGenres(context context.Context) ([]*Genre, error)
- func (s *Service) UpdateGenreByID(ctx context.Context, id int, raq *UpdateGenreRequest) error
- type UpdateGenreRequest
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 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 (*Handler) CreateGenre ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 }
type MovieGenreRelation ¶
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 (*Repository) GetGenres ¶
func (r *Repository) GetGenres(ctx context.Context) ([]*Genre, error)
func (*Repository) GetGenresByMovieID ¶
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