comments

package
v0.0.0-...-f5cdc36 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	CreatedAt *time.Time `json:"created_at"`
	UpdatedAt *time.Time `json:"updated_at"`
	Message   string     `json:"message" validate:"required,min=5,max=500"`
	Photos    []string   `json:"photos,omitempty"`
	Rating    float64    `json:"rating" validate:"required,min=0,max=10"`
	CommentID uuid.UUID  `json:"comment_id"`
	HotelID   uuid.UUID  `json:"hotel_id"`
	UserID    uuid.UUID  `json:"user_id"`
}

type CommentFull

type CommentFull struct {
	User      *users.CommentUser `json:"user"`
	CreatedAt *time.Time         `json:"createdAt"`
	UpdatedAt *time.Time         `json:"updatedAt"`
	Message   string             `json:"message"`
	Photos    []string           `json:"photos"`
	Rating    float64            `json:"rating"`
	CommentID uuid.UUID          `json:"comment_id"`
	HotelID   uuid.UUID          `json:"hotel_id"`
}

type List

type List struct {
	Comments   []*CommentFull `json:"comments"`
	TotalCount int64          `json:"totalCount"`
	TotalPages int64          `json:"totalPages"`
	Page       int64          `json:"page"`
	Size       int64          `json:"size"`
	HasMore    bool           `json:"hasMore"`
}

type Repository

type Repository interface {
	CommentByID(ctx context.Context, commentID uuid.UUID) (*Comment, error)
	SetComment(ctx context.Context, comment *Comment) error
	DeleteComment(ctx context.Context, commentID uuid.UUID) error
}

type RepositoryImpl

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

func NewRepository

func NewRepository(redisConn *redis.Client) RepositoryImpl

func (*RepositoryImpl) CommentByID

func (c *RepositoryImpl) CommentByID(ctx context.Context, commentID uuid.UUID) (*Comment, error)

func (*RepositoryImpl) DeleteComment

func (c *RepositoryImpl) DeleteComment(ctx context.Context, commentID uuid.UUID) error

func (*RepositoryImpl) SetComment

func (c *RepositoryImpl) SetComment(ctx context.Context, comment *Comment) error

type ServerImpl

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

func NewServer

func NewServer(
	cfg *config.Config,
	group *echo.Group,
	logger logger.Logger,
	validate *validator.Validate,
	service Service,
) ServerImpl

func (*ServerImpl) CreateComment

func (s *ServerImpl) CreateComment() echo.HandlerFunc

Register CreateComment @Tags Comments @Summary Create new comment @Description Create new single comment @Accept json @Produce json @Success 201 {object} Comment @Router /api/v1/comments [post]

func (*ServerImpl) GetByHotelID

func (s *ServerImpl) GetByHotelID() echo.HandlerFunc

Register GetByHotelID @Tags Comments @Summary Get comments by hotel id @Description Get comments list by hotel uuid @Accept json @Produce json @Param hotel_id query string false "hotel uuid" @Success 200 {object} List @Router /api/v1/comments/hotel/{hotel_id} [get]

func (*ServerImpl) GetCommByID

func (s *ServerImpl) GetCommByID() echo.HandlerFunc

Register GetCommByID @Tags Comments @Summary Get comment by id @Description Get comment by uuid @Accept json @Produce json @Param comment_id query string false "comment uuid" @Success 200 {object} Comment @Router /api/v1/comments/{comment_id} [get]

func (*ServerImpl) MapRoutes

func (s *ServerImpl) MapRoutes(mw *users.SessionMiddleware)

func (*ServerImpl) UpdateComment

func (s *ServerImpl) UpdateComment() echo.HandlerFunc

Register UpdateComment @Tags Comments @Summary Update comment by id @Description Update comment by uuid @Accept json @Produce json @Param comment_id query string false "comment uuid" @Success 200 {object} Comment @Router /api/v1/comments/{comment_id} [put]

type Service

type Service interface {
	CreateComment(ctx context.Context, comment *Comment) (*Comment, error)
	GetCommByID(ctx context.Context, commentID uuid.UUID) (*Comment, error)
	UpdateComment(ctx context.Context, comment *Comment) (*Comment, error)
	GetByHotelID(ctx context.Context, hotelID uuid.UUID, page, size int64) (*List, error)
}

type ServiceImpl

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

func NewService

func NewService(
	logger logger.Logger,
	repository Repository,
) ServiceImpl

func (*ServiceImpl) CreateComment

func (s *ServiceImpl) CreateComment(ctx context.Context, comment *Comment) (*Comment, error)

func (*ServiceImpl) GetByHotelID

func (s *ServiceImpl) GetByHotelID(ctx context.Context, hotelID uuid.UUID, page, size int64) (*List, error)

func (*ServiceImpl) GetCommByID

func (s *ServiceImpl) GetCommByID(ctx context.Context, commentID uuid.UUID) (*Comment, error)

func (*ServiceImpl) UpdateComment

func (s *ServiceImpl) UpdateComment(ctx context.Context, comment *Comment) (*Comment, error)

Jump to

Keyboard shortcuts

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