stars

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: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateStarRequest

type CreateStarRequest struct {
	FirstName  string     `json:"firstName" validate:"min=1,max=50"`
	MiddleName *string    `json:"middleName,omitempty" validate:"max=50"`
	LastName   string     `json:"lastName" validate:"min=1,max=50"`
	AvatarURL  *string    `json:"avatarUrl,omitempty"`
	BirthDate  time.Time  `json:"birthDate" validate:"nonzero"`
	BirthPlace *string    `json:"birthPlace,omitempty" validate:"max=100"`
	DeathDate  *time.Time `json:"deathDate,omitempty"`
	Bio        *string    `json:"bio,omitempty"`
	IMDbURL    *string    `json:"imdbUrl,omitempty"`
}

func (*CreateStarRequest) ToStar

func (c *CreateStarRequest) ToStar() *Star

type DeleteStarRequest

type DeleteStarRequest struct {
	StarID int `json:"-" param:"starId" validate:"nonzero"`
}

type GetStarRequest

type GetStarRequest struct {
	StarID int `json:"-" param:"starId" validate:"nonzero"`
}

type GetStarsRequest

type GetStarsRequest struct {
	pagination.PaginatedRequest
}

type Handler

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

func NewHandler

func NewHandler(service *Service, paginationConfig *config.PaginationConfig) *Handler

func (*Handler) CreateStar

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

CreateStar godoc @Summary Create star @Description Create star @ID create-star @Tags stars @Param request body CreateStarRequest true "Request, can have optional fields" @Produce json @Success 201 {object} contracts.Star "Start" @Failure 400 {object} apperrors.Error "Invalid request, invalid parameter or missing parameter" @Failure 403 {object} apperrors.Error "Insufficient permissions" @Failure 500 {object} apperrors.Error "Internal server error" @Router /stars [post]

func (*Handler) DeleteStarByID

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

DeleteStarByID godoc @Summary Delete star by id @Description Delete star by id @ID delete-star-by-id @Tags stars @Param starId path int true "Start ID" @Success 200 @Failure 400 {object} apperrors.Error "Invalid request, invalid parameter or missing parameter" @Failure 403 {object} apperrors.Error "Insufficient permissions" @Failure 404 {object} apperrors.Error "Start not found" @Failure 500 {object} apperrors.Error "Internal server error" @Router /stars/{starId} [delete]

func (*Handler) GetStarByID

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

GetStarByID godoc @Summary Get star by id @Description Get star by id @ID get-star-by-id @Tags stars @Param starId path int true "Start ID" @Produce json @Success 200 {object} contracts.Star "Start" @Failure 400 {object} apperrors.Error "Invalid request, invalid parameter or missing parameter" @Failure 404 {object} apperrors.Error "Start not found" @Failure 500 {object} apperrors.Error "Internal server error" @Router /stars/{starId} [get]

func (*Handler) GetStars

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

GetStars godoc @Summary Get stars @Description Get stars @ID get-stars @Tags stars @Produce json @Param request body contracts.PaginatedRequest false "Request, if request body empty, default values will be used" @Success 200 {object} pagination.PaginatedResponse[contracts.Star] "PaginatedResponse of Stars, total number of stars, or nil if none found" @Failure 400 {object} apperrors.Error "Invalid request, invalid parameter or missing parameter" @Failure 500 {object} apperrors.Error "Internal server error" @Router /stars [get]

func (*Handler) UpdateStarByID

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

UpdateStarByID godoc @Summary Update star by id @Description Update star by id @ID update-star-by-id @Tags stars @Param starId path int true "Start ID" @Param request body UpdateStarRequest true "Request, can have optional fields" @Produce json @Success 200 {object} contracts.Star "Start" @Failure 400 {object} apperrors.Error "Invalid request, invalid parameter or missing parameter" @Failure 403 {object} apperrors.Error "Insufficient permissions" @Failure 404 {object} apperrors.Error "Start not found" @Failure 500 {object} apperrors.Error "Internal server error" @Router /stars/{starId} [put]

type Module

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

func NewModule

func NewModule(db *pgxpool.Pool, paginationConfig config.PaginationConfig) *Module

type MovieCredit

type MovieCredit struct {
	Star     Star
	Role     string
	HeroName *string
	Details  string
}

type MovieStarsRelation

type MovieStarsRelation struct {
	MovieID  int
	StarID   int
	HeroName string
	Role     string
	Details  string
	OrderNo  int
}

func (MovieStarsRelation) Key

func (m MovieStarsRelation) Key() any

type Repository

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

func NewRepository

func NewRepository(db *pgxpool.Pool) *Repository

func (*Repository) CreateStar

func (r *Repository) CreateStar(ctx context.Context, req *CreateStarRequest) (*Star, error)

func (*Repository) DeleteStarByID

func (r *Repository) DeleteStarByID(ctx context.Context, starID int) error

func (*Repository) GetRelationsByMovieID

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

func (*Repository) GetStarByID

func (r *Repository) GetStarByID(ctx context.Context, starID int) (*Star, error)

func (*Repository) GetStars

func (r *Repository) GetStars(ctx context.Context) ([]*Star, error)

func (*Repository) GetStarsByMovieID

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

func (*Repository) GetStarsForMovie

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

func (*Repository) GetStarsPaginated

func (r *Repository) GetStarsPaginated(ctx context.Context, offset int, limit int) ([]*Star, int, error)

func (*Repository) UpdateStar

func (r *Repository) UpdateStar(ctx context.Context, starID int, req *UpdateStarRequest) (*Star, error)

type Service

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

func NewService

func NewService(repo *Repository) *Service

func (*Service) CreateStar

func (s *Service) CreateStar(ctx context.Context, req *CreateStarRequest) (*Star, error)

func (*Service) DeleteStarByID

func (s *Service) DeleteStarByID(ctx context.Context, starID int) error

func (*Service) GetStarByID

func (s *Service) GetStarByID(ctx context.Context, starID int) (*Star, error)

func (*Service) GetStars

func (s *Service) GetStars(ctx context.Context) ([]*Star, error)

func (*Service) GetStarsPaginated

func (s *Service) GetStarsPaginated(ctx context.Context, offset int, limit int) ([]*Star, int, error)

func (*Service) UpdateStar

func (s *Service) UpdateStar(ctx context.Context, starID int, req *UpdateStarRequest) (*Star, error)

type Star

type Star struct {
	ID         int        `json:"id"`
	FirstName  string     `json:"firstName"`
	MiddleName *string    `json:"middleName,omitempty"`
	LastName   string     `json:"lastName"`
	AvatarURL  *string    `json:"avatarUrl,omitempty"`
	BirthDate  time.Time  `json:"birthDate"`
	BirthPlace *string    `json:"birthPlace,omitempty"`
	DeathDate  *time.Time `json:"deathDate,omitempty"`
	Bio        *string    `json:"bio,omitempty"`
	IMDbURL    *string    `json:"imdbUrl,omitempty"`
	CreatedAt  time.Time  `json:"createdAt"`
	DeletedAt  *time.Time `json:"deletedAt,omitempty"`
}

func NewStar

func NewStar() *Star

func (Star) ConvertToV2

func (s Star) ConvertToV2() *StarV2

func (Star) Normalize

func (s Star) Normalize() *Star

type StarV2

type StarV2 struct {
	ID         int        `json:"id"`
	FirstName  string     `json:"firstName"`
	MiddleName *string    `json:"middleName,omitempty"`
	LastName   string     `json:"lastName"`
	AvatarURL  *string    `json:"avatarUrl,omitempty"`
	CreatedAt  time.Time  `json:"createdAt"`
	DeletedAt  *time.Time `json:"deletedAt,omitempty"`
}

type UpdateStarRequest

type UpdateStarRequest struct {
	StarID     int        `json:"-" param:"starId" validate:"nonzero"`
	FirstName  *string    `json:"firstName,omitempty" validate:"max=50"`
	MiddleName *string    `json:"middleName,omitempty" validate:"max=50"`
	LastName   *string    `json:"lastName,omitempty" validate:"max=50"`
	AvatarURL  *string    `json:"avatarUrl,omitempty"`
	BirthDate  *time.Time `json:"birthDate,omitempty"`
	BirthPlace *string    `json:"birthPlace,omitempty" validate:"max=100"`
	DeathDate  *time.Time `json:"deathDate,omitempty"`
	Bio        *string    `json:"bio,omitempty"`
	IMDbURL    *string    `json:"imdbUrl,omitempty"`
}

Jump to

Keyboard shortcuts

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