-
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.
feat(user): started adding new user interfaces
- Loading branch information
1 parent
51887f2
commit fce11ce
Showing
12 changed files
with
184 additions
and
108 deletions.
There are no files selected for viewing
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
4 changes: 0 additions & 4 deletions
4
...zenei-user-account/runtime/src/main/java/dev/cloudeko/zenei/user/EmailAddressManager.java
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
...r-account/runtime/src/main/java/dev/cloudeko/zenei/user/EmailAddressReactiveProvider.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,18 @@ | ||
package dev.cloudeko.zenei.user; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
|
||
import java.util.List; | ||
|
||
public interface EmailAddressReactiveProvider<ENTITY extends UserAccount<ID>, ID> { | ||
|
||
Uni<List<EmailAddress>> listEmailAddresses(ID id); | ||
|
||
Uni<EmailAddress> getEmailAddress(ID id, String emailAddress); | ||
|
||
Uni<EmailAddress> addEmailAddress(ID id, EmailAddress emailAddress); | ||
|
||
Uni<EmailAddress> updateEmailAddress(ID id, EmailAddress emailAddress); | ||
|
||
Uni<Void> removeEmailAddress(ID id, String emailAddress); | ||
} |
1 change: 1 addition & 0 deletions
1
.../zenei-user-account/runtime/src/main/java/dev/cloudeko/zenei/user/PhoneNumberManager.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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
package dev.cloudeko.zenei.user; | ||
|
||
public interface PhoneNumberManager { | ||
|
||
} |
50 changes: 20 additions & 30 deletions
50
extensions/zenei-user-account/runtime/src/main/java/dev/cloudeko/zenei/user/UserAccount.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 |
---|---|---|
@@ -1,47 +1,37 @@ | ||
package dev.cloudeko.zenei.user; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
public abstract class UserAccount<ID> { | ||
public abstract interface UserAccount<ID> { | ||
|
||
private ID id; | ||
private LocalDateTime createdAt; | ||
private LocalDateTime updatedAt; | ||
ID getId(); | ||
|
||
public UserAccount() { | ||
} | ||
String getUsername(); | ||
|
||
public UserAccount(ID id) { | ||
this(id, null, null); | ||
} | ||
void setUsername(String username); | ||
|
||
public UserAccount(ID id, LocalDateTime createdAt, LocalDateTime updatedAt) { | ||
this.id = id; | ||
this.createdAt = createdAt; | ||
this.updatedAt = updatedAt; | ||
default EmailAddress getPrimaryEmailAddress() { | ||
return getEmailAddresses().stream().filter(EmailAddress::isPrimaryEmail).findFirst().orElse(null); | ||
} | ||
|
||
public ID getId() { | ||
return id; | ||
} | ||
List<EmailAddress> getEmailAddresses(); | ||
|
||
public void setId(ID id) { | ||
this.id = id; | ||
} | ||
void setEmailAddresses(List<EmailAddress> emailAddresses); | ||
|
||
public LocalDateTime getCreatedAt() { | ||
return createdAt; | ||
default PhoneNumber getPrimaryPhoneNumber() { | ||
return getPhoneNumbers().stream().filter(PhoneNumber::isPrimaryPhoneNumber).findFirst().orElse(null); | ||
} | ||
|
||
public void setCreatedAt(LocalDateTime createdAt) { | ||
this.createdAt = createdAt; | ||
} | ||
List<PhoneNumber> getPhoneNumbers(); | ||
|
||
public LocalDateTime getUpdatedAt() { | ||
return updatedAt; | ||
} | ||
void setPhoneNumbers(List<PhoneNumber> phoneNumbers); | ||
|
||
public void setUpdatedAt(LocalDateTime updatedAt) { | ||
this.updatedAt = updatedAt; | ||
} | ||
LocalDateTime getCreatedAt(); | ||
|
||
void setCreatedAt(LocalDateTime createdAt); | ||
|
||
LocalDateTime getUpdatedAt(); | ||
|
||
void setUpdatedAt(LocalDateTime updatedAt); | ||
} |
63 changes: 0 additions & 63 deletions
63
.../zenei-user-account/runtime/src/main/java/dev/cloudeko/zenei/user/UserAccountManager.java
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
...zenei-user-account/runtime/src/main/java/dev/cloudeko/zenei/user/UserAccountProvider.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,17 @@ | ||
package dev.cloudeko.zenei.user; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface UserAccountProvider<ID> { | ||
|
||
Optional<UserAccount<ID>> findUserByIdentifierBlocking(ID id); | ||
|
||
UserAccount<ID> createUserBlocking(UserAccount<ID> entity); | ||
|
||
UserAccount<ID> updateUserBlocking(UserAccount<ID> entity); | ||
|
||
boolean deleteUserBlocking(ID id); | ||
} |
13 changes: 13 additions & 0 deletions
13
...-user-account/runtime/src/main/java/dev/cloudeko/zenei/user/UserAccountQueryProvider.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,13 @@ | ||
package dev.cloudeko.zenei.user; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface UserAccountQueryProvider<ID> { | ||
|
||
Optional<UserAccount<ID>> findUserByUsernameBlocking(String username); | ||
|
||
List<UserAccount<ID>> listUsersBlocking(); | ||
|
||
List<UserAccount<ID>> listUsersBlocking(int page, int pageSize); | ||
} |
63 changes: 63 additions & 0 deletions
63
...er-account/runtime/src/main/java/dev/cloudeko/zenei/user/UserAccountReactiveProvider.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,63 @@ | ||
package dev.cloudeko.zenei.user; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface UserAccountReactiveProvider<ID> { | ||
|
||
Uni<UserAccount<ID>> findUserByIdentifier(ID id); | ||
|
||
default Optional<UserAccount<ID>> findUserByIdentifierBlocking(ID id) { | ||
return Optional.ofNullable(findUserByIdentifier(id).await().indefinitely()); | ||
} | ||
|
||
Uni<UserAccount<ID>> findUserByPrimaryEmailAddress(String email); | ||
|
||
default Optional<UserAccount<ID>> findUserByPrimaryEmailAddressBlocking(String email) { | ||
return Optional.ofNullable(findUserByPrimaryEmailAddress(email).await().indefinitely()); | ||
} | ||
|
||
Uni<UserAccount<ID>> findUserByPrimaryPhoneNumber(String phoneNumber); | ||
|
||
default Optional<UserAccount<ID>> findUserByPrimaryPhoneNumberBlocking(String phoneNumber) { | ||
return Optional.ofNullable(findUserByPrimaryPhoneNumber(phoneNumber).await().indefinitely()); | ||
} | ||
|
||
Uni<UserAccount<ID>> findUserByUsername(String username); | ||
|
||
default Optional<UserAccount<ID>> findUserByUsernameBlocking(String username) { | ||
return Optional.ofNullable(findUserByUsername(username).await().indefinitely()); | ||
} | ||
|
||
Uni<List<UserAccount<ID>>> listUsers(); | ||
|
||
default List<UserAccount<ID>> listUsersBlocking() { | ||
return listUsers().await().indefinitely(); | ||
} | ||
|
||
Uni<List<UserAccount<ID>>> listUsers(int page, int pageSize); | ||
|
||
default List<UserAccount<ID>> listUsersBlocking(int page, int pageSize) { | ||
return listUsers(page, pageSize).await().indefinitely(); | ||
} | ||
|
||
Uni<UserAccount<ID>> createUser(UserAccount<ID> entity); | ||
|
||
default UserAccount<ID> createUserBlocking(UserAccount<ID> entity) { | ||
return createUser(entity).await().indefinitely(); | ||
} | ||
|
||
Uni<UserAccount<ID>> updateUser(UserAccount<ID> entity); | ||
|
||
default UserAccount<ID> updateUserBlocking(UserAccount<ID> entity) { | ||
return updateUser(entity).await().indefinitely(); | ||
} | ||
|
||
Uni<Boolean> deleteUser(ID id); | ||
|
||
default boolean deleteUserBlocking(ID id) { | ||
return deleteUser(id).await().indefinitely(); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
extensions/zenei-user-account/runtime/src/main/java/dev/cloudeko/zenei/user/UserManager.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,44 @@ | ||
package dev.cloudeko.zenei.user; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface UserManager<ID> extends UserAccountProvider<ID>, UserAccountReactiveProvider<ID> { | ||
|
||
@Override | ||
default Optional<UserAccount<ID>> findUserByIdentifierBlocking(ID id) { | ||
return Optional.ofNullable(findUserByIdentifier(id).await().indefinitely()); | ||
} | ||
|
||
@Override | ||
default Optional<UserAccount<ID>> findUserByUsernameBlocking(String username) { | ||
return Optional.ofNullable(findUserByUsername(username).await().indefinitely()); | ||
} | ||
|
||
@Override | ||
default List<UserAccount<ID>> listUsersBlocking() { | ||
return listUsers().await().indefinitely(); | ||
} | ||
|
||
@Override | ||
default List<UserAccount<ID>> listUsersBlocking(int page, int pageSize) { | ||
return listUsers(page, pageSize).await().indefinitely(); | ||
} | ||
|
||
@Override | ||
default UserAccount<ID> createUserBlocking(UserAccount<ID> entity) { | ||
return createUser(entity).await().indefinitely(); | ||
} | ||
|
||
@Override | ||
default UserAccount<ID> updateUserBlocking(UserAccount<ID> entity) { | ||
return updateUser(entity).await().indefinitely(); | ||
} | ||
|
||
@Override | ||
default boolean deleteUserBlocking(ID id) { | ||
return deleteUser(id).await().indefinitely(); | ||
} | ||
} |
10 changes: 4 additions & 6 deletions
10
...er/runtime/DefaultUserAccountManager.java → ...e/DefaultUserAccountReactiveProvider.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