Documentation
¶
Index ¶
- func CheckImageUpload(file multipart.File) (string, error)
- type Hotel
- type ListResult
- type Repository
- type RepositoryImpl
- type ServerImpl
- func (h *ServerImpl) CreateHotel() echo.HandlerFunc
- func (h *ServerImpl) GetHotelByID() echo.HandlerFunc
- func (h *ServerImpl) GetHotels() echo.HandlerFunc
- func (h *ServerImpl) MapRoutes(mw *users.SessionMiddleware)
- func (h *ServerImpl) UpdateHotel() echo.HandlerFunc
- func (h *ServerImpl) UploadImage() echo.HandlerFunc
- type Service
- type ServiceImpl
- func (s *ServiceImpl) CreateHotel(ctx context.Context, hotel *Hotel) (*Hotel, error)
- func (s *ServiceImpl) GetHotelByID(ctx context.Context, hotelID uuid.UUID) (*Hotel, error)
- func (s *ServiceImpl) GetHotels(ctx context.Context, page, size int64) (*ListResult, error)
- func (s *ServiceImpl) UpdateHotel(ctx context.Context, hotel *Hotel) (*Hotel, error)
- func (s *ServiceImpl) UploadImage(ctx context.Context, data []byte, contentType, hotelID string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 Repository ¶
type RepositoryImpl ¶
type RepositoryImpl struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(redisClient *redis.Client) RepositoryImpl
func (*RepositoryImpl) DeleteHotel ¶
func (*RepositoryImpl) GetHotelByID ¶
type ServerImpl ¶
type ServerImpl struct {
// contains filtered or unexported fields
}
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 (*ServiceImpl) GetHotelByID ¶
func (*ServiceImpl) GetHotels ¶
func (s *ServiceImpl) GetHotels(ctx context.Context, page, size int64) (*ListResult, error)