hotels

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckImageUpload

func CheckImageUpload(file multipart.File) (string, error)

Types

type Hotel

type Hotel struct {
	Image         *string    `json:"image,omitempty"`
	UpdatedAt     *time.Time `json:"updated_at"`
	CreatedAt     *time.Time `json:"created_at"`
	Longitude     *float64   `json:"longitude,omitempty"`
	Latitude      *float64   `json:"latitude,omitempty"`
	Location      string     `json:"location" validate:"required,min=10,max=250"`
	Description   string     `json:"description,omitempty" validate:"required,min=10,max=250"`
	City          string     `json:"city,omitempty" validate:"required,min=3,max=25"`
	Country       string     `json:"country,omitempty" validate:"required,min=3,max=25"`
	Email         string     `json:"email,omitempty" validate:"required,email"`
	Name          string     `json:"name" validate:"required,min=3,max=25"`
	Photos        []string   `json:"photos,omitempty"`
	Rating        float64    `json:"rating" validate:"required,min=0,max=10"`
	CommentsCount int        `json:"comments_count,omitempty"`
	HotelID       uuid.UUID  `json:"hotel_id"`
}

type ListResult

type ListResult struct {
	Hotels     []*Hotel `json:"hotels"`
	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 {
	GetHotelByID(ctx context.Context, hotelID uuid.UUID) (*Hotel, error)
	SetHotel(ctx context.Context, hotel *Hotel) error
	DeleteHotel(ctx context.Context, hotelID uuid.UUID) error
}

type RepositoryImpl

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

func NewRepository

func NewRepository(redisClient *redis.Client) RepositoryImpl

func (*RepositoryImpl) DeleteHotel

func (h *RepositoryImpl) DeleteHotel(ctx context.Context, hotelID uuid.UUID) error

func (*RepositoryImpl) GetHotelByID

func (h *RepositoryImpl) GetHotelByID(ctx context.Context, hotelID uuid.UUID) (*Hotel, error)

func (*RepositoryImpl) SetHotel

func (h *RepositoryImpl) SetHotel(ctx context.Context, hotel *Hotel) 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) CreateHotel

func (h *ServerImpl) CreateHotel() echo.HandlerFunc

Register CreateHotel @Tags Hotels @Summary Create new hotel @Description Create new hotel instance @Accept json @Produce json @Success 201 {object} Hotel @Router /api/v1/hotels [post]

func (*ServerImpl) GetHotelByID

func (h *ServerImpl) GetHotelByID() echo.HandlerFunc

Register GetHotelByID @Tags Hotels @Summary Get hotel by id @Description Get single hotel by uuid @Accept json @Produce json @Param hotel_id query string false "hotel uuid" @Success 200 {object} Hotel @Router /api/v1/hotels/{hotel_id} [get]

func (*ServerImpl) GetHotels

func (h *ServerImpl) GetHotels() echo.HandlerFunc

Register GetHotels @Tags Hotels @Summary Get hotels list new user @Description Get hotels list with pagination using page and size query parameters @Accept json @Produce json @Param page query int false "page number" @Param size query int false "number of elements" @Success 200 {object} ListResult @Router /api/v1/hotels [get]

func (*ServerImpl) MapRoutes

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

func (*ServerImpl) UpdateHotel

func (h *ServerImpl) UpdateHotel() echo.HandlerFunc

Register UpdateHotel @Tags Hotels @Summary Update hotel data @Description Update single hotel data @Accept json @Produce json @Param hotel_id path int true "Hotel UUID" @Success 200 {object} Hotel @Router /api/v1/hotels/{hotel_id} [put]

func (*ServerImpl) UploadImage

func (h *ServerImpl) UploadImage() echo.HandlerFunc

UploadImage godoc @Summary Upload hotel image @Tags Hotels @Description Upload hotel logo image @Accept mpfd @Produce json @Param hotel_id query string false "hotel uuid" @Success 200 {object} Hotel @Router /api/v1/hotels/{id}/image [put]

type Service

type Service interface {
	GetHotels(ctx context.Context, page, size int64) (*ListResult, error)
	GetHotelByID(ctx context.Context, hotelID uuid.UUID) (*Hotel, error)
	UpdateHotel(ctx context.Context, hotel *Hotel) (*Hotel, error)
	CreateHotel(ctx context.Context, hotel *Hotel) (*Hotel, error)
	UploadImage(ctx context.Context, data []byte, contentType, hotelID string) error
}

type ServiceImpl

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

func NewService

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

func (*ServiceImpl) CreateHotel

func (s *ServiceImpl) CreateHotel(ctx context.Context, hotel *Hotel) (*Hotel, error)

func (*ServiceImpl) GetHotelByID

func (s *ServiceImpl) GetHotelByID(ctx context.Context, hotelID uuid.UUID) (*Hotel, error)

func (*ServiceImpl) GetHotels

func (s *ServiceImpl) GetHotels(ctx context.Context, page, size int64) (*ListResult, error)

func (*ServiceImpl) UpdateHotel

func (s *ServiceImpl) UpdateHotel(ctx context.Context, hotel *Hotel) (*Hotel, error)

func (*ServiceImpl) UploadImage

func (s *ServiceImpl) UploadImage(ctx context.Context, data []byte, contentType, hotelID string) error

Jump to

Keyboard shortcuts

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