Documentation ¶
Index ¶
- type CreateStarRequest
- type DeleteStarRequest
- type GetStarRequest
- type GetStarsRequest
- type Handler
- type Module
- type MovieCredit
- type MovieStarsRelation
- type Repository
- func (r *Repository) CreateStar(ctx context.Context, req *CreateStarRequest) (*Star, error)
- func (r *Repository) DeleteStarByID(ctx context.Context, starID int) error
- func (r *Repository) GetRelationsByMovieID(ctx context.Context, movieID int) ([]*MovieStarsRelation, error)
- func (r *Repository) GetStarByID(ctx context.Context, starID int) (*Star, error)
- func (r *Repository) GetStars(ctx context.Context) ([]*Star, error)
- func (r *Repository) GetStarsByMovieID(ctx context.Context, movieID int) ([]*MovieCredit, error)
- func (r *Repository) GetStarsForMovie(ctx context.Context, movieID int) ([]*Star, error)
- func (r *Repository) GetStarsPaginated(ctx context.Context, offset int, limit int) ([]*Star, int, error)
- func (r *Repository) UpdateStar(ctx context.Context, starID int, req *UpdateStarRequest) (*Star, error)
- type Service
- func (s *Service) CreateStar(ctx context.Context, req *CreateStarRequest) (*Star, error)
- func (s *Service) DeleteStarByID(ctx context.Context, starID int) error
- func (s *Service) GetStarByID(ctx context.Context, starID int) (*Star, error)
- func (s *Service) GetStars(ctx context.Context) ([]*Star, error)
- func (s *Service) GetStarsPaginated(ctx context.Context, offset int, limit int) ([]*Star, int, error)
- func (s *Service) UpdateStar(ctx context.Context, starID int, req *UpdateStarRequest) (*Star, error)
- type Star
- type StarV2
- type UpdateStarRequest
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 }
type MovieCredit ¶
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 (*Repository) GetStarsByMovieID ¶
func (r *Repository) GetStarsByMovieID(ctx context.Context, movieID int) ([]*MovieCredit, error)
func (*Repository) GetStarsForMovie ¶
func (*Repository) GetStarsPaginated ¶
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 (*Service) DeleteStarByID ¶
func (*Service) GetStarByID ¶
func (*Service) GetStarsPaginated ¶
func (*Service) UpdateStar ¶
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 (Star) ConvertToV2 ¶
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"` }