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
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 53s
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user