Refactor blog post logic to standardize field names and improve error handling; implement pagination for post listing and add tag retrieval functionality.
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 53s

This commit is contained in:
2025-10-25 12:21:17 +08:00
parent e21f9e6d1a
commit aaa89bf8b7
9 changed files with 174 additions and 27 deletions

View File

@@ -28,7 +28,7 @@ func NewDeletePostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Delete
func (l *DeletePostLogic) DeletePost(req *types.DeletePostReq) (resp *types.DeletePostResp, err error) {
// Delete post from database
query := `DELETE FROM posts WHERE id = $1`
result, err := l.svcCtx.DB.ExecContext(l.ctx, query, req.Post_id)
result, err := l.svcCtx.DB.ExecContext(l.ctx, query, req.PostId)
if err != nil {
l.Errorf("Failed to delete post: %v", err)
return nil, err
@@ -41,7 +41,7 @@ func (l *DeletePostLogic) DeletePost(req *types.DeletePostReq) (resp *types.Dele
return nil, err
}
if rowsAffected == 0 {
l.Errorf("Post not found with id: %s", req.Post_id)
l.Errorf("Post not found with id: %s", req.PostId)
return nil, fmt.Errorf("post not found")
}