From 1548a62df20b07d4311ff69b481082b24837c2b0 Mon Sep 17 00:00:00 2001 From: Anthony Buisset Date: Mon, 23 Sep 2024 10:30:18 +0200 Subject: [PATCH] add ecosystem id + getters in permission port --- .../marketplace/kernel/model/EcosystemId.java | 23 +++++++++++++++++++ .../kernel/port/output/PermissionPort.java | 9 ++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/main/java/onlydust/com/marketplace/kernel/model/EcosystemId.java diff --git a/src/main/java/onlydust/com/marketplace/kernel/model/EcosystemId.java b/src/main/java/onlydust/com/marketplace/kernel/model/EcosystemId.java new file mode 100644 index 0000000..7c1f4ed --- /dev/null +++ b/src/main/java/onlydust/com/marketplace/kernel/model/EcosystemId.java @@ -0,0 +1,23 @@ +package onlydust.com.marketplace.kernel.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.experimental.SuperBuilder; + +import java.util.UUID; + +@NoArgsConstructor(staticName = "random") +@EqualsAndHashCode(callSuper = true) +@SuperBuilder +public class EcosystemId extends UuidWrapper { + public static EcosystemId of(@NonNull final UUID uuid) { + return EcosystemId.builder().uuid(uuid).build(); + } + + @JsonCreator + public static EcosystemId of(@NonNull final String uuid) { + return EcosystemId.of(UUID.fromString(uuid)); + } +} \ No newline at end of file diff --git a/src/main/java/onlydust/com/marketplace/kernel/port/output/PermissionPort.java b/src/main/java/onlydust/com/marketplace/kernel/port/output/PermissionPort.java index 14e7bae..2519eaa 100644 --- a/src/main/java/onlydust/com/marketplace/kernel/port/output/PermissionPort.java +++ b/src/main/java/onlydust/com/marketplace/kernel/port/output/PermissionPort.java @@ -5,6 +5,7 @@ import onlydust.com.marketplace.kernel.model.SponsorId; import onlydust.com.marketplace.kernel.model.UserId; +import java.util.List; import java.util.Optional; public interface PermissionPort { @@ -24,6 +25,14 @@ public interface PermissionPort { boolean isUserProgramLead(UserId userId, ProgramId programId); + List getLeadPrograms(UserId userId); + + List getLeadEcosystems(UserId userId); + + List getLeadSponsors(UserId userId); + + List getLeadProjects(UserId userId); + default boolean hasUserAccessToProgram(UserId userId, ProgramId programId) { return isUserProgramLead(userId, programId) || isUserSponsorLeadOfProgram(userId, programId); }