Documentation ¶
Index ¶
- Variables
- type Comment
- type CreateCommentParams
- type CreatePostParams
- type DeletePostParams
- type Post
- type Service
- func (s Service) CreateComment(params CreateCommentParams) (*Comment, error)
- func (s Service) CreatePost(params CreatePostParams) (*Post, error)
- func (s Service) DeleteComment(params DeletePostParams) error
- func (s Service) DeletePost(user *auth.User, postId int64) error
- func (s Service) DislikePost(userId, postId int64) error
- func (s Service) GetPost(id int64) (*Post, error)
- func (s Service) LikePost(userId, postId int64) error
- func (s Service) ListComments(postId int64, p pagination.Pagination) (*pagination.Paginated[*Comment], error)
- func (s Service) ListPosts(p pagination.Pagination) (*pagination.Paginated[*Post], error)
- func (s Service) UpdateComment(params UpdateCommentParams) error
- func (s Service) UpdatePost(params UpdatePostParams) error
- type Storer
- type UpdateCommentParams
- type UpdatePostParams
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New("post not found") ErrCommentNotFound = errors.New("post comment not found") ErrDuplicate = errors.New("post already exists") ErrNotAllowed = errors.New("user is not allowed to perform this operation") ErrAlreadyLiked = errors.New("user already like this post") )
Functions ¶
This section is empty.
Types ¶
type CreateCommentParams ¶
type CreatePostParams ¶
type DeletePostParams ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (Service) CreateComment ¶
func (s Service) CreateComment(params CreateCommentParams) (*Comment, error)
func (Service) CreatePost ¶
func (s Service) CreatePost(params CreatePostParams) (*Post, error)
func (Service) DeleteComment ¶
func (s Service) DeleteComment(params DeletePostParams) error
Post owners can delete comments.
func (Service) DislikePost ¶
func (Service) ListComments ¶
func (s Service) ListComments(postId int64, p pagination.Pagination) (*pagination.Paginated[*Comment], error)
func (Service) ListPosts ¶
func (s Service) ListPosts(p pagination.Pagination) (*pagination.Paginated[*Post], error)
func (Service) UpdateComment ¶
func (s Service) UpdateComment(params UpdateCommentParams) error
func (Service) UpdatePost ¶
func (s Service) UpdatePost(params UpdatePostParams) error
type Storer ¶
type Storer interface { InsertPost(*Post) error GetPost(int64) (*Post, error) ListPosts(limit, offset int) ([]*Post, error) DeletePost(int64) error UpdatePost(*Post) error CountPosts() (int, error) InsertPostLike(userId int64, postId int64) error DeletePostLike(userId int64, postId int64) error GetComment(postId, commentId int64) (*Comment, error) InsertPostComment(*Comment) error ListPostComments(postId int64, limit int, offset int) ([]*Comment, error) DeletePostComment(int64) error UpdatePostComment(*Comment) error CountPostComments(postId int64) (int, error) }
type UpdateCommentParams ¶
Click to show internal directories.
Click to hide internal directories.