feat: add logic for repository

This commit is contained in:
d3m0k1d
2026-02-18 13:43:00 +03:00
parent 3fcaefba1b
commit bb987b1f8b

View File

@@ -21,8 +21,16 @@ func NewCommentsRepository(db *sql.DB) CommentRepository {
} }
} }
func (c *commentsRepository) CreateComment(ctx context.Context, comment *storage.CommentCreate) error { func (c *commentsRepository) CreateComment(
_, err := c.db.Exec("INSERT INTO comments(content, post_id) VALUES(?, ?, ?)", comment.Content, comment.PostID, comment.UserID) 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 { if err != nil {
c.logger.Error("error insert: " + err.Error()) c.logger.Error("error insert: " + err.Error())
return err return err
@@ -58,7 +66,10 @@ func (c *commentsRepository) GetAllComments(ctx context.Context) ([]storage.Comm
return result, nil 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 return nil, nil
} }
@@ -66,6 +77,10 @@ func (c *commentsRepository) DeleteComment(ctx context.Context, id int) error {
return nil 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 return nil
} }