-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
041feaa
commit 0718195
Showing
13 changed files
with
139 additions
and
6 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/main/java/fr/sweetiez/api/adapter/delivery/role/RoleEndPoints.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package fr.sweetiez.api.adapter.delivery.role; | ||
|
||
import fr.sweetiez.api.core.roles.Role; | ||
import fr.sweetiez.api.core.roles.RoleService; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
import java.util.Collection; | ||
|
||
public class RoleEndPoints { | ||
|
||
private final RoleService roleService; | ||
|
||
public RoleEndPoints(RoleService roleService) { | ||
this.roleService = roleService; | ||
} | ||
|
||
public ResponseEntity<Collection<Role>> retrieveAll() { | ||
return roleService.retrieveAll(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/fr/sweetiez/api/adapter/repository/roles/RolesAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package fr.sweetiez.api.adapter.repository.roles; | ||
|
||
import fr.sweetiez.api.adapter.shared.RoleMapper; | ||
import fr.sweetiez.api.core.roles.Role; | ||
import fr.sweetiez.api.core.roles.Roles; | ||
import fr.sweetiez.api.infrastructure.repository.accounts.RoleRepository; | ||
|
||
import java.util.Collection; | ||
|
||
public class RolesAdapter implements Roles { | ||
private final RoleRepository repository; | ||
private final RoleMapper mapper; | ||
|
||
public RolesAdapter(RoleRepository roleRepository, RoleMapper roleMapper) { | ||
repository = roleRepository; | ||
mapper = roleMapper; | ||
} | ||
|
||
public Collection<Role> findAll() { | ||
return repository.findAll().stream().map(mapper::toDto).toList(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/java/fr/sweetiez/api/adapter/shared/AccountMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/fr/sweetiez/api/adapter/shared/RoleMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package fr.sweetiez.api.adapter.shared; | ||
|
||
import fr.sweetiez.api.core.roles.Role; | ||
import fr.sweetiez.api.infrastructure.repository.accounts.RoleEntity; | ||
|
||
public class RoleMapper { | ||
|
||
public Role toDto(RoleEntity entity) { | ||
return new Role(entity.getId(), entity.getName()); | ||
} | ||
|
||
public RoleEntity toEntity(Role role) { | ||
return new RoleEntity(role.id(), role.name()); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
src/main/java/fr/sweetiez/api/core/authentication/models/Account.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
src/main/java/fr/sweetiez/api/core/authentication/models/Role.java
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
src/main/java/fr/sweetiez/api/core/authentication/ports/AuthenticationRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package fr.sweetiez.api.core.roles; | ||
|
||
public record Role(Long id, String name) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package fr.sweetiez.api.core.roles; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
|
||
import java.util.Collection; | ||
|
||
public class RoleService { | ||
|
||
private final Roles roles; | ||
|
||
public RoleService(Roles roles) { | ||
this.roles = roles; | ||
} | ||
|
||
public ResponseEntity<Collection<Role>> retrieveAll() { | ||
return ResponseEntity.ok(roles.findAll()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package fr.sweetiez.api.core.roles; | ||
|
||
import java.util.Collection; | ||
|
||
public interface Roles { | ||
Collection<Role> findAll(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/fr/sweetiez/api/infrastructure/delivery/roles/SpringRoleController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package fr.sweetiez.api.infrastructure.delivery.roles; | ||
|
||
import fr.sweetiez.api.adapter.delivery.role.RoleEndPoints; | ||
import fr.sweetiez.api.core.roles.Role; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.Collection; | ||
|
||
@RestController | ||
public class SpringRoleController { | ||
|
||
private final RoleEndPoints roleEndPoints; | ||
|
||
public SpringRoleController(RoleEndPoints roleEndPoints) { | ||
this.roleEndPoints = roleEndPoints; | ||
} | ||
|
||
@GetMapping("/roles") | ||
public ResponseEntity<Collection<Role>> retrieveAll() { | ||
return roleEndPoints.retrieveAll(); | ||
} | ||
} |