I have code block like below and I want to escape from repeated code with Callable design pattern. Is it possible?
@GetMapping("")
public ResponseEntity<?> getUserRules(HttpServletRequest request)
{
String integId = helper.getIntegId(request);
String orgId = helper.getOrgId(request);
return ResponseEntity.ok(service.getUserRules(integId, orgId));
}
@GetMapping("/{ruleId}")
public ResponseEntity<?> getRule(HttpServletRequest request, @PathVariable Long ruleId)
{
String integId = helper.getIntegId(request);
String orgId = helper.getOrgId(request);
return ResponseEntity.ok(service.getRule(integId, orgId, ruleId));
}
@PutMapping("/{ruleId}")
public ResponseEntity<?> updateRule(HttpServletRequest request, @PathVariable Long ruleId,
@RequestBody @Valid Object object)
{
String integId = helper.getIntegId(request);
String orgId = helper.getOrgId(request);
service.updateRule(integId, orgId, ruleId, object);
return ApiResponse.ok();
}
And I want to try execute it with Callable method.
public ResponseEntity execute(HttpServletRequest request)
{
? Actually, I could not find an exact solution here.
}
Aucun commentaire:
Enregistrer un commentaire