Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed the Role object and implemented pagination on teachers/all endpoint #60

Merged

Conversation

Eukon05
Copy link
Contributor

@Eukon05 Eukon05 commented Aug 13, 2022

I've removed the Role object entirely and replaced it with a simple element collection in the user object. This is because in our implementation roles couldn't exist without a user anyway, but they would introduce a problem while fetching every user that has a specified role (please refer to a PR with teacher role implementation or ask on Discord). An element collection is, in my opinion, a better solution, because on the DB side, it creates a table that only consists of a user id and a name of the RoleType enum, and in the code we can use something like user.getRoles().contains(RoleType.TEACHER) and it will just work.

I've also implemented pagination and sorting on the api/v1/teachers/all endpoint to minimize DB load and allow for, for example, sorting the teacher list alphabetically by surname, etc.

- Added a method to UserRepository that finds all users with a specified role
# Conflicts:
#	src/main/java/pl/simpleascoding/tutoringplatform/domain/user/Role.java
#	src/main/java/pl/simpleascoding/tutoringplatform/repository/RoleRepository.java
…e removal

- Implemented pagination and sorting on `api/v1/teachers/all` endpoint
@Eukon05 Eukon05 added the feature/ New feature or request label Aug 13, 2022
- Changed the `roles` collection type from List to Set
- Added `@Enumerated` annotation to the `roles` collection

UserDTO:
- The DTO now contains a set of user's roles
@MateuszBednarczyk
Copy link
Contributor

MateuszBednarczyk commented Aug 22, 2022

Looks good to me

# Conflicts:
#	src/main/java/pl/simpleascoding/tutoringplatform/domain/user/Role.java
@dawciobiel dawciobiel merged commit f309071 into Simple-as-Coding:main Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/ New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants