Documentation ¶
Index ¶
- type BlogService
- func (service *BlogService) AddBlog(blog model.Blog) (primitive.ObjectID, error)
- func (service *BlogService) DeleteBlog(id string) (err error)
- func (service *BlogService) GetBlogByBlogID(blogID string) (blog model.Blog, err error)
- func (service *BlogService) GetBlogs() (blogs []model.Blog, err error)
- func (service *BlogService) GetBlogsByID(userID string) (blogs []model.Blog, err error)
- type CommentService
- type Mongo
- type Service
- type TagService
- type UserService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlogService ¶
type BlogService struct {
DB *mgo.Collection
}
BlogService 博客的服务
func (*BlogService) DeleteBlog ¶
func (service *BlogService) DeleteBlog(id string) (err error)
DeleteBlog 删除博客
func (*BlogService) GetBlogByBlogID ¶
func (service *BlogService) GetBlogByBlogID(blogID string) (blog model.Blog, err error)
GetBlogByBlogID 获取到某个博客
func (*BlogService) GetBlogs ¶
func (service *BlogService) GetBlogs() (blogs []model.Blog, err error)
GetBlogs 获取所有人的所有博客
func (*BlogService) GetBlogsByID ¶
func (service *BlogService) GetBlogsByID(userID string) (blogs []model.Blog, err error)
GetBlogsByID 获取到某个人的所有博客
type CommentService ¶
type CommentService struct {
DB *mongo.Collection
}
CommentService 评论服务
func (*CommentService) GetCommentsByBlogID ¶
func (service *CommentService) GetCommentsByBlogID(id string) (comments []model.Comment, err error)
GetCommentsByBlogID 根据BlogID获得评论
func (*CommentService) PostComment ¶
func (service *CommentService) PostComment(blogID string, comment model.Comment) (id primitive.ObjectID, err error)
PostComment 发评论
type Mongo ¶
type Mongo struct { Host string `yaml:"Host"` Port string `yaml:"Port"` User string `yaml:"User"` Password string `yaml:"Password"` Name string `yaml:"Name"` }
Mongo 数据库配置
type Service ¶
type Service struct { Config Mongo DB *mongo.Database User UserService Tag TagService Blog BlogService Comment CommentService }
type TagService ¶
type TagService struct {
DB *mongo.Collection
}
TagService 标签服务
func (*TagService) GetTagByBlogID ¶
func (service *TagService) GetTagByBlogID(id string) (tags []model.Tag, err error)
GetTagByBlogID 获取某个博客的所有tag
type UserService ¶
type UserService struct {
DB *mongo.Collection
}
func (*UserService) CreateUser ¶
func (*UserService) GetUserByID ¶
func (service *UserService) GetUserByID(id string) (user model.UserInfo, err error)
Click to show internal directories.
Click to hide internal directories.