File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
src/main/java/com/kodluyoruz/subscription/controllers Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 44import org .springframework .web .bind .annotation .*;
55
66import java .net .URI ;
7+ import java .util .Objects ;
78
89@ RestController
910@ RequestMapping ("/subscriptions" )
1011public class SubscriptionController {
1112
1213 @ GetMapping
13- public ResponseEntity getSubscriptions (){
14- return ResponseEntity .ok ().build ();
14+ public ResponseEntity getSubscriptions (@ RequestParam (required = false ) String userId , @ RequestParam (required = false ) String paymentId ) {
15+ if (Objects .nonNull (userId ) && Objects .nonNull (paymentId )) {
16+ return ResponseEntity .ok (String .format ("user id -> %s -- payment id -> %s" , userId , paymentId ));
17+ } else if (Objects .nonNull (userId )) {
18+ return ResponseEntity .ok (String .format ("user id -> %s" , userId ));
19+ } else if (Objects .nonNull (paymentId )) {
20+ return ResponseEntity .ok (String .format ("payment id -> %s" , paymentId ));
21+ } else {
22+ return ResponseEntity .ok ("All Subscription" );
23+ }
1524 }
1625
1726 @ PostMapping
@@ -21,7 +30,7 @@ public ResponseEntity createSubscription() {
2130 }
2231
2332 @ PatchMapping
24- public ResponseEntity changeSunscription () {
33+ public ResponseEntity changeSubscription () {
2534 return ResponseEntity .noContent ().build ();
2635 }
2736
@@ -36,7 +45,4 @@ public ResponseEntity deleteSubscription(@PathVariable String id) {
3645 }
3746
3847
39-
40-
41-
4248}
You can’t perform that action at this time.
0 commit comments