Skip to content

Commit

Permalink
[FIX] Fix controller test and implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
asteriskzie committed May 1, 2024
1 parent 45d8f77 commit a9ea2c1
Show file tree
Hide file tree
Showing 2 changed files with 264 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand Down Expand Up @@ -92,6 +93,27 @@ public ResponseEntity<Review> editSelfSubscriptionBoxId(@RequestBody Map<String,
}
}

@DeleteMapping("/api/subscription-boxes/{subscriptionBoxId}/users/self")
public ResponseEntity<Review> deleteSelfSubscriptionBoxReview(@RequestBody Map<String,String> body, @PathVariable String subscriptionBoxId) {
try {
String userId = body.get("userId");
reviewService.deleteReview(subscriptionBoxId, userId);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} catch (Exception e) {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}

@DeleteMapping("/api/subscription-boxes/{subscriptionBoxId}/users/{userId}")
public ResponseEntity<Review> deleteSubscriptionBoxReview(@PathVariable String subscriptionBoxId, @PathVariable String userId) {
try {
reviewService.deleteReview(subscriptionBoxId, userId);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} catch (Exception e) {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}

@GetMapping("/api/reviews/{subsboxId}")
public List<Review> getBySubscriptionBoxId(@PathVariable String subsboxId) throws Exception {
return reviewService.getAllSubscriptionBoxReview(subsboxId, null);
Expand Down
Loading

0 comments on commit a9ea2c1

Please sign in to comment.