Skip to content

Instantly share code, notes, and snippets.

@0001vrn
Created April 11, 2020 10:28
Show Gist options
  • Save 0001vrn/352ca9529401b9842d9fd6aab5cba700 to your computer and use it in GitHub Desktop.
Save 0001vrn/352ca9529401b9842d9fd6aab5cba700 to your computer and use it in GitHub Desktop.
@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