Skip to content

Commit

Permalink
fetch need plan based on need plan id api included
Browse files Browse the repository at this point in the history
  • Loading branch information
Sowmya-Raghuram committed May 15, 2024
1 parent d1dae14 commit 303620e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public ResponseEntity<List<NeedPlanResponse>> getByNeedId(@PathVariable String n
} else {
return ResponseEntity.notFound().build();
}

}


Expand All @@ -78,5 +79,18 @@ public ResponseEntity<NeedPlan> createNeedPlan(@RequestBody NeedPlanRequest requ
return ResponseEntity.status(HttpStatus.CREATED).body(response);
}

//Fetch all need plan based on need plan id
@Operation(summary = "Fetch a Need Plan by providing NeedPlanId", description = "Fetch a NeedPlan by providing NeedPlanId")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully Fetched Need Plan", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)),
@ApiResponse(responseCode = "400", description = "Bad Input"),
@ApiResponse(responseCode = "500", description = "Server Error")}
)
@GetMapping("/need-plan/read/{needPlanId}")
public ResponseEntity<NeedPlan> getNeedPlanById(@PathVariable String needPlanId) {
Optional<NeedPlan> needPlan = needPlanService.getNeedPlanById(UUID.fromString(needPlanId));
return needPlan.map(ResponseEntity::ok)
.orElse(ResponseEntity.notFound().build());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public List<NeedPlanResponse> getByNeedId(String needId) {
return response;
}

//Fetch need plan based on needPlanId
public Optional<NeedPlan> getNeedPlanById(UUID needPlanId) {
return needPlanRepository.findById(needPlanId);
}

public NeedPlan createNeedPlan(NeedPlanRequest needPlanRequest, Map<String, String> headers) {
// Convert RaiseNeedRequest to Need entity
Expand Down

0 comments on commit 303620e

Please sign in to comment.