Closed orubel closed 1 year ago
So ideally:
public User show(HttpServletRequest request, HttpServletResponse response){
String username;
switch(principle.authorities()){
case apiProperties.roles['ROLE_ADMIN']{
username = (Objects.nonNull(this.params.get("id")))?(this.params.get("id")):principle.name().toString();
break;
case apiProperties.roles['ROLE_USER']{
username = principle.name();
break;
}
// User user = userService.findByUsername(params.username);
User user = userService.findByUsername(username);
return apiObjectService.parseReturnObject(Object user,String authority)
}
This would give us a consistent way to check role, create 'apiObject' and do caching at the same time.
EVEN BETTER...add this to 'BeapiRequestHandler' so that we can seamlessly return
response(user);
ok... so VERY redundant with the exception of setting cache; Cache is being set the same CLASS it is read from (for simplicit).
So we don't need to do this. But I'm glad we documented this now.
should consider automating Controller automation for cache and return data off a common object and role:
LinkedHashMap data = ApiObjectService.generateReturnData(Object object, String Role) return data
This simplifies ALL controller generation and aids in automation.
We can more easily template off this and autoGernerate controller as well