Documentation ¶
Index ¶
- Constants
- type Comment
- type CommentRepository
- type CommentUsecase
- type EditUserRequest
- type ErrorResponse
- type JwtCustomClaims
- type JwtCustomRefreshClaims
- type LoginRequest
- type LoginResponse
- type LoginUsecase
- type Post
- type PostRepository
- type PostUsecase
- type Profile
- type ProfileUsecase
- type RefreshTokenRequest
- type RefreshTokenResponse
- type RefreshTokenUsecase
- type SignupRequest
- type SignupResponse
- type SignupUsecase
- type SuccessResponse
- type User
- type UserNameRequest
- type UserRepository
- type UserUsecase
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 ErrorResponse ¶
type ErrorResponse struct {
Message string `json:"message"`
}
type JwtCustomClaims ¶
type JwtCustomRefreshClaims ¶
type JwtCustomRefreshClaims struct { ID string `json:"id"` jwt.StandardClaims }
type LoginRequest ¶
type LoginResponse ¶
type LoginUsecase ¶
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 ProfileUsecase ¶
type RefreshTokenRequest ¶
type RefreshTokenRequest struct {
RefreshToken string `form:"refreshToken" binding:"required"`
}
type RefreshTokenResponse ¶
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 SignupResponse ¶
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 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 }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.