From 45e1a46e392ff31778adf33602ab1fff44bb8c68 Mon Sep 17 00:00:00 2001 From: Daniel Fiala Date: Tue, 25 Jul 2023 23:16:42 +0200 Subject: [PATCH] enhancement(projects): added project data structures --- .../entity/{ => account}/AccountEntity.java | 2 +- .../entity/{ => account}/SessionEntity.java | 4 +-- .../entity/{ => account}/UserEntity.java | 4 +-- .../entity/project/ProjectEntity.java | 29 +++++++++++++++++++ .../mapper/QuarkusMappingConfig.java | 2 +- .../mapper/{ => account}/AccountMapper.java | 7 +++-- .../mapper/{ => account}/SessionMapper.java | 7 +++-- .../mapper/{ => account}/UserMapper.java | 7 +++-- .../model/{ => account}/Account.java | 4 +-- .../model/{ => account}/Session.java | 6 ++-- .../shiperist/model/{ => account}/User.java | 8 ++--- .../model/{ => account}/UserCredentials.java | 2 +- .../dev/shiperist/model/project/Project.java | 4 +++ .../repository/AccountRepository.java | 2 +- .../repository/SessionRepository.java | 2 +- .../shiperist/repository/UserRepository.java | 2 +- .../dev/shiperist/resource/AuthService.java | 3 +- .../shiperist/resource/ProjectResource.java | 4 +++ .../security/CustomIdentityProvider.java | 2 +- .../dev/shiperist/service/AccountService.java | 6 ++-- .../dev/shiperist/service/SessionService.java | 10 +++---- .../dev/shiperist/service/UserService.java | 6 ++-- .../java/dev/shiperist/AuthResourceTest.java | 2 +- 23 files changed, 77 insertions(+), 48 deletions(-) rename server/src/main/java/dev/shiperist/entity/{ => account}/AccountEntity.java (97%) rename server/src/main/java/dev/shiperist/entity/{ => account}/SessionEntity.java (90%) rename server/src/main/java/dev/shiperist/entity/{ => account}/UserEntity.java (92%) create mode 100644 server/src/main/java/dev/shiperist/entity/project/ProjectEntity.java rename server/src/main/java/dev/shiperist/mapper/{ => account}/AccountMapper.java (76%) rename server/src/main/java/dev/shiperist/mapper/{ => account}/SessionMapper.java (76%) rename server/src/main/java/dev/shiperist/mapper/{ => account}/UserMapper.java (76%) rename server/src/main/java/dev/shiperist/model/{ => account}/Account.java (84%) rename server/src/main/java/dev/shiperist/model/{ => account}/Session.java (63%) rename server/src/main/java/dev/shiperist/model/{ => account}/User.java (66%) rename server/src/main/java/dev/shiperist/model/{ => account}/UserCredentials.java (75%) create mode 100644 server/src/main/java/dev/shiperist/model/project/Project.java create mode 100644 server/src/main/java/dev/shiperist/resource/ProjectResource.java diff --git a/server/src/main/java/dev/shiperist/entity/AccountEntity.java b/server/src/main/java/dev/shiperist/entity/account/AccountEntity.java similarity index 97% rename from server/src/main/java/dev/shiperist/entity/AccountEntity.java rename to server/src/main/java/dev/shiperist/entity/account/AccountEntity.java index f143ed6..fefc9ca 100644 --- a/server/src/main/java/dev/shiperist/entity/AccountEntity.java +++ b/server/src/main/java/dev/shiperist/entity/account/AccountEntity.java @@ -1,4 +1,4 @@ -package dev.shiperist.entity; +package dev.shiperist.entity.account; import io.quarkus.hibernate.reactive.panache.PanacheEntityBase; import jakarta.persistence.*; diff --git a/server/src/main/java/dev/shiperist/entity/SessionEntity.java b/server/src/main/java/dev/shiperist/entity/account/SessionEntity.java similarity index 90% rename from server/src/main/java/dev/shiperist/entity/SessionEntity.java rename to server/src/main/java/dev/shiperist/entity/account/SessionEntity.java index c6a5f53..66e1c76 100644 --- a/server/src/main/java/dev/shiperist/entity/SessionEntity.java +++ b/server/src/main/java/dev/shiperist/entity/account/SessionEntity.java @@ -1,12 +1,10 @@ -package dev.shiperist.entity; +package dev.shiperist.entity.account; import io.quarkus.hibernate.reactive.panache.PanacheEntityBase; import jakarta.persistence.*; import lombok.Data; import lombok.EqualsAndHashCode; -import java.sql.Time; -import java.time.LocalDateTime; import java.util.Date; @Data diff --git a/server/src/main/java/dev/shiperist/entity/UserEntity.java b/server/src/main/java/dev/shiperist/entity/account/UserEntity.java similarity index 92% rename from server/src/main/java/dev/shiperist/entity/UserEntity.java rename to server/src/main/java/dev/shiperist/entity/account/UserEntity.java index 4a1ee74..3a115fb 100644 --- a/server/src/main/java/dev/shiperist/entity/UserEntity.java +++ b/server/src/main/java/dev/shiperist/entity/account/UserEntity.java @@ -1,12 +1,10 @@ -package dev.shiperist.entity; +package dev.shiperist.entity.account; import io.quarkus.hibernate.reactive.panache.PanacheEntityBase; import jakarta.persistence.*; import lombok.Data; import lombok.EqualsAndHashCode; -import java.sql.Time; -import java.time.LocalDateTime; import java.util.Date; import java.util.Set; diff --git a/server/src/main/java/dev/shiperist/entity/project/ProjectEntity.java b/server/src/main/java/dev/shiperist/entity/project/ProjectEntity.java new file mode 100644 index 0000000..cfea835 --- /dev/null +++ b/server/src/main/java/dev/shiperist/entity/project/ProjectEntity.java @@ -0,0 +1,29 @@ +package dev.shiperist.entity.project; + +import io.quarkus.hibernate.reactive.panache.PanacheEntityBase; +import jakarta.persistence.*; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@Entity(name = "Account") +@Table(name = "account", schema = "public") +@EqualsAndHashCode(callSuper = true) +public class ProjectEntity extends PanacheEntityBase { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + public Long id; + + @Column(name = "name") + private String name; + + @Column(name = "display_name") + private String displayName; + + @Column(name = "description") + private String description; + + @Column(name = "image") + private String image; +} diff --git a/server/src/main/java/dev/shiperist/mapper/QuarkusMappingConfig.java b/server/src/main/java/dev/shiperist/mapper/QuarkusMappingConfig.java index 66017d8..6e7424a 100644 --- a/server/src/main/java/dev/shiperist/mapper/QuarkusMappingConfig.java +++ b/server/src/main/java/dev/shiperist/mapper/QuarkusMappingConfig.java @@ -3,5 +3,5 @@ import org.mapstruct.MapperConfig; @MapperConfig(componentModel = "jakarta-cdi") -interface QuarkusMappingConfig { +public interface QuarkusMappingConfig { } diff --git a/server/src/main/java/dev/shiperist/mapper/AccountMapper.java b/server/src/main/java/dev/shiperist/mapper/account/AccountMapper.java similarity index 76% rename from server/src/main/java/dev/shiperist/mapper/AccountMapper.java rename to server/src/main/java/dev/shiperist/mapper/account/AccountMapper.java index 0cb7be6..201f6a6 100644 --- a/server/src/main/java/dev/shiperist/mapper/AccountMapper.java +++ b/server/src/main/java/dev/shiperist/mapper/account/AccountMapper.java @@ -1,7 +1,8 @@ -package dev.shiperist.mapper; +package dev.shiperist.mapper.account; -import dev.shiperist.entity.AccountEntity; -import dev.shiperist.model.Account; +import dev.shiperist.entity.account.AccountEntity; +import dev.shiperist.mapper.QuarkusMappingConfig; +import dev.shiperist.model.account.Account; import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.Mapper; import org.mapstruct.MappingTarget; diff --git a/server/src/main/java/dev/shiperist/mapper/SessionMapper.java b/server/src/main/java/dev/shiperist/mapper/account/SessionMapper.java similarity index 76% rename from server/src/main/java/dev/shiperist/mapper/SessionMapper.java rename to server/src/main/java/dev/shiperist/mapper/account/SessionMapper.java index 437efe8..27cf84a 100644 --- a/server/src/main/java/dev/shiperist/mapper/SessionMapper.java +++ b/server/src/main/java/dev/shiperist/mapper/account/SessionMapper.java @@ -1,7 +1,8 @@ -package dev.shiperist.mapper; +package dev.shiperist.mapper.account; -import dev.shiperist.entity.SessionEntity; -import dev.shiperist.model.Session; +import dev.shiperist.entity.account.SessionEntity; +import dev.shiperist.mapper.QuarkusMappingConfig; +import dev.shiperist.model.account.Session; import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.Mapper; import org.mapstruct.MappingTarget; diff --git a/server/src/main/java/dev/shiperist/mapper/UserMapper.java b/server/src/main/java/dev/shiperist/mapper/account/UserMapper.java similarity index 76% rename from server/src/main/java/dev/shiperist/mapper/UserMapper.java rename to server/src/main/java/dev/shiperist/mapper/account/UserMapper.java index 7ac6f53..bae9ea1 100644 --- a/server/src/main/java/dev/shiperist/mapper/UserMapper.java +++ b/server/src/main/java/dev/shiperist/mapper/account/UserMapper.java @@ -1,7 +1,8 @@ -package dev.shiperist.mapper; +package dev.shiperist.mapper.account; -import dev.shiperist.entity.UserEntity; -import dev.shiperist.model.User; +import dev.shiperist.entity.account.UserEntity; +import dev.shiperist.mapper.QuarkusMappingConfig; +import dev.shiperist.model.account.User; import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.Mapper; import org.mapstruct.MappingTarget; diff --git a/server/src/main/java/dev/shiperist/model/Account.java b/server/src/main/java/dev/shiperist/model/account/Account.java similarity index 84% rename from server/src/main/java/dev/shiperist/model/Account.java rename to server/src/main/java/dev/shiperist/model/account/Account.java index 7ff9765..df495e4 100644 --- a/server/src/main/java/dev/shiperist/model/Account.java +++ b/server/src/main/java/dev/shiperist/model/account/Account.java @@ -1,6 +1,6 @@ -package dev.shiperist.model; +package dev.shiperist.model.account; -import dev.shiperist.entity.UserEntity; +import dev.shiperist.entity.account.UserEntity; import lombok.Data; @Data diff --git a/server/src/main/java/dev/shiperist/model/Session.java b/server/src/main/java/dev/shiperist/model/account/Session.java similarity index 63% rename from server/src/main/java/dev/shiperist/model/Session.java rename to server/src/main/java/dev/shiperist/model/account/Session.java index edd5acc..cf0ce3c 100644 --- a/server/src/main/java/dev/shiperist/model/Session.java +++ b/server/src/main/java/dev/shiperist/model/account/Session.java @@ -1,10 +1,8 @@ -package dev.shiperist.model; +package dev.shiperist.model.account; -import dev.shiperist.entity.UserEntity; +import dev.shiperist.entity.account.UserEntity; import lombok.Data; -import java.sql.Time; -import java.time.LocalDateTime; import java.util.Date; @Data diff --git a/server/src/main/java/dev/shiperist/model/User.java b/server/src/main/java/dev/shiperist/model/account/User.java similarity index 66% rename from server/src/main/java/dev/shiperist/model/User.java rename to server/src/main/java/dev/shiperist/model/account/User.java index 458f066..b5fdb69 100644 --- a/server/src/main/java/dev/shiperist/model/User.java +++ b/server/src/main/java/dev/shiperist/model/account/User.java @@ -1,11 +1,9 @@ -package dev.shiperist.model; +package dev.shiperist.model.account; -import dev.shiperist.entity.AccountEntity; -import dev.shiperist.entity.SessionEntity; +import dev.shiperist.entity.account.AccountEntity; +import dev.shiperist.entity.account.SessionEntity; import lombok.Data; -import java.sql.Time; -import java.time.LocalDateTime; import java.util.Date; import java.util.Set; diff --git a/server/src/main/java/dev/shiperist/model/UserCredentials.java b/server/src/main/java/dev/shiperist/model/account/UserCredentials.java similarity index 75% rename from server/src/main/java/dev/shiperist/model/UserCredentials.java rename to server/src/main/java/dev/shiperist/model/account/UserCredentials.java index 4d3691b..812affb 100644 --- a/server/src/main/java/dev/shiperist/model/UserCredentials.java +++ b/server/src/main/java/dev/shiperist/model/account/UserCredentials.java @@ -1,4 +1,4 @@ -package dev.shiperist.model; +package dev.shiperist.model.account; import lombok.Data; diff --git a/server/src/main/java/dev/shiperist/model/project/Project.java b/server/src/main/java/dev/shiperist/model/project/Project.java new file mode 100644 index 0000000..79255c5 --- /dev/null +++ b/server/src/main/java/dev/shiperist/model/project/Project.java @@ -0,0 +1,4 @@ +package dev.shiperist.model.project; + +public class Project { +} diff --git a/server/src/main/java/dev/shiperist/repository/AccountRepository.java b/server/src/main/java/dev/shiperist/repository/AccountRepository.java index cb11fca..e01f155 100644 --- a/server/src/main/java/dev/shiperist/repository/AccountRepository.java +++ b/server/src/main/java/dev/shiperist/repository/AccountRepository.java @@ -1,6 +1,6 @@ package dev.shiperist.repository; -import dev.shiperist.entity.AccountEntity; +import dev.shiperist.entity.account.AccountEntity; import io.quarkus.hibernate.reactive.panache.PanacheRepositoryBase; import io.quarkus.hibernate.reactive.panache.common.WithSession; import jakarta.enterprise.context.ApplicationScoped; diff --git a/server/src/main/java/dev/shiperist/repository/SessionRepository.java b/server/src/main/java/dev/shiperist/repository/SessionRepository.java index 7c3e262..1d2e94a 100644 --- a/server/src/main/java/dev/shiperist/repository/SessionRepository.java +++ b/server/src/main/java/dev/shiperist/repository/SessionRepository.java @@ -1,6 +1,6 @@ package dev.shiperist.repository; -import dev.shiperist.entity.SessionEntity; +import dev.shiperist.entity.account.SessionEntity; import io.quarkus.hibernate.reactive.panache.PanacheRepositoryBase; import io.quarkus.hibernate.reactive.panache.common.WithSession; import io.smallrye.mutiny.Uni; diff --git a/server/src/main/java/dev/shiperist/repository/UserRepository.java b/server/src/main/java/dev/shiperist/repository/UserRepository.java index ff75953..0f527a0 100644 --- a/server/src/main/java/dev/shiperist/repository/UserRepository.java +++ b/server/src/main/java/dev/shiperist/repository/UserRepository.java @@ -1,6 +1,6 @@ package dev.shiperist.repository; -import dev.shiperist.entity.UserEntity; +import dev.shiperist.entity.account.UserEntity; import io.quarkus.hibernate.reactive.panache.PanacheRepositoryBase; import io.quarkus.hibernate.reactive.panache.common.WithSession; import io.smallrye.mutiny.Uni; diff --git a/server/src/main/java/dev/shiperist/resource/AuthService.java b/server/src/main/java/dev/shiperist/resource/AuthService.java index 431f117..014ba7a 100644 --- a/server/src/main/java/dev/shiperist/resource/AuthService.java +++ b/server/src/main/java/dev/shiperist/resource/AuthService.java @@ -1,6 +1,6 @@ package dev.shiperist.resource; -import dev.shiperist.model.User; +import dev.shiperist.model.account.User; import dev.shiperist.service.AccountService; import dev.shiperist.service.SessionService; import dev.shiperist.service.UserService; @@ -11,7 +11,6 @@ import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; -import java.time.LocalDateTime; import java.util.Date; import java.util.Optional; diff --git a/server/src/main/java/dev/shiperist/resource/ProjectResource.java b/server/src/main/java/dev/shiperist/resource/ProjectResource.java new file mode 100644 index 0000000..fcbb412 --- /dev/null +++ b/server/src/main/java/dev/shiperist/resource/ProjectResource.java @@ -0,0 +1,4 @@ +package dev.shiperist.resource; + +public class ProjectResource { +} diff --git a/server/src/main/java/dev/shiperist/security/CustomIdentityProvider.java b/server/src/main/java/dev/shiperist/security/CustomIdentityProvider.java index 89a1f89..6ab3965 100644 --- a/server/src/main/java/dev/shiperist/security/CustomIdentityProvider.java +++ b/server/src/main/java/dev/shiperist/security/CustomIdentityProvider.java @@ -1,6 +1,6 @@ package dev.shiperist.security; -import dev.shiperist.model.User; +import dev.shiperist.model.account.User; import dev.shiperist.service.SessionService; import dev.shiperist.service.UserService; import io.quarkus.security.AuthenticationFailedException; diff --git a/server/src/main/java/dev/shiperist/service/AccountService.java b/server/src/main/java/dev/shiperist/service/AccountService.java index 84f81ac..edf1f57 100644 --- a/server/src/main/java/dev/shiperist/service/AccountService.java +++ b/server/src/main/java/dev/shiperist/service/AccountService.java @@ -1,8 +1,8 @@ package dev.shiperist.service; -import dev.shiperist.entity.AccountEntity; -import dev.shiperist.mapper.AccountMapper; -import dev.shiperist.model.Account; +import dev.shiperist.entity.account.AccountEntity; +import dev.shiperist.mapper.account.AccountMapper; +import dev.shiperist.model.account.Account; import dev.shiperist.repository.AccountRepository; import io.quarkus.hibernate.reactive.panache.common.WithTransaction; import io.smallrye.mutiny.Uni; diff --git a/server/src/main/java/dev/shiperist/service/SessionService.java b/server/src/main/java/dev/shiperist/service/SessionService.java index 66d0dd3..3f45fc3 100644 --- a/server/src/main/java/dev/shiperist/service/SessionService.java +++ b/server/src/main/java/dev/shiperist/service/SessionService.java @@ -1,9 +1,9 @@ package dev.shiperist.service; -import dev.shiperist.entity.SessionEntity; -import dev.shiperist.mapper.SessionMapper; -import dev.shiperist.model.Session; -import dev.shiperist.model.User; +import dev.shiperist.entity.account.SessionEntity; +import dev.shiperist.mapper.account.SessionMapper; +import dev.shiperist.model.account.Session; +import dev.shiperist.model.account.User; import dev.shiperist.repository.SessionRepository; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; @@ -14,9 +14,7 @@ import jakarta.inject.Inject; import java.security.Key; -import java.sql.Time; import java.time.Instant; -import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; import java.util.Date; import java.util.Optional; diff --git a/server/src/main/java/dev/shiperist/service/UserService.java b/server/src/main/java/dev/shiperist/service/UserService.java index 169ff22..ea89458 100644 --- a/server/src/main/java/dev/shiperist/service/UserService.java +++ b/server/src/main/java/dev/shiperist/service/UserService.java @@ -1,9 +1,9 @@ package dev.shiperist.service; import at.favre.lib.crypto.bcrypt.BCrypt; -import dev.shiperist.entity.UserEntity; -import dev.shiperist.mapper.UserMapper; -import dev.shiperist.model.User; +import dev.shiperist.entity.account.UserEntity; +import dev.shiperist.mapper.account.UserMapper; +import dev.shiperist.model.account.User; import dev.shiperist.repository.UserRepository; import io.quarkus.hibernate.reactive.panache.common.WithTransaction; import io.smallrye.mutiny.Uni; diff --git a/server/src/test/java/dev/shiperist/AuthResourceTest.java b/server/src/test/java/dev/shiperist/AuthResourceTest.java index 75c91a7..7d94240 100644 --- a/server/src/test/java/dev/shiperist/AuthResourceTest.java +++ b/server/src/test/java/dev/shiperist/AuthResourceTest.java @@ -1,6 +1,6 @@ package dev.shiperist; -import dev.shiperist.model.User; +import dev.shiperist.model.account.User; import io.quarkus.test.junit.QuarkusTest; import io.restassured.http.ContentType; import org.junit.jupiter.api.Test;