feat: add logic for repository
This commit is contained in:
@@ -21,8 +21,16 @@ func NewCommentsRepository(db *sql.DB) CommentRepository {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *commentsRepository) CreateComment(ctx context.Context, comment *storage.CommentCreate) error {
|
||||
_, err := c.db.Exec("INSERT INTO comments(content, post_id) VALUES(?, ?, ?)", comment.Content, comment.PostID, comment.UserID)
|
||||
func (c *commentsRepository) CreateComment(
|
||||
ctx context.Context,
|
||||
comment *storage.CommentCreate,
|
||||
) error {
|
||||
_, err := c.db.Exec(
|
||||
"INSERT INTO comments(content, post_id) VALUES(?, ?, ?)",
|
||||
comment.Content,
|
||||
comment.PostID,
|
||||
comment.UserID,
|
||||
)
|
||||
if err != nil {
|
||||
c.logger.Error("error insert: " + err.Error())
|
||||
return err
|
||||
@@ -58,7 +66,10 @@ func (c *commentsRepository) GetAllComments(ctx context.Context) ([]storage.Comm
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *commentsRepository) GetCommentsOfPost(ctx context.Context, id int) ([]storage.Comment, error) {
|
||||
func (c *commentsRepository) GetCommentsOfPost(
|
||||
ctx context.Context,
|
||||
id int,
|
||||
) ([]storage.Comment, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -66,6 +77,10 @@ func (c *commentsRepository) DeleteComment(ctx context.Context, id int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *commentsRepository) UpdateComment(ctx context.Context, id int, comment *storage.Comment) error {
|
||||
func (c *commentsRepository) UpdateComment(
|
||||
ctx context.Context,
|
||||
id int,
|
||||
comment *storage.Comment,
|
||||
) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user