service

package
v0.0.0-...-7e0de9a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

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) AddBlog

func (service *BlogService) AddBlog(blog model.Blog) (primitive.ObjectID, error)

AddBlog 添加博客

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
}

func NewService

func NewService(c Mongo) (*Service, error)

NewModel 初始化Service

func (*Service) InitMongo

func (service *Service) InitMongo(conf Mongo) error

InitMongo 初始化数据库

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

func (*TagService) PostTag

func (service *TagService) PostTag(id string, tag model.Tag) (ID primitive.ObjectID, err error)

PostTag 修改每个博客的tag

type UserService

type UserService struct {
	DB *mongo.Collection
}

func (*UserService) CreateUser

func (service *UserService) CreateUser(id string, name string, password string) (ID string, err error)

func (*UserService) GetUserByID

func (service *UserService) GetUserByID(id string) (user model.UserInfo, err error)

func (*UserService) LoginUser

func (service *UserService) LoginUser(id string, password string) (name string, err error)

Jump to

Keyboard shortcuts

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