domain

package
v0.0.0-...-d903cca Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CollectionComments = "comments"
)
View Source
const (
	CollectionPost = "posts"
)
View Source
const (
	CollectionUser = "users"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	ID         primitive.ObjectID `bson:"_id" json:"-"`
	UserID     primitive.ObjectID `bson:"userID" json:"userID"`
	PostID     primitive.ObjectID `bson:"postID" json:"postID"`
	Content    string             `bson:"content" form:"content" binding:"required" json:"content"`
	DateCreate string             `bson:"date_create" form:"date_create" json:"date_create"`
}

type CommentRepository

type CommentRepository interface {
	Create(c context.Context, comment *Comment) error
	Edit(c context.Context, commentID string, comment *Comment) error
	GetCommentByID(c context.Context, postID string) (Comment, error)
	GetCommentByPostID(c context.Context, postID string) ([]Comment, error)
	Delete(c context.Context, comment *Comment) error
}

type CommentUsecase

type CommentUsecase interface {
	Create(c context.Context, comment *Comment) error
	Edit(c context.Context, commentID string, comment *Comment) error
	GetCommentByID(c context.Context, postID string) (Comment, error)
	GetCommentByPostID(c context.Context, postID string) ([]Comment, error)
	Delete(c context.Context, comment *Comment) error
}

type EditUserRequest

type EditUserRequest struct {
	Name        string `json:"name"`
	Bio         string `json:"bio"`
	ProfilePic  string `json:"profile_pic"`
	SocialMedia string `json:"social_media"`
}

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

type JwtCustomClaims

type JwtCustomClaims struct {
	Name string `json:"name"`
	ID   string `json:"id"`
	jwt.StandardClaims
}

type JwtCustomRefreshClaims

type JwtCustomRefreshClaims struct {
	ID string `json:"id"`
	jwt.StandardClaims
}

type LoginRequest

type LoginRequest struct {
	Email    string `form:"email" binding:"required"`
	Password string `form:"password" binding:"required"`
}

type LoginResponse

type LoginResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
}

type LoginUsecase

type LoginUsecase interface {
	GetUserByEmail(c context.Context, email string) (User, error)
	CreateAccessToken(user *User, secret string, expiry int) (accessToken string, err error)
	CreateRefreshToken(user *User, secret string, expiry int) (refreshToken string, err error)
}

type Post

type Post struct {
	ID                  primitive.ObjectID `bson:"_id" json:"id"`
	Title               string             `bson:"title" form:"title" binding:"required" json:"title"`
	UserID              primitive.ObjectID `bson:"userID" json:"userID"`
	Content             string             `bson:"content" form:"content" binding:"required" json:"content"`
	DateCreate          string             `bson:"date_create" form:"date_create" json:"date_create"`
	DateUpdate          string             `bson:"date_update" form:"date_update" json:"date_update"`
	Categories          []string           `bson:"categories" form:"categories" json:"categories"`
	ApprovedByModerator string             `bson:"approved" form:"approved" json:"approved"`
}

type PostRepository

type PostRepository interface {
	Create(c context.Context, post *Post) error
	Edit(c context.Context, postID string, post *Post) error
	GetPost(c context.Context) ([]Post, error)
	Search(c context.Context, query string) ([]Post, error)
	GetPostByID(c context.Context, commentID string) (Post, error)
	GetPostByUserID(c context.Context, userID string) ([]Post, error)
	GetPostByCategory(c context.Context, category string) ([]Post, error)
	Delete(c context.Context, post *Post) error
}

type PostUsecase

type PostUsecase interface {
	Create(c context.Context, post *Post) error
	Edit(c context.Context, postID string, post *Post) error
	GetPost(c context.Context) ([]Post, error)
	Search(c context.Context, query string) ([]Post, error)
	GetPostByID(c context.Context, postID string) (Post, error)
	GetPostByUserID(c context.Context, userID string) ([]Post, error)
	GetPostByCategory(c context.Context, category string) ([]Post, error)
	Delete(c context.Context, post *Post) error
}

type Profile

type Profile struct {
	Name     string `json:"name"`
	Email    string `json:"email"`
	UserName string `json:"username"`
	Bio      string `json:"bio"`
}

type ProfileUsecase

type ProfileUsecase interface {
	GetProfileByID(c context.Context, userID string) (*Profile, error)
}

type RefreshTokenRequest

type RefreshTokenRequest struct {
	RefreshToken string `form:"refreshToken" binding:"required"`
}

type RefreshTokenResponse

type RefreshTokenResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
}

type RefreshTokenUsecase

type RefreshTokenUsecase interface {
	GetUserByID(c context.Context, id string) (User, error)
	CreateAccessToken(user *User, secret string, expiry int) (accessToken string, err error)
	CreateRefreshToken(user *User, secret string, expiry int) (refreshToken string, err error)
	ExtractIDFromToken(requestToken string, secret string) (string, error)
}

type SignupRequest

type SignupRequest struct {
	Name     string `form:"name" binding:"required"`
	Email    string `form:"email" binding:"required,email"`
	Password string `form:"password" binding:"required"`
	UserName string `from:"username" binding:"required"`
}

type SignupResponse

type SignupResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
}

type SignupUsecase

type SignupUsecase interface {
	Create(c context.Context, user *User) error
	GetUserByEmail(c context.Context, email string) (User, error)
	GetUserByUserName(c context.Context, username string) (User, error)
	CreateAccessToken(user *User, secret string, expiry int) (accessToken string, err error)
	CreateRefreshToken(user *User, secret string, expiry int) (refreshToken string, err error)
}

type SuccessResponse

type SuccessResponse struct {
	Message string `json:"message"`
}

type User

type User struct {
	ID          primitive.ObjectID `bson:"_id"`
	Name        string             `bson:"name"`
	Email       string             `bson:"email"`
	Password    string             `bson:"password"`
	UserName    string             `bson:"username"`
	ProfilePic  string             `bson:"profile_pic"`
	Bio         string             `bson:"bio"`
	SocialMedia string             `bson:"social_media"`
}

type UserNameRequest

type UserNameRequest struct {
	UserName string `bson:"username"`
}

type UserRepository

type UserRepository interface {
	Create(c context.Context, user *User) error
	Fetch(c context.Context) ([]User, error)
	GetUserByEmail(c context.Context, email string) (User, error)
	GetUserByID(c context.Context, id string) (User, error)
	GetUserByUserName(c context.Context, username string) (User, error)
	UpdateUser(c context.Context, user User) error
}

type UserUsecase

type UserUsecase interface {
	GetUserByUserName(c context.Context, id string) (User, error)
	GetUserByUserId(c context.Context, id string) (User, error)
	EditUser(c context.Context, id string, name string, bio string, pic string, media string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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