backend-api http://jira.mfd.msk:8088/browse/CLS-64 UserSettingsController.java
This commit is contained in:
parent
ef187881b2
commit
ea561b9a85
1 changed files with 12 additions and 3 deletions
|
|
@ -45,12 +45,21 @@ public class UserSettingsController extends AbstractQueueController {
|
||||||
this.userImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_User, User.class);
|
this.userImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_User, User.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "get all user settings.")
|
@ApiOperation(value = "get all user settings for current user.")
|
||||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||||
@RequestMapping(method = RequestMethod.GET)
|
@RequestMapping(method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public CommonGetAllResponse getAll() {
|
public CommonGetAllResponse getAllForCurrentUser() {
|
||||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_UserSettings, UserSettings.class);
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
String username = KeycloakUtils.getUserNameFromAuthentication(authentication);
|
||||||
|
User user = userImdg.getSingleObjectByFieldValues(Map.of("identifier", username));
|
||||||
|
if (user == null) {
|
||||||
|
throw new IllegalStateException("cannot obtain userId from logged in user " + username);
|
||||||
|
}
|
||||||
|
|
||||||
|
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_UserSettings, UserSettings.class,
|
||||||
|
Map.of("userId", user.getId())
|
||||||
|
);
|
||||||
var response = new CommonGetAllResponse();
|
var response = new CommonGetAllResponse();
|
||||||
response.fromEntity(all);
|
response.fromEntity(all);
|
||||||
return response;
|
return response;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue