|
39 | 39 | import org.apache.commons.logging.LogFactory; |
40 | 40 | import org.springframework.beans.factory.annotation.Value; |
41 | 41 | import org.springframework.core.io.Resource; |
| 42 | +import org.springframework.http.HttpStatus; |
42 | 43 | import org.springframework.http.MediaType; |
43 | 44 | import org.springframework.http.ResponseEntity; |
44 | 45 | import org.springframework.security.access.prepost.PreAuthorize; |
@@ -391,10 +392,15 @@ public ResponseEntity<List<CRMOrganisation>> organisations() { |
391 | 392 | @Operation(summary = "Delete CRM organisation") |
392 | 393 | @SecurityRequirement(name = API_HEADER_SCHEME_NAME) |
393 | 394 | @PreAuthorize("hasRole('CRM')") |
394 | | - public ResponseEntity<Void> deleteOrganisation(@RequestBody CRMOrganisation crmOrganisation) { |
| 395 | + public ResponseEntity<Map<String, String>> deleteOrganisation(@RequestBody CRMOrganisation crmOrganisation) { |
395 | 396 | Optional<Organisation> optionalOrganisation = organisationRepository.findByCrmOrganisationId(crmOrganisation.getOrganisationId()); |
396 | | - optionalOrganisation.ifPresent(organisation -> organisationRepository.delete(organisation)); |
397 | | - return ResponseEntity.status(204).build(); |
| 397 | + return optionalOrganisation |
| 398 | + .map(organisation -> { |
| 399 | + organisationRepository.delete(organisation); |
| 400 | + return ResponseEntity.ok(Map.of("status", "deleted")); |
| 401 | + }).orElseGet(() -> ResponseEntity.status(HttpStatus.BAD_REQUEST).body( |
| 402 | + Map.of("status", |
| 403 | + String.format("Organisation with crmOrganisationId %s not found", crmOrganisation.getOrganisationId())))); |
398 | 404 | } |
399 | 405 |
|
400 | 406 | @PostMapping(value = "/crm/api/v1/invite/send", produces = MediaType.APPLICATION_JSON_VALUE) |
|
0 commit comments