Created
April 11, 2020 10:28
-
-
Save 0001vrn/352ca9529401b9842d9fd6aab5cba700 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
@RequestMapping("/crq") | |
public class ChgRequestController { | |
private final ChgRequestService chgRequestService; | |
@Autowired | |
public ChgRequestController(ChgRequestService chgRequestService) { | |
this.chgRequestService = chgRequestService; | |
} | |
@GetMapping(value = "/", produces = MediaType.APPLICATION_JSON_VALUE) | |
public List<AppMetaDataResponse> getAll() { | |
return chgRequestService.findAll() | |
.stream() | |
.map(ChgRequest::appMetaDataResponse) | |
.collect(Collectors.toList()); | |
} | |
@PostMapping(value = "/create", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) | |
public UUID createChgRequest(@RequestBody final CreateChgRequest createChgRequest) { | |
return chgRequestService.createChgRequest(createChgRequest.getAppMetadata()); | |
} | |
@GetMapping(value = "/{id}/begin") | |
public void transitionBegin(@PathVariable final UUID id) { | |
chgRequestService.beginChgRequest(id); | |
} | |
@GetMapping(value = "/{id}/done") | |
public void transitionDone(@PathVariable final UUID id) { | |
chgRequestService.doneChgRequest(id); | |
} | |
@GetMapping(value = "/{id}/rollback") | |
public void transitionRollback(@PathVariable final UUID id) { | |
chgRequestService.rollbackChgRequest(id); | |
} | |
@GetMapping(value = "/{id}") | |
public AppMetaDataResponse displayMetadata(@PathVariable final UUID id) { | |
return chgRequestService.findById(id).appMetaDataResponse(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment