0

In our application UI, we're displaying a table of contents that shows user information, i.e. firstName, lastName, email, phoneNumber, role, userType

The last two columns, role and userType are NOT part of the User domain object. They are derived in the serviceImpl class and populated in the userRoleDTO object that is being returned as part of the rest call.

In this case, if I want to sort with User domain parameters, e.g.

.../user-service/api/users-with-roles?size=10&page=0&sort=email,asc

it works fine.

How do I make this work with

user-service/api/users-with-roles?size=10&page=0&sort=role,asc 

or

user-service/api/users-with-roles?size=10&page=0&sort=userType,asc

?

lealceldeiro
  • 14,342
  • 6
  • 49
  • 80
getITdone
  • 95
  • 2
  • 12
  • Where do role and userType come from? and how do you use the sort in your app? – Simon Martinelli Jun 18 '19 at 14:02
  • first we do this: List userRepo.findAll(predicate, pageable); For each user, role and userType are populated using additional logic and are not part of the User domain. Results are placed in UserRoleDTO list. – getITdone Jun 18 '19 at 15:48
  • So no connection between this two tables? Then sorting is only possible after you loaded the data fully – Simon Martinelli Jun 18 '19 at 17:29
  • There is an indirect connection through a given study. A user can belong belong to a study and have roles for that study. This is what I was afraid of. – getITdone Jun 18 '19 at 17:58
  • So could do a join? – Simon Martinelli Jun 18 '19 at 17:59
  • User table has a foreign key in customer_user_context table which has a foreign key in study_environment_role table where the roles are kept. User types are stored in customer_user_context table. – getITdone Jun 19 '19 at 18:44

0 Answers0