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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_app_comments_comments_proto protoreflect.FileDescriptor

Functions

func RegisterCommentsServiceServer

func RegisterCommentsServiceServer(s *grpc.Server, srv CommentsServiceServer)

func UsersGRPCClientFactory

func UsersGRPCClientFactory(
	logger logger.Logger,
	cfg *config.Config,
	tracer opentracing.Tracer,
) func(ctx context.Context) (*grpc.ClientConn, users.UserServiceClient, error)

Types

type Application

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

func NewApplication

func NewApplication(logger logger.Logger, cfg *config.Config, pgxPool *pgxpool.Pool, tracer opentracing.Tracer) Application

func (*Application) Run

func (a *Application) Run() error

type Comment

type Comment struct {
	CreatedAt *timestamp.Timestamp `protobuf:"bytes,7,opt,name=CreatedAt,proto3" json:"CreatedAt,omitempty"`
	UpdatedAt *timestamp.Timestamp `protobuf:"bytes,8,opt,name=UpdatedAt,proto3" json:"UpdatedAt,omitempty"`
	CommentID string               `protobuf:"bytes,1,opt,name=CommentID,proto3" json:"CommentID,omitempty"`
	HotelID   string               `protobuf:"bytes,2,opt,name=HotelID,proto3" json:"HotelID,omitempty"`
	UserID    string               `protobuf:"bytes,3,opt,name=UserID,proto3" json:"UserID,omitempty"`
	Message   string               `protobuf:"bytes,4,opt,name=Message,proto3" json:"Message,omitempty"`
	Photos    []string             `protobuf:"bytes,5,rep,name=Photos,proto3" json:"Photos,omitempty"`
	Rating    float64              `protobuf:"fixed64,6,opt,name=Rating,proto3" json:"Rating,omitempty"`
	// contains filtered or unexported fields
}

func (*Comment) Descriptor deprecated

func (*Comment) Descriptor() ([]byte, []int)

Deprecated: Use Comment.ProtoReflect.Descriptor instead.

func (*Comment) GetCommentID

func (x *Comment) GetCommentID() string

func (*Comment) GetCreatedAt

func (x *Comment) GetCreatedAt() *timestamp.Timestamp

func (*Comment) GetHotelID

func (x *Comment) GetHotelID() string

func (*Comment) GetMessage

func (x *Comment) GetMessage() string

func (*Comment) GetPhotos

func (x *Comment) GetPhotos() []string

func (*Comment) GetRating

func (x *Comment) GetRating() float64

func (*Comment) GetUpdatedAt

func (x *Comment) GetUpdatedAt() *timestamp.Timestamp

func (*Comment) GetUserID

func (x *Comment) GetUserID() string

func (*Comment) ProtoMessage

func (*Comment) ProtoMessage()

func (*Comment) ProtoReflect

func (x *Comment) ProtoReflect() protoreflect.Message

func (*Comment) Reset

func (x *Comment) Reset()

func (*Comment) String

func (x *Comment) String() string

type CommentDO

type CommentDO 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"`
}

func (*CommentDO) ToProto

func (c *CommentDO) ToProto() *Comment

type CommentFull

type CommentFull struct {
	CreatedAt *timestamp.Timestamp `protobuf:"bytes,7,opt,name=CreatedAt,proto3" json:"CreatedAt,omitempty"`
	UpdatedAt *timestamp.Timestamp `protobuf:"bytes,8,opt,name=UpdatedAt,proto3" json:"UpdatedAt,omitempty"`
	User      *users.User          `protobuf:"bytes,3,opt,name=User,proto3" json:"User,omitempty"`
	CommentID string               `protobuf:"bytes,1,opt,name=CommentID,proto3" json:"CommentID,omitempty"`
	HotelID   string               `protobuf:"bytes,2,opt,name=HotelID,proto3" json:"HotelID,omitempty"`
	Message   string               `protobuf:"bytes,4,opt,name=Message,proto3" json:"Message,omitempty"`
	Photos    []string             `protobuf:"bytes,5,rep,name=Photos,proto3" json:"Photos,omitempty"`
	Rating    float64              `protobuf:"fixed64,6,opt,name=Rating,proto3" json:"Rating,omitempty"`
	// contains filtered or unexported fields
}

func (*CommentFull) Descriptor deprecated

func (*CommentFull) Descriptor() ([]byte, []int)

Deprecated: Use CommentFull.ProtoReflect.Descriptor instead.

func (*CommentFull) GetCommentID

func (x *CommentFull) GetCommentID() string

func (*CommentFull) GetCreatedAt

func (x *CommentFull) GetCreatedAt() *timestamp.Timestamp

func (*CommentFull) GetHotelID

func (x *CommentFull) GetHotelID() string

func (*CommentFull) GetMessage

func (x *CommentFull) GetMessage() string

func (*CommentFull) GetPhotos

func (x *CommentFull) GetPhotos() []string

func (*CommentFull) GetRating

func (x *CommentFull) GetRating() float64

func (*CommentFull) GetUpdatedAt

func (x *CommentFull) GetUpdatedAt() *timestamp.Timestamp

func (*CommentFull) GetUser

func (x *CommentFull) GetUser() *users.User

func (*CommentFull) ProtoMessage

func (*CommentFull) ProtoMessage()

func (*CommentFull) ProtoReflect

func (x *CommentFull) ProtoReflect() protoreflect.Message

func (*CommentFull) Reset

func (x *CommentFull) Reset()

func (*CommentFull) String

func (x *CommentFull) String() string

type CommentsServiceClient

type CommentsServiceClient interface {
	CreateComment(ctx context.Context, in *CreateCommentRequest, opts ...grpc.CallOption) (*CreateCommentResponse, error)
	GetCommByID(ctx context.Context, in *GetCommentByIDRequest, opts ...grpc.CallOption) (*GetCommentByIDResponse, error)
	UpdateComment(ctx context.Context, in *UpdateCommentRequest, opts ...grpc.CallOption) (*UpdateCommentResponse, error)
	GetByHotelID(ctx context.Context, in *GetCommentsByHotelRequest, opts ...grpc.CallOption) (*GetCommentsByHotelResponse, error)
}

CommentsServiceClient is the client API for CommentsService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

type CommentsServiceServer

CommentsServiceServer is the server API for CommentsService service.

type CreateCommentRequest

type CreateCommentRequest struct {
	HotelID string   `protobuf:"bytes,1,opt,name=HotelID,proto3" json:"HotelID,omitempty"`
	UserID  string   `protobuf:"bytes,2,opt,name=UserID,proto3" json:"UserID,omitempty"`
	Message string   `protobuf:"bytes,3,opt,name=Message,proto3" json:"Message,omitempty"`
	Photos  []string `protobuf:"bytes,4,rep,name=Photos,proto3" json:"Photos,omitempty"`
	Rating  float64  `protobuf:"fixed64,5,opt,name=Rating,proto3" json:"Rating,omitempty"`
	// contains filtered or unexported fields
}

func (*CreateCommentRequest) Descriptor deprecated

func (*CreateCommentRequest) Descriptor() ([]byte, []int)

Deprecated: Use CreateCommentRequest.ProtoReflect.Descriptor instead.

func (*CreateCommentRequest) GetHotelID

func (x *CreateCommentRequest) GetHotelID() string

func (*CreateCommentRequest) GetMessage

func (x *CreateCommentRequest) GetMessage() string

func (*CreateCommentRequest) GetPhotos

func (x *CreateCommentRequest) GetPhotos() []string

func (*CreateCommentRequest) GetRating

func (x *CreateCommentRequest) GetRating() float64

func (*CreateCommentRequest) GetUserID

func (x *CreateCommentRequest) GetUserID() string

func (*CreateCommentRequest) ProtoMessage

func (*CreateCommentRequest) ProtoMessage()

func (*CreateCommentRequest) ProtoReflect

func (x *CreateCommentRequest) ProtoReflect() protoreflect.Message

func (*CreateCommentRequest) Reset

func (x *CreateCommentRequest) Reset()

func (*CreateCommentRequest) String

func (x *CreateCommentRequest) String() string

type CreateCommentResponse

type CreateCommentResponse struct {
	Comment *Comment `protobuf:"bytes,1,opt,name=Comment,proto3" json:"Comment,omitempty"`
	// contains filtered or unexported fields
}

func (*CreateCommentResponse) Descriptor deprecated

func (*CreateCommentResponse) Descriptor() ([]byte, []int)

Deprecated: Use CreateCommentResponse.ProtoReflect.Descriptor instead.

func (*CreateCommentResponse) GetComment

func (x *CreateCommentResponse) GetComment() *Comment

func (*CreateCommentResponse) ProtoMessage

func (*CreateCommentResponse) ProtoMessage()

func (*CreateCommentResponse) ProtoReflect

func (x *CreateCommentResponse) ProtoReflect() protoreflect.Message

func (*CreateCommentResponse) Reset

func (x *CreateCommentResponse) Reset()

func (*CreateCommentResponse) String

func (x *CreateCommentResponse) String() string

type FullCommentsList

type FullCommentsList struct {
	UsersList    []users.UserResponse
	CommentsList List
}

type FullList

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

All Comments response with pagination

type GRPCServer

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

func NewServer

func NewServer(service Service, logger logger.Logger, cfg *config.Config, validate *validator.Validate) GRPCServer

func (*GRPCServer) CreateComment

func (*GRPCServer) GetByHotelID

func (*GRPCServer) GetCommByID

func (*GRPCServer) UpdateComment

type GetCommentByIDRequest

type GetCommentByIDRequest struct {
	CommentID string `protobuf:"bytes,1,opt,name=CommentID,proto3" json:"CommentID,omitempty"`
	// contains filtered or unexported fields
}

func (*GetCommentByIDRequest) Descriptor deprecated

func (*GetCommentByIDRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetCommentByIDRequest.ProtoReflect.Descriptor instead.

func (*GetCommentByIDRequest) GetCommentID

func (x *GetCommentByIDRequest) GetCommentID() string

func (*GetCommentByIDRequest) ProtoMessage

func (*GetCommentByIDRequest) ProtoMessage()

func (*GetCommentByIDRequest) ProtoReflect

func (x *GetCommentByIDRequest) ProtoReflect() protoreflect.Message

func (*GetCommentByIDRequest) Reset

func (x *GetCommentByIDRequest) Reset()

func (*GetCommentByIDRequest) String

func (x *GetCommentByIDRequest) String() string

type GetCommentByIDResponse

type GetCommentByIDResponse struct {
	Comment *Comment `protobuf:"bytes,1,opt,name=Comment,proto3" json:"Comment,omitempty"`
	// contains filtered or unexported fields
}

func (*GetCommentByIDResponse) Descriptor deprecated

func (*GetCommentByIDResponse) Descriptor() ([]byte, []int)

Deprecated: Use GetCommentByIDResponse.ProtoReflect.Descriptor instead.

func (*GetCommentByIDResponse) GetComment

func (x *GetCommentByIDResponse) GetComment() *Comment

func (*GetCommentByIDResponse) ProtoMessage

func (*GetCommentByIDResponse) ProtoMessage()

func (*GetCommentByIDResponse) ProtoReflect

func (x *GetCommentByIDResponse) ProtoReflect() protoreflect.Message

func (*GetCommentByIDResponse) Reset

func (x *GetCommentByIDResponse) Reset()

func (*GetCommentByIDResponse) String

func (x *GetCommentByIDResponse) String() string

type GetCommentsByHotelRequest

type GetCommentsByHotelRequest struct {
	HotelID string `protobuf:"bytes,1,opt,name=HotelID,proto3" json:"HotelID,omitempty"`
	Page    int64  `protobuf:"varint,2,opt,name=page,proto3" json:"page,omitempty"`
	Size    int64  `protobuf:"varint,3,opt,name=size,proto3" json:"size,omitempty"`
	// contains filtered or unexported fields
}

func (*GetCommentsByHotelRequest) Descriptor deprecated

func (*GetCommentsByHotelRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetCommentsByHotelRequest.ProtoReflect.Descriptor instead.

func (*GetCommentsByHotelRequest) GetHotelID

func (x *GetCommentsByHotelRequest) GetHotelID() string

func (*GetCommentsByHotelRequest) GetPage

func (x *GetCommentsByHotelRequest) GetPage() int64

func (*GetCommentsByHotelRequest) GetSize

func (x *GetCommentsByHotelRequest) GetSize() int64

func (*GetCommentsByHotelRequest) ProtoMessage

func (*GetCommentsByHotelRequest) ProtoMessage()

func (*GetCommentsByHotelRequest) ProtoReflect

func (*GetCommentsByHotelRequest) Reset

func (x *GetCommentsByHotelRequest) Reset()

func (*GetCommentsByHotelRequest) String

func (x *GetCommentsByHotelRequest) String() string

type GetCommentsByHotelResponse

type GetCommentsByHotelResponse struct {
	Comments   []*CommentFull `protobuf:"bytes,6,rep,name=Comments,proto3" json:"Comments,omitempty"`
	TotalCount int64          `protobuf:"varint,1,opt,name=TotalCount,proto3" json:"TotalCount,omitempty"`
	TotalPages int64          `protobuf:"varint,2,opt,name=TotalPages,proto3" json:"TotalPages,omitempty"`
	Page       int64          `protobuf:"varint,3,opt,name=Page,proto3" json:"Page,omitempty"`
	Size       int64          `protobuf:"varint,4,opt,name=Size,proto3" json:"Size,omitempty"`
	HasMore    bool           `protobuf:"varint,5,opt,name=HasMore,proto3" json:"HasMore,omitempty"`
	// contains filtered or unexported fields
}

func (*GetCommentsByHotelResponse) Descriptor deprecated

func (*GetCommentsByHotelResponse) Descriptor() ([]byte, []int)

Deprecated: Use GetCommentsByHotelResponse.ProtoReflect.Descriptor instead.

func (*GetCommentsByHotelResponse) GetComments

func (x *GetCommentsByHotelResponse) GetComments() []*CommentFull

func (*GetCommentsByHotelResponse) GetHasMore

func (x *GetCommentsByHotelResponse) GetHasMore() bool

func (*GetCommentsByHotelResponse) GetPage

func (x *GetCommentsByHotelResponse) GetPage() int64

func (*GetCommentsByHotelResponse) GetSize

func (x *GetCommentsByHotelResponse) GetSize() int64

func (*GetCommentsByHotelResponse) GetTotalCount

func (x *GetCommentsByHotelResponse) GetTotalCount() int64

func (*GetCommentsByHotelResponse) GetTotalPages

func (x *GetCommentsByHotelResponse) GetTotalPages() int64

func (*GetCommentsByHotelResponse) ProtoMessage

func (*GetCommentsByHotelResponse) ProtoMessage()

func (*GetCommentsByHotelResponse) ProtoReflect

func (*GetCommentsByHotelResponse) Reset

func (x *GetCommentsByHotelResponse) Reset()

func (*GetCommentsByHotelResponse) String

func (x *GetCommentsByHotelResponse) String() string

type List

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

All Comments response with pagination

func (*List) ToHotelByIDProto

func (h *List) ToHotelByIDProto(userz []*users.User) []*CommentFull

func (*List) ToProto

func (h *List) ToProto() []*Comment

type Repository

type Repository interface {
	Create(ctx context.Context, comment *CommentDO) (*CommentDO, error)
	GetByID(ctx context.Context, commentID uuid.UUID) (*CommentDO, error)
	Update(ctx context.Context, comment *CommentDO) (*CommentDO, error)
	GetByHotelID(ctx context.Context, hotelID uuid.UUID, query *pagination.Pagination) (*List, error)
}

type RepositoryImpl

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

func NewRepository

func NewRepository(db *pgxpool.Pool) RepositoryImpl

func (*RepositoryImpl) Create

func (c *RepositoryImpl) Create(ctx context.Context, comment *CommentDO) (*CommentDO, error)

func (*RepositoryImpl) GetByHotelID

func (c *RepositoryImpl) GetByHotelID(ctx context.Context, hotelID uuid.UUID, query *pagination.Pagination) (*List, error)

func (*RepositoryImpl) GetByID

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

func (*RepositoryImpl) Update

func (c *RepositoryImpl) Update(ctx context.Context, comment *CommentDO) (*CommentDO, error)

type Service

type Service interface {
	Create(ctx context.Context, comment *CommentDO) (*CommentDO, error)
	GetByID(ctx context.Context, commentID uuid.UUID) (*CommentDO, error)
	Update(ctx context.Context, comment *CommentDO) (*CommentDO, error)
	GetByHotelID(ctx context.Context, hotelID uuid.UUID, query *pagination.Pagination) (*FullList, error)
}

type ServiceImpl

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

func NewService

func NewService(
	repository Repository,
	logger logger.Logger,
	grpcClientFactory func(ctx context.Context) (*grpc.ClientConn, users.UserServiceClient, error),
) ServiceImpl

func (*ServiceImpl) Create

func (s *ServiceImpl) Create(ctx context.Context, comment *CommentDO) (*CommentDO, error)

func (*ServiceImpl) GetByHotelID

func (s *ServiceImpl) GetByHotelID(ctx context.Context, hotelID uuid.UUID, query *pagination.Pagination) (*FullList, error)

func (*ServiceImpl) GetByID

func (s *ServiceImpl) GetByID(ctx context.Context, commentID uuid.UUID) (*CommentDO, error)

func (*ServiceImpl) Update

func (s *ServiceImpl) Update(ctx context.Context, comment *CommentDO) (*CommentDO, error)

type UnimplementedCommentsServiceServer

type UnimplementedCommentsServiceServer struct {
}

UnimplementedCommentsServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedCommentsServiceServer) CreateComment

func (*UnimplementedCommentsServiceServer) GetByHotelID

func (*UnimplementedCommentsServiceServer) GetCommByID

func (*UnimplementedCommentsServiceServer) UpdateComment

type UpdateCommentRequest

type UpdateCommentRequest struct {
	CommentID string   `protobuf:"bytes,1,opt,name=CommentID,proto3" json:"CommentID,omitempty"`
	Message   string   `protobuf:"bytes,2,opt,name=Message,proto3" json:"Message,omitempty"`
	Photos    []string `protobuf:"bytes,3,rep,name=Photos,proto3" json:"Photos,omitempty"`
	Rating    float64  `protobuf:"fixed64,4,opt,name=Rating,proto3" json:"Rating,omitempty"`
	// contains filtered or unexported fields
}

func (*UpdateCommentRequest) Descriptor deprecated

func (*UpdateCommentRequest) Descriptor() ([]byte, []int)

Deprecated: Use UpdateCommentRequest.ProtoReflect.Descriptor instead.

func (*UpdateCommentRequest) GetCommentID

func (x *UpdateCommentRequest) GetCommentID() string

func (*UpdateCommentRequest) GetMessage

func (x *UpdateCommentRequest) GetMessage() string

func (*UpdateCommentRequest) GetPhotos

func (x *UpdateCommentRequest) GetPhotos() []string

func (*UpdateCommentRequest) GetRating

func (x *UpdateCommentRequest) GetRating() float64

func (*UpdateCommentRequest) ProtoMessage

func (*UpdateCommentRequest) ProtoMessage()

func (*UpdateCommentRequest) ProtoReflect

func (x *UpdateCommentRequest) ProtoReflect() protoreflect.Message

func (*UpdateCommentRequest) Reset

func (x *UpdateCommentRequest) Reset()

func (*UpdateCommentRequest) String

func (x *UpdateCommentRequest) String() string

type UpdateCommentResponse

type UpdateCommentResponse struct {
	Comment *Comment `protobuf:"bytes,1,opt,name=Comment,proto3" json:"Comment,omitempty"`
	// contains filtered or unexported fields
}

func (*UpdateCommentResponse) Descriptor deprecated

func (*UpdateCommentResponse) Descriptor() ([]byte, []int)

Deprecated: Use UpdateCommentResponse.ProtoReflect.Descriptor instead.

func (*UpdateCommentResponse) GetComment

func (x *UpdateCommentResponse) GetComment() *Comment

func (*UpdateCommentResponse) ProtoMessage

func (*UpdateCommentResponse) ProtoMessage()

func (*UpdateCommentResponse) ProtoReflect

func (x *UpdateCommentResponse) ProtoReflect() protoreflect.Message

func (*UpdateCommentResponse) Reset

func (x *UpdateCommentResponse) Reset()

func (*UpdateCommentResponse) String

func (x *UpdateCommentResponse) String() string

Jump to

Keyboard shortcuts

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