Documentation ¶
Index ¶
- func InitSearchIndex(ctx context.Context, blogCollection *mongo.Collection) error
- type BlogController
- func (controller *BlogController) CreateBlogPost(c *gin.Context)
- func (controller *BlogController) DeleteBlogPost(c *gin.Context)
- func (controller *BlogController) GetBlogPostByID(c *gin.Context)
- func (controller *BlogController) GetBlogPostBySlug(c *gin.Context)
- func (controller *BlogController) GetBlogPosts(c *gin.Context)
- func (controller *BlogController) GetComment(c *gin.Context)
- func (controller *BlogController) GetComments(c *gin.Context)
- func (controller *BlogController) LikeOrUnlikeComment(c *gin.Context)
- func (controller *BlogController) LikeOrUnlikePost(c *gin.Context)
- func (controller *BlogController) PostComment(c *gin.Context)
- func (controller *BlogController) Search(c *gin.Context)
- func (controller *BlogController) UpdateBlogPost(c *gin.Context)
- func (controller *BlogController) UpdateComment(c *gin.Context)
- type BlogPost
- type BlogRepo
- func (repo *BlogRepo) CreateBlogPost(ctx context.Context, blogPost *BlogPost) (*mongo.InsertOneResult, error)
- func (repo *BlogRepo) DeleteBlogPost(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (repo *BlogRepo) DeleteComment(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (repo *BlogRepo) GetBlogPost(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (*BlogPost, error)
- func (rep *BlogRepo) GetBlogPosts(ctx context.Context, filter interface{}, opts ...*options.FindOptions) ([]*BlogPost, error)
- func (repo *BlogRepo) GetComment(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (*Comment, error)
- func (rep *BlogRepo) GetComments(ctx context.Context, filter interface{}, opts ...*options.FindOptions) ([]*Comment, error)
- func (repo *BlogRepo) PostComment(ctx context.Context, comment *Comment) (*mongo.InsertOneResult, error)
- func (repo *BlogRepo) SearchBlogPosts(ctx context.Context, query string) ([]*BlogPost, error)
- func (repo *BlogRepo) UpdateBlogPost(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (repo *BlogRepo) UpdateComment(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- type BlogRepository
- type BlogService
- func (service *BlogService) CreateBlogPost(ctx context.Context, blogPost *BlogPost) error
- func (service *BlogService) DeleteBlogPost(ctx context.Context, idStr string) error
- func (service *BlogService) DeleteComment(ctx context.Context, idStr string) error
- func (service *BlogService) GetBlogPostByID(ctx context.Context, idStr string) (*BlogPost, error)
- func (service *BlogService) GetBlogPostBySlug(ctx context.Context, slug string) (*BlogPost, error)
- func (service *BlogService) GetBlogPosts(ctx context.Context) ([]*BlogPost, error)
- func (service *BlogService) GetComment(ctx context.Context, idStr string) (*Comment, error)
- func (service *BlogService) GetComments(ctx context.Context, postIdStr string) ([]*Comment, error)
- func (service *BlogService) LikeOrUnlikeComment(ctx context.Context, commentIdStr, userId string, opt CommnentOption) error
- func (service *BlogService) LikeOrUnlikePost(ctx context.Context, postIdStr, userId string, opt PostOption) error
- func (service *BlogService) PostComment(ctx context.Context, comment *Comment) error
- func (service *BlogService) SearchBlogPosts(ctx context.Context, query string) ([]*BlogPost, error)
- func (service *BlogService) UpdateBlogPost(ctx context.Context, blogPost *BlogPost) error
- func (service *BlogService) UpdateComment(ctx context.Context, comment *Comment) error
- type BlogServices
- type Comment
- type CommnentOption
- type Like
- type PostOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitSearchIndex ¶
func InitSearchIndex(ctx context.Context, blogCollection *mongo.Collection) error
Types ¶
type BlogController ¶
type BlogController struct {
// contains filtered or unexported fields
}
func NewBlogController ¶
func NewBlogController(service BlogServices) *BlogController
func (*BlogController) CreateBlogPost ¶
func (controller *BlogController) CreateBlogPost(c *gin.Context)
func (*BlogController) DeleteBlogPost ¶
func (controller *BlogController) DeleteBlogPost(c *gin.Context)
func (*BlogController) GetBlogPostByID ¶
func (controller *BlogController) GetBlogPostByID(c *gin.Context)
func (*BlogController) GetBlogPostBySlug ¶
func (controller *BlogController) GetBlogPostBySlug(c *gin.Context)
func (*BlogController) GetBlogPosts ¶
func (controller *BlogController) GetBlogPosts(c *gin.Context)
func (*BlogController) GetComment ¶
func (controller *BlogController) GetComment(c *gin.Context)
func (*BlogController) GetComments ¶
func (controller *BlogController) GetComments(c *gin.Context)
func (*BlogController) LikeOrUnlikeComment ¶
func (controller *BlogController) LikeOrUnlikeComment(c *gin.Context)
func (*BlogController) LikeOrUnlikePost ¶
func (controller *BlogController) LikeOrUnlikePost(c *gin.Context)
func (*BlogController) PostComment ¶
func (controller *BlogController) PostComment(c *gin.Context)
func (*BlogController) Search ¶
func (controller *BlogController) Search(c *gin.Context)
func (*BlogController) UpdateBlogPost ¶
func (controller *BlogController) UpdateBlogPost(c *gin.Context)
func (*BlogController) UpdateComment ¶
func (controller *BlogController) UpdateComment(c *gin.Context)
type BlogPost ¶
type BlogPost struct { Id primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` Title string `json:"title,omitempty" bson:"title,omitempty"` Slug string `json:"slug,omitempty" bson:"slug,omitempty"` Description string `json:"description,omitempty" bson:"description,omitempty"` Content string `json:"content,omitempty" bson:"content,omitempty"` Likes []Like `json:"likes,omitempty" bson:"likes,omitempty"` CreatedAt time.Time `json:"created_at,omitempty" bson:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty" bson:"updated_at,omitempty"` }
type BlogRepo ¶
type BlogRepo struct {
// contains filtered or unexported fields
}
func NewBlogRepo ¶
func NewBlogRepo(blogCollection, commentCollection *mongo.Collection) *BlogRepo
func (*BlogRepo) CreateBlogPost ¶
func (*BlogRepo) DeleteBlogPost ¶
func (repo *BlogRepo) DeleteBlogPost(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func (*BlogRepo) DeleteComment ¶
func (repo *BlogRepo) DeleteComment(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func (*BlogRepo) GetBlogPost ¶
func (*BlogRepo) GetBlogPosts ¶
func (*BlogRepo) GetComment ¶
func (*BlogRepo) GetComments ¶
func (*BlogRepo) PostComment ¶
func (*BlogRepo) SearchBlogPosts ¶
func (*BlogRepo) UpdateBlogPost ¶
func (repo *BlogRepo) UpdateBlogPost(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
func (*BlogRepo) UpdateComment ¶
func (repo *BlogRepo) UpdateComment(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
type BlogRepository ¶
type BlogRepository interface { CreateBlogPost(ctx context.Context, blogPost *BlogPost) (*mongo.InsertOneResult, error) GetBlogPosts(ctx context.Context, filter interface{}, opts ...*options.FindOptions) ([]*BlogPost, error) GetBlogPost(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (*BlogPost, error) UpdateBlogPost(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error) DeleteBlogPost(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error) SearchBlogPosts(ctx context.Context, query string) ([]*BlogPost, error) PostComment(ctx context.Context, comment *Comment) (*mongo.InsertOneResult, error) GetComments(ctx context.Context, filter interface{}, opts ...*options.FindOptions) ([]*Comment, error) GetComment(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (*Comment, error) UpdateComment(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error) DeleteComment(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error) }
type BlogService ¶
type BlogService struct {
// contains filtered or unexported fields
}
func NewBlogService ¶
func NewBlogService(repo BlogRepository) *BlogService
func (*BlogService) CreateBlogPost ¶
func (service *BlogService) CreateBlogPost(ctx context.Context, blogPost *BlogPost) error
func (*BlogService) DeleteBlogPost ¶
func (service *BlogService) DeleteBlogPost(ctx context.Context, idStr string) error
func (*BlogService) DeleteComment ¶
func (service *BlogService) DeleteComment(ctx context.Context, idStr string) error
func (*BlogService) GetBlogPostByID ¶
func (*BlogService) GetBlogPostBySlug ¶
func (*BlogService) GetBlogPosts ¶
func (service *BlogService) GetBlogPosts(ctx context.Context) ([]*BlogPost, error)
func (*BlogService) GetComment ¶
func (*BlogService) GetComments ¶
func (*BlogService) LikeOrUnlikeComment ¶
func (service *BlogService) LikeOrUnlikeComment(ctx context.Context, commentIdStr, userId string, opt CommnentOption) error
func (*BlogService) LikeOrUnlikePost ¶
func (service *BlogService) LikeOrUnlikePost(ctx context.Context, postIdStr, userId string, opt PostOption) error
func (*BlogService) PostComment ¶
func (service *BlogService) PostComment(ctx context.Context, comment *Comment) error
func (*BlogService) SearchBlogPosts ¶
func (*BlogService) UpdateBlogPost ¶
func (service *BlogService) UpdateBlogPost(ctx context.Context, blogPost *BlogPost) error
func (*BlogService) UpdateComment ¶
func (service *BlogService) UpdateComment(ctx context.Context, comment *Comment) error
type BlogServices ¶
type BlogServices interface { CreateBlogPost(ctx context.Context, blogPost *BlogPost) error GetBlogPosts(ctx context.Context) ([]*BlogPost, error) GetBlogPostByID(ctx context.Context, idStr string) (*BlogPost, error) GetBlogPostBySlug(ctx context.Context, slug string) (*BlogPost, error) UpdateBlogPost(ctx context.Context, blogPost *BlogPost) error DeleteBlogPost(ctx context.Context, idStr string) error SearchBlogPosts(ctx context.Context, query string) ([]*BlogPost, error) PostComment(ctx context.Context, comment *Comment) error GetComments(ctx context.Context, postIdStr string) ([]*Comment, error) GetComment(ctx context.Context, idStr string) (*Comment, error) UpdateComment(ctx context.Context, comment *Comment) error DeleteComment(ctx context.Context, idStr string) error LikeOrUnlikePost(ctx context.Context, postIdStr, userId string, opt PostOption) error LikeOrUnlikeComment(ctx context.Context, commentIdStr, userId string, opt CommnentOption) error }
type Comment ¶
type Comment struct { Id primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` AuthorId string `json:"author_id,omitempty" bson:"author_id,omitempty"` BlogPostId primitive.ObjectID `json:"blog_post_id,omitempty" bson:"blog_post_id,omitempty"` ParentId primitive.ObjectID `json:"parent_id,omitempty" bson:"parent_id,omitempty"` Content string `json:"content,omitempty" bson:"content,omitempty"` Likes []Like `json:"likes,omitempty" bson:"likes,omitempty"` CreatedAt time.Time `json:"created_at,omitempty" bson:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty" bson:"updated_at,omitempty"` }
type CommnentOption ¶
type CommnentOption string
const LikeComment CommnentOption = "like"
const UnlikeComment CommnentOption = "unlike"
type PostOption ¶
type PostOption string
const LikePost PostOption = "like"
const UnlikePost PostOption = "unlike"
Click to show internal directories.
Click to hide internal directories.