posts

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

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

Go to latest
Published: Jun 9, 2024 License: Apache-2.0 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        string    `bson:"id,omitempty" json:"id"`
	Content   string    `bson:"content"      json:"content"`
	CreatedAt time.Time `bson:"created_at"   json:"created_at"`
	UpdateAt  time.Time `bson:"updated_at"   json:"updated_at"`
	UserID    string    `bson:"user_id"      json:"user_id"`
}

type CommentsPage

type CommentsPage struct {
	Page
	Comments []Comment `json:"comments"`
}

func (CommentsPage) MarshalJSON

func (page CommentsPage) MarshalJSON() ([]byte, error)

type Like

type Like struct {
	UserID    string    `bson:"user_id"    json:"user_id"`
	CreatedAt time.Time `bson:"created_at" json:"created_at"`
}

type LikesPage

type LikesPage struct {
	Page
	Likes []Like `json:"likes"`
}

func (LikesPage) MarshalJSON

func (page LikesPage) MarshalJSON() ([]byte, error)

type Page

type Page struct {
	Total      uint64 `db:"total"                json:"total"`
	Offset     uint64 `db:"offset"               json:"offset"`
	Limit      uint64 `db:"limit"                json:"limit"`
	Tag        string `db:"tag,omitempty"        json:"tag,omitempty"`
	PostID     string `db:"post_id,omitempty"    json:"post_id,omitempty"`
	Visibility bool   `db:"visibility,omitempty" json:"visibility,omitempty"`
	UserID     string `db:"user_id,omitempty"    json:"user_id,omitempty"`
	CommentID  string `db:"comment_id,omitempty" json:"comment_id,omitempty"`
}

type Post

type Post struct {
	ID         string    `bson:"_id,omitempty"      json:"id"`
	Title      string    `bson:"title"              json:"title"`
	Content    string    `bson:"content"            json:"content"`
	Tags       []string  `bson:"tags"               json:"tags"`
	ImageURL   string    `bson:"image_url"          json:"image_url"`
	Visibility bool      `bson:"visibility"         json:"visibility"`
	CreatedAt  time.Time `bson:"created_at"         json:"created_at"`
	UpdatedAt  time.Time `bson:"updated_at"         json:"updated_at"`
	UserID     string    `bson:"user_id"            json:"user_id"`
	Comments   []Comment `bson:"comments,omitempty" json:"comments,omitempty"`
	Likes      []Like    `bson:"likes,omitempty"    json:"likes,omitempty"`
	Shares     []Share   `bson:"shares,omitempty"   json:"shares,omitempty"`
}

func (Post) MarshalJSON

func (post Post) MarshalJSON() ([]byte, error)

type PostsPage

type PostsPage struct {
	Page
	Posts []Post `json:"posts"`
}

func (PostsPage) MarshalJSON

func (page PostsPage) MarshalJSON() ([]byte, error)

type Repository

type Repository interface {
	Create(ctx context.Context, post Post) (Post, error)
	RetrieveByID(ctx context.Context, id string) (Post, error)
	RetrieveAll(ctx context.Context, page Page) (PostsPage, error)
	Update(ctx context.Context, post Post) (Post, error)
	UpdateContent(ctx context.Context, post Post) (Post, error)
	UpdateTags(ctx context.Context, post Post) (Post, error)
	UpdateImageURL(ctx context.Context, post Post) (Post, error)
	UpdateVisibility(ctx context.Context, post Post) (Post, error)
	Delete(ctx context.Context, id string) error

	CreateComment(ctx context.Context, postID string, comment Comment) (Comment, error)
	RetrieveCommentByID(ctx context.Context, id string) (Comment, error)
	RetrieveAllComments(ctx context.Context, page Page) (CommentsPage, error)
	UpdateComment(ctx context.Context, comment Comment) (Comment, error)
	DeleteComment(ctx context.Context, id string) error

	CreateLike(ctx context.Context, postID string, like Like) (Like, error)
	RetrieveAllLikes(ctx context.Context, page Page) (LikesPage, error)
	DeleteLike(ctx context.Context, postID, userID string) error

	CreateShare(ctx context.Context, postID string, share Share) (Share, error)
	RetrieveShareByID(ctx context.Context, id string) (Share, error)
	RetrieveAllShares(ctx context.Context, page Page) (SharesPage, error)
	DeleteShare(ctx context.Context, id string) error
}

type Service

type Service interface {
	CreatePost(ctx context.Context, token string, post Post) (Post, error)
	RetrievePostByID(ctx context.Context, token string, id string) (Post, error)
	RetrieveAllPosts(ctx context.Context, token string, page Page) (PostsPage, error)
	UpdatePost(ctx context.Context, token string, post Post) (Post, error)
	UpdatePostContent(ctx context.Context, token string, post Post) (Post, error)
	UpdatePostTags(ctx context.Context, token string, post Post) (Post, error)
	UpdatePostImageURL(ctx context.Context, token string, post Post) (Post, error)
	UpdatePostVisibility(ctx context.Context, token string, post Post) (Post, error)
	DeletePost(ctx context.Context, token string, id string) error

	CreateComment(ctx context.Context, token string, postID string, comment Comment) (Comment, error)
	RetrieveCommentByID(ctx context.Context, token string, id string) (Comment, error)
	RetrieveAllComments(ctx context.Context, token string, page Page) (CommentsPage, error)
	UpdateComment(ctx context.Context, token string, comment Comment) (Comment, error)
	DeleteComment(ctx context.Context, roken, id string) error

	CreateLike(ctx context.Context, token string, postID string, like Like) (Like, error)
	RetrieveAllLikes(ctx context.Context, token string, page Page) (LikesPage, error)
	DeleteLike(ctx context.Context, token string, postID string) error

	CreateShare(ctx context.Context, token string, postID string, share Share) (Share, error)
	RetrieveAllShares(ctx context.Context, token string, page Page) (SharesPage, error)
	DeleteShare(ctx context.Context, token string, postID string) error
}

func NewService

func NewService(repo Repository, users proto.UsersServiceClient, cacher cache.Cacher) Service

type Share

type Share struct {
	ID        string    `bson:"id,omitempty" json:"id"`
	UserID    string    `bson:"user_id"      json:"user_id"`
	CreatedAt time.Time `bson:"created_at"   json:"created_at"`
}

type SharesPage

type SharesPage struct {
	Page
	Shares []Share `json:"shares"`
}

func (SharesPage) MarshalJSON

func (page SharesPage) MarshalJSON() ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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