diff --git a/src/main/java/com/sunbird/serve/need/DeliverableService/controllers/NeedDeliverableController.java b/src/main/java/com/sunbird/serve/need/DeliverableService/controllers/NeedDeliverableController.java index 75c16ae..17d7bcb 100644 --- a/src/main/java/com/sunbird/serve/need/DeliverableService/controllers/NeedDeliverableController.java +++ b/src/main/java/com/sunbird/serve/need/DeliverableService/controllers/NeedDeliverableController.java @@ -6,8 +6,10 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import com.sunbird.serve.need.models.Need.NeedDeliverable; +import com.sunbird.serve.need.models.Need.InputParameters; import com.sunbird.serve.need.models.enums.NeedDeliverableStatus; import com.sunbird.serve.need.models.request.NeedDeliverableRequest; +import com.sunbird.serve.need.models.request.DeliverableDetailsRequest; import com.sunbird.serve.need.models.response.NeedDeliverableResponse; import org.springframework.http.HttpStatus; import java.util.List; @@ -89,4 +91,21 @@ public ResponseEntity updateNeedDeliverable( return ResponseEntity.ok(updatedNeedDeliverable); } + //Update Need Deliverable Details + @Operation(summary = "Update a Need Deliverable Details with appropritate values", description = "Update an exsisting need deliverable details") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Successfully Updated Need Deliverable Details", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)), + @ApiResponse(responseCode = "400", description = "Bad Input"), + @ApiResponse(responseCode = "500", description = "Server Error")} + ) + @PutMapping("/deliverable-details/update/{needDeliverableId}") + public ResponseEntity> updateDeliverableDetails( + @PathVariable String needDeliverableId, + @RequestBody DeliverableDetailsRequest request, + @RequestHeader Map headers) { + + List updatedInputParameters = needDeliverableService.updateInputParameters(needDeliverableId, request, headers); + return ResponseEntity.ok(updatedInputParameters); + } + } diff --git a/src/main/java/com/sunbird/serve/need/DeliverableService/services/NeedDeliverableService.java b/src/main/java/com/sunbird/serve/need/DeliverableService/services/NeedDeliverableService.java index 5fd7c93..09791e8 100644 --- a/src/main/java/com/sunbird/serve/need/DeliverableService/services/NeedDeliverableService.java +++ b/src/main/java/com/sunbird/serve/need/DeliverableService/services/NeedDeliverableService.java @@ -3,6 +3,7 @@ import com.sunbird.serve.need.models.Need.NeedDeliverable; import com.sunbird.serve.need.models.Need.InputParameters; import com.sunbird.serve.need.models.request.NeedDeliverableRequest; +import com.sunbird.serve.need.models.request.DeliverableDetailsRequest; import com.sunbird.serve.need.models.response.NeedDeliverableResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -69,4 +70,23 @@ public NeedDeliverable updateNeedDeliverable(UUID needDeliverableId, NeedDeliver return needDeliverableRepository.save(existingNeedDeliverable); } + public List updateInputParameters(String needDeliverableId, DeliverableDetailsRequest request, Map headers) { + // Check if the need with the given ID exists + List existingInputParameters = inputParametersRepository.findByNeedDeliverableId(needDeliverableId); + + if (existingInputParameters != null) { + for (InputParameters parameter : existingInputParameters) { + parameter.setNeedDeliverableId(request.getNeedDeliverableId()); + parameter.setInputUrl(request.getInputUrl()); + parameter.setSoftwarePlatform(request.getSoftwarePlatform()); + parameter.setStartTime(request.getStartTime()); + parameter.setEndTime(request.getEndTime()); + } + + + } + // Save the updated need + return inputParametersRepository.saveAll(existingInputParameters); + } + } diff --git a/src/main/java/com/sunbird/serve/need/models/request/DeliverableDetailsRequest.java b/src/main/java/com/sunbird/serve/need/models/request/DeliverableDetailsRequest.java index 014d29f..d1a1368 100644 --- a/src/main/java/com/sunbird/serve/need/models/request/DeliverableDetailsRequest.java +++ b/src/main/java/com/sunbird/serve/need/models/request/DeliverableDetailsRequest.java @@ -16,10 +16,9 @@ @NoArgsConstructor @AllArgsConstructor public class DeliverableDetailsRequest { - private String needId; + private String needDeliverableId; private String inputUrl; private SoftwarePlatform softwarePlatform; private Instant startTime; private Instant endTime; - private Instant deliverableDate; } \ No newline at end of file