blogo

package
v0.0.0-...-c4cacf9 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	ID        CommentId `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"created_at"`
	UpdatedAt time.Time `db:"updated_at" json:"updated_at"`

	ParentPostID uint64 `db:"parent_post_id" json:"parent_post_id"`
	ParentID     *int   `db:"parent_id" json:"parent_id"` // allow nullable on lvl 0 comment

	AuthorID       uint64  `db:"author_id" json:"author_id"`
	AuthorUsername *string `db:"username" json:"author_username"`

	Content    string        `db:"content" json:"content"`
	ReactViews []*ReactViews `json:"react_views"`
	Replies    []*Comment    `json:"replies"`
}

type CommentId

type CommentId uint64

type CommentRepository

type CommentRepository interface {
	// GetByPostId get comment which bind to a post
	GetByPostID(PostId) []*Comment
	GetByID(CommentId) *Comment
	InsertComment(comment *Comment) error
}

type CommentService

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

func NewCommentService

func NewCommentService(repo CommentRepository) *CommentService

func (CommentService) CreateComment

func (c CommentService) CreateComment(comment *Comment) error

func (CommentService) GetCommentByID

func (c CommentService) GetCommentByID(commentId CommentId) *Comment

type GitHubClient

type GitHubClient struct {
	Repositories RepositoriesService
	Users        UsersService
}

GitHubClient manages communication with the GitHub API. https://github.com/google/go-github/issues/113

type GitHubCreator

type GitHubCreator struct{}

func (*GitHubCreator) NewClient

func (g *GitHubCreator) NewClient(httpClient *http.Client) GitHubClient

NewClient returns a new GitHubInterface instance.

type GitHubInterface

type GitHubInterface interface {
	NewClient(httpClient *http.Client) GitHubClient
}

GitHubInterface defines all necessary methods. https://godoc.org/github.com/google/go-github/github#NewClient

type Post

type Post struct {
	ID PostId `db:"id" json:"id"`

	AuthorID       uint64 `db:"author_id" json:"author_id"`
	AuthorUsername string `db:"username" json:"author_username"`

	Title      string        `db:"title" json:"title"` // # TODO add field validation before insert
	Content    string        `db:"content" json:"content"`
	ReactViews []*ReactViews `json:"react_views"`
	Replies    []*Comment    `json:"replies"`

	CreatedAt time.Time `db:"created_at" json:"created_at"`
	UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}

type PostId

type PostId uint64

type PostRepository

type PostRepository interface {
	FindByID(PostId) *Post
	InsertPost(post *Post) error
	GetPost(limit, offset int) []*Post
}

type PostService

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

func NewPostService

func NewPostService(postRepo PostRepository, commentRepo CommentRepository, reactRepo ReactRepository) *PostService

func (PostService) CreatePost

func (p PostService) CreatePost(payload *Post) error

func (PostService) GetPostByID

func (p PostService) GetPostByID(postID PostId) *Post

func (PostService) GetPostMany

func (p PostService) GetPostMany(limit, pageNum int) []*Post

type React

type React struct {
	ID uint64 `db:"id" json:"id"`

	AuthorID uint64 `db:"author_id" json:"author_id"`
	ReactID  int    `db:"react_id" json:"react_id"`

	PostID    *uint64 `db:"post_id" json:"post_id"`
	CommentID *uint64 `db:"comment_id" json:"comment_id"`

	CreatedAt time.Time `db:"created_at" json:"created_at"`
	UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}

type ReactRepository

type ReactRepository interface {
	InsertUserReact(react *React) error
	GetByPostID(PostId) []*ReactViews
}

type ReactService

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

func NewReactService

func NewReactService(repository ReactRepository) *ReactService

func (*ReactService) AddReact

func (r *ReactService) AddReact(react *React) error

type ReactViews

type ReactViews struct {
	ReactID int `db:"react_id" json:"react_id"`
	Count   int `db:"count" json:"count"`
}

type RepositoriesService

type RepositoriesService interface {
	Get(context.Context, string, string) (*github.Repository, *github.Response, error)
}

RepositoriesService handles communication with the repository related methods of the GitHub API. https://godoc.org/github.com/google/go-github/github#RepositoriesService

type User

type User struct {
	ID uint64 `json:"id"`

	Username string `json:"username"`
	Password string `json:"-"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type UsersService

type UsersService interface {
	Get(context.Context, string) (*github.User, *github.Response, error)
}

UsersService handles communication with the user related methods of the GitHub API. https://godoc.org/github.com/google/go-github/github#UsersService

Jump to

Keyboard shortcuts

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