我有下面的代码块,我想使用Callable设计模式避免重复的代码。有可能吗?
@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();
}
我想尝试使用Callable方法执行它。
public ResponseEntity execute(HttpServletRequest request)
{
? Actually, I could not find an exact solution here.
}