Compare commits
12 Commits
7f12034174
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a26b299f2 | |||
| 6b3585da5e | |||
| e7b6712ad3 | |||
| ca41aee64f | |||
| 2959c68bf3 | |||
| 8b2795d518 | |||
| 8ef605ea2d | |||
|
|
ee1820960e | ||
| 1b55d9ab29 | |||
| 9f5306545e | |||
| ab40e9a497 | |||
| 9ff4b21dd9 |
9
.env.example
Normal file
9
.env.example
Normal file
@@ -0,0 +1,9 @@
|
||||
SPRING_PROFILES_ACTIVE=dev
|
||||
|
||||
APP_ALLOWED_ORIGINS='http://127.0.0.1:3000, http://localhost:3000'
|
||||
|
||||
DB_NAME=EXAMPLE_DB
|
||||
DB_USER=EXAMPLE
|
||||
DB_PASSWORD=SECRET
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=5432
|
||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,3 +1,6 @@
|
||||
.idea
|
||||
|
||||
target
|
||||
*.toml
|
||||
*.db
|
||||
target
|
||||
.env
|
||||
Icon?
|
||||
16
Dockerfile
Normal file
16
Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
||||
# Stage 1: Build
|
||||
FROM maven:3.9-eclipse-temurin-21-alpine AS build
|
||||
WORKDIR /app
|
||||
|
||||
# Copiamos todo el proyecto
|
||||
COPY . .
|
||||
|
||||
# Compilamos todo el proyecto (todos los módulos)
|
||||
RUN mvn clean package -DskipTests
|
||||
|
||||
# Stage 2: Run
|
||||
FROM openjdk:21-jdk
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/bootstrap/target/*.jar app.jar
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["java", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005", "-Xmx512m", "-Xms256m", "-jar", "app.jar"]
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.pablotj.portfolio.application.about;
|
||||
|
||||
import com.pablotj.portfolio.domain.about.About;
|
||||
import com.pablotj.portfolio.domain.about.port.AboutRepositoryPort;
|
||||
|
||||
public class CreateAboutUseCase {
|
||||
|
||||
private final AboutRepositoryPort repository;
|
||||
|
||||
public CreateAboutUseCase(AboutRepositoryPort repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public About handle(Command cmd) {
|
||||
var about = About.builder()
|
||||
.id(null)
|
||||
.title(cmd.title())
|
||||
.description(cmd.description())
|
||||
.url(cmd.url())
|
||||
.build();
|
||||
return repository.save(about);
|
||||
}
|
||||
|
||||
public record Command(String title, String description, String url) {
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.pablotj.portfolio.application.about;
|
||||
|
||||
import com.pablotj.portfolio.domain.about.About;
|
||||
import com.pablotj.portfolio.domain.about.AboutId;
|
||||
import com.pablotj.portfolio.domain.about.port.AboutRepositoryPort;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class GetAboutUseCase {
|
||||
|
||||
private final AboutRepositoryPort repository;
|
||||
|
||||
public GetAboutUseCase(AboutRepositoryPort repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Optional<About> byId(Long id) {
|
||||
return repository.findById(new AboutId(id));
|
||||
}
|
||||
|
||||
public List<About> all() {
|
||||
return repository.findAll();
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,33 @@
|
||||
package com.pablotj.portfolio.application.certification;
|
||||
|
||||
import com.pablotj.portfolio.domain.certification.Certification;
|
||||
import com.pablotj.portfolio.domain.certification.CertificationId;
|
||||
import com.pablotj.portfolio.domain.certification.port.CertificationRepositoryPort;
|
||||
|
||||
public class CreateCertificationUseCase {
|
||||
|
||||
private final CertificationRepositoryPort repository;
|
||||
CertificationRepositoryPort repository;
|
||||
|
||||
public CreateCertificationUseCase(CertificationRepositoryPort repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Certification handle(Command cmd) {
|
||||
public Certification handle(Long profileId, Command cmd) {
|
||||
var certification = Certification.builder()
|
||||
.id(null)
|
||||
.title(cmd.title())
|
||||
.description(cmd.description())
|
||||
.url(cmd.url())
|
||||
.id(new CertificationId(profileId))
|
||||
.name(cmd.name())
|
||||
.issuer(cmd.issuer())
|
||||
.date(cmd.date())
|
||||
.credentialId(cmd.credentialId())
|
||||
.build();
|
||||
return repository.save(certification);
|
||||
}
|
||||
|
||||
public record Command(String title, String description, String url) {
|
||||
public record Command(
|
||||
String name,
|
||||
String issuer,
|
||||
String date,
|
||||
String credentialId
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,11 @@ public class GetCertificationUseCase {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Optional<Certification> byId(Long id) {
|
||||
return repository.findById(new CertificationId(id));
|
||||
public Optional<Certification> byId(Long profileId, Long id) {
|
||||
return repository.findById(new CertificationId(profileId, id));
|
||||
}
|
||||
|
||||
public List<Certification> all() {
|
||||
return repository.findAll();
|
||||
public List<Certification> all(Long profileId) {
|
||||
return repository.findAll(profileId);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.pablotj.portfolio.application.contact;
|
||||
|
||||
import com.pablotj.portfolio.domain.contact.Contact;
|
||||
import com.pablotj.portfolio.domain.contact.port.ContactRepositoryPort;
|
||||
|
||||
public class CreateContactUseCase {
|
||||
|
||||
private final ContactRepositoryPort repository;
|
||||
|
||||
public CreateContactUseCase(ContactRepositoryPort repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Contact handle(Command cmd) {
|
||||
var contact = Contact.builder()
|
||||
.id(null)
|
||||
.title(cmd.title())
|
||||
.description(cmd.description())
|
||||
.url(cmd.url())
|
||||
.build();
|
||||
return repository.save(contact);
|
||||
}
|
||||
|
||||
public record Command(String title, String description, String url) {
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.pablotj.portfolio.application.contact;
|
||||
|
||||
import com.pablotj.portfolio.domain.contact.Contact;
|
||||
import com.pablotj.portfolio.domain.contact.ContactId;
|
||||
import com.pablotj.portfolio.domain.contact.port.ContactRepositoryPort;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class GetContactUseCase {
|
||||
|
||||
private final ContactRepositoryPort repository;
|
||||
|
||||
public GetContactUseCase(ContactRepositoryPort repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Optional<Contact> byId(Long id) {
|
||||
return repository.findById(new ContactId(id));
|
||||
}
|
||||
|
||||
public List<Contact> all() {
|
||||
return repository.findAll();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.pablotj.portfolio.application.education;
|
||||
|
||||
import com.pablotj.portfolio.domain.education.Education;
|
||||
import com.pablotj.portfolio.domain.education.EducationId;
|
||||
import com.pablotj.portfolio.domain.education.port.EducationRepositoryPort;
|
||||
|
||||
public class CreateEducationUseCase {
|
||||
@@ -11,16 +12,24 @@ public class CreateEducationUseCase {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Education handle(Command cmd) {
|
||||
public Education handle(Long profileId, Command cmd) {
|
||||
var education = Education.builder()
|
||||
.id(null)
|
||||
.title(cmd.title())
|
||||
.id(new EducationId(profileId))
|
||||
.institution(cmd.institution())
|
||||
.degree(cmd.degree())
|
||||
.period(cmd.period())
|
||||
.grade(cmd.grade())
|
||||
.description(cmd.description())
|
||||
.url(cmd.url())
|
||||
.build();
|
||||
return repository.save(education);
|
||||
}
|
||||
|
||||
public record Command(String title, String description, String url) {
|
||||
public record Command(
|
||||
String institution,
|
||||
String degree,
|
||||
String period,
|
||||
String grade,
|
||||
String description
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,11 @@ public class GetEducationUseCase {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Optional<Education> byId(Long id) {
|
||||
return repository.findById(new EducationId(id));
|
||||
public Optional<Education> byId(Long profileId, Long id) {
|
||||
return repository.findById(new EducationId(profileId, id));
|
||||
}
|
||||
|
||||
public List<Education> all() {
|
||||
return repository.findAll();
|
||||
public List<Education> all(Long profileId) {
|
||||
return repository.findAll(profileId);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
package com.pablotj.portfolio.application.experience;
|
||||
|
||||
import com.pablotj.portfolio.domain.experience.Achievement;
|
||||
import com.pablotj.portfolio.domain.experience.Experience;
|
||||
import com.pablotj.portfolio.domain.experience.ExperienceId;
|
||||
import com.pablotj.portfolio.domain.experience.Technology;
|
||||
import com.pablotj.portfolio.domain.experience.port.ExperienceRepositoryPort;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CreateExperienceUseCase {
|
||||
|
||||
@@ -11,16 +16,30 @@ public class CreateExperienceUseCase {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Experience handle(Command cmd) {
|
||||
public Experience handle(Long profileId, Command cmd) {
|
||||
var experience = Experience.builder()
|
||||
.id(null)
|
||||
.title(cmd.title())
|
||||
.id(new ExperienceId(profileId))
|
||||
.company(cmd.company())
|
||||
.position(cmd.position())
|
||||
.period(cmd.period())
|
||||
.location(cmd.location())
|
||||
.description(cmd.description())
|
||||
.url(cmd.url())
|
||||
.technologies(new ArrayList<>())
|
||||
.achievements(new ArrayList<>())
|
||||
.build();
|
||||
cmd.technologies.forEach(name -> experience.getTechnologies().add(Technology.builder().id(null).name(name).build()));
|
||||
cmd.achievements.forEach(description -> experience.getAchievements().add(Achievement.builder().id(null).description(description).build()));
|
||||
return repository.save(experience);
|
||||
}
|
||||
|
||||
public record Command(String title, String description, String url) {
|
||||
public record Command(
|
||||
String position,
|
||||
String company,
|
||||
String period,
|
||||
String location,
|
||||
String description,
|
||||
List<String> technologies,
|
||||
List<String> achievements
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,11 @@ public class GetExperienceUseCase {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Optional<Experience> byId(Long id) {
|
||||
return repository.findById(new ExperienceId(id));
|
||||
public Optional<Experience> byId(Long profileId, Long id) {
|
||||
return repository.findById(new ExperienceId(profileId, id));
|
||||
}
|
||||
|
||||
public List<Experience> all() {
|
||||
return repository.findAll();
|
||||
public List<Experience> all(Long profileId) {
|
||||
return repository.findAll(profileId);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.pablotj.portfolio.application.home;
|
||||
|
||||
import com.pablotj.portfolio.domain.home.Home;
|
||||
import com.pablotj.portfolio.domain.home.port.HomeRepositoryPort;
|
||||
|
||||
public class CreateHomeUseCase {
|
||||
|
||||
private final HomeRepositoryPort repository;
|
||||
|
||||
public CreateHomeUseCase(HomeRepositoryPort repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Home handle(Command cmd) {
|
||||
var home = Home.builder()
|
||||
.id(null)
|
||||
.title(cmd.title())
|
||||
.description(cmd.description())
|
||||
.url(cmd.url())
|
||||
.build();
|
||||
return repository.save(home);
|
||||
}
|
||||
|
||||
public record Command(String title, String description, String url) {
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.pablotj.portfolio.application.home;
|
||||
|
||||
import com.pablotj.portfolio.domain.home.Home;
|
||||
import com.pablotj.portfolio.domain.home.HomeId;
|
||||
import com.pablotj.portfolio.domain.home.port.HomeRepositoryPort;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class GetHomeUseCase {
|
||||
|
||||
private final HomeRepositoryPort repository;
|
||||
|
||||
public GetHomeUseCase(HomeRepositoryPort repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Optional<Home> byId(Long id) {
|
||||
return repository.findById(new HomeId(id));
|
||||
}
|
||||
|
||||
public List<Home> all() {
|
||||
return repository.findAll();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.pablotj.portfolio.application.profile;
|
||||
|
||||
import com.pablotj.portfolio.domain.profile.Profile;
|
||||
import com.pablotj.portfolio.domain.profile.ProfileSocialLink;
|
||||
import com.pablotj.portfolio.domain.profile.port.ProfileRepositoryPort;
|
||||
import java.util.List;
|
||||
|
||||
public class CreateProfileUseCase {
|
||||
|
||||
private final ProfileRepositoryPort repository;
|
||||
|
||||
public CreateProfileUseCase(ProfileRepositoryPort repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Profile handle(Command cmd) {
|
||||
var personalBuilder = Profile.builder()
|
||||
.id(null)
|
||||
.slug(cmd.slug())
|
||||
.name(cmd.name())
|
||||
.title(cmd.title())
|
||||
.subtitle(cmd.subtitle())
|
||||
.email(cmd.email())
|
||||
.phone(cmd.phone())
|
||||
.location(cmd.location())
|
||||
.avatar(cmd.avatar())
|
||||
.bio(cmd.bio());
|
||||
if (cmd.socialLinks != null) {
|
||||
cmd.socialLinks.forEach(l -> personalBuilder.social(ProfileSocialLink.builder().id(null).platform(l.platform()).url(l.url()).build()));
|
||||
}
|
||||
return repository.save(personalBuilder.build());
|
||||
}
|
||||
|
||||
public record Command(
|
||||
String slug,
|
||||
String name,
|
||||
String title,
|
||||
String subtitle,
|
||||
String email,
|
||||
String phone,
|
||||
String location,
|
||||
String avatar,
|
||||
String bio,
|
||||
List<Link> socialLinks
|
||||
) {
|
||||
}
|
||||
|
||||
public record Link(String platform, String url) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.pablotj.portfolio.application.profile;
|
||||
|
||||
import com.pablotj.portfolio.domain.profile.Profile;
|
||||
import com.pablotj.portfolio.domain.profile.ProfileId;
|
||||
import com.pablotj.portfolio.domain.profile.port.ProfileRepositoryPort;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class GetProfileUseCase {
|
||||
|
||||
private final ProfileRepositoryPort repository;
|
||||
|
||||
public GetProfileUseCase(ProfileRepositoryPort repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Optional<Profile> byId(Long id) {
|
||||
return repository.findById(new ProfileId(id));
|
||||
}
|
||||
|
||||
public Optional<Profile> bySlug(String slug) {
|
||||
return repository.findBySlug(new ProfileId(slug));
|
||||
}
|
||||
|
||||
public List<Profile> all() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,25 +1,44 @@
|
||||
package com.pablotj.portfolio.application.project;
|
||||
|
||||
import com.pablotj.portfolio.domain.project.Project;
|
||||
import com.pablotj.portfolio.domain.project.ProjectFeature;
|
||||
import com.pablotj.portfolio.domain.project.ProjectId;
|
||||
import com.pablotj.portfolio.domain.project.ProjectTechnology;
|
||||
import com.pablotj.portfolio.domain.project.port.ProjectRepositoryPort;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CreateProjectUseCase {
|
||||
|
||||
private final ProjectRepositoryPort repository;
|
||||
|
||||
public record Command(String title, String description, String url) {}
|
||||
|
||||
public CreateProjectUseCase(ProjectRepositoryPort repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Project handle(Command cmd) {
|
||||
public Project handle(Long profileId, Command cmd) {
|
||||
var project = Project.builder()
|
||||
.id(null)
|
||||
.id(new ProjectId(profileId))
|
||||
.title(cmd.title())
|
||||
.description(cmd.description())
|
||||
.url(cmd.url())
|
||||
.image(cmd.image())
|
||||
.technologies(new ArrayList<>())
|
||||
.features(new ArrayList<>())
|
||||
.demo(cmd.demo())
|
||||
.repository(cmd.repository())
|
||||
|
||||
.build();
|
||||
cmd.technologies.forEach(name -> project.getTechnologies().add(ProjectTechnology.builder().id(null).name(name).build()));
|
||||
cmd.features.forEach(description -> project.getFeatures().add(ProjectFeature.builder().id(null).name(description).build()));
|
||||
return repository.save(project);
|
||||
}
|
||||
|
||||
public record Command(String title,
|
||||
String description,
|
||||
String image,
|
||||
List<String> technologies,
|
||||
List<String> features,
|
||||
String demo,
|
||||
String repository) {
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,11 @@ public class GetProjectUseCase {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Optional<Project> byId(Long id) {
|
||||
return repository.findById(new ProjectId(id));
|
||||
public Optional<Project> byId(Long profileId, Long id) {
|
||||
return repository.findById(new ProjectId(profileId, id));
|
||||
}
|
||||
|
||||
public List<Project> all() {
|
||||
return repository.findAll();
|
||||
public List<Project> all(Long profileId) {
|
||||
return repository.findAll(profileId);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.pablotj.portfolio.application.skill;
|
||||
|
||||
import com.pablotj.portfolio.domain.skill.Skill;
|
||||
import com.pablotj.portfolio.domain.skill.SkillGroup;
|
||||
import com.pablotj.portfolio.domain.skill.SkillGroupId;
|
||||
import com.pablotj.portfolio.domain.skill.port.SkillRepositoryPort;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CreateSkillUseCase {
|
||||
|
||||
@@ -11,16 +15,29 @@ public class CreateSkillUseCase {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Skill handle(Command cmd) {
|
||||
var skill = Skill.builder()
|
||||
.id(null)
|
||||
.title(cmd.title())
|
||||
.description(cmd.description())
|
||||
.url(cmd.url())
|
||||
public SkillGroup handle(Long profileId, CommandGroup cmd) {
|
||||
var skillGroup = SkillGroup.builder()
|
||||
.id(new SkillGroupId(profileId))
|
||||
.name(cmd.name())
|
||||
.icon(cmd.icon())
|
||||
.skills(new ArrayList<>())
|
||||
.build();
|
||||
return repository.save(skill);
|
||||
cmd.skills.forEach(s -> skillGroup.getSkills().add(
|
||||
Skill.builder().id(null).name(s.name).level(s.level).years(s.years).build()));
|
||||
return repository.save(skillGroup);
|
||||
}
|
||||
|
||||
public record Command(String title, String description, String url) {
|
||||
public record CommandGroup(
|
||||
String name,
|
||||
String icon,
|
||||
List<CommandSkill> skills
|
||||
) {
|
||||
}
|
||||
|
||||
public record CommandSkill(
|
||||
String name,
|
||||
Integer level,
|
||||
Integer years
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.pablotj.portfolio.application.skill;
|
||||
|
||||
import com.pablotj.portfolio.domain.skill.Skill;
|
||||
import com.pablotj.portfolio.domain.skill.SkillId;
|
||||
import com.pablotj.portfolio.domain.skill.SkillGroup;
|
||||
import com.pablotj.portfolio.domain.skill.SkillGroupId;
|
||||
import com.pablotj.portfolio.domain.skill.port.SkillRepositoryPort;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -14,11 +14,11 @@ public class GetSkillUseCase {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Optional<Skill> byId(Long id) {
|
||||
return repository.findById(new SkillId(id));
|
||||
public Optional<SkillGroup> byId(Long profileId, Long id) {
|
||||
return repository.findById(new SkillGroupId(profileId, id));
|
||||
}
|
||||
|
||||
public List<Skill> all() {
|
||||
return repository.findAll();
|
||||
public List<SkillGroup> all(Long profileId) {
|
||||
return repository.findAll(profileId);
|
||||
}
|
||||
}
|
||||
@@ -51,4 +51,20 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.pablotj.portfolio.bootstrap.about;
|
||||
|
||||
import com.pablotj.portfolio.application.about.CreateAboutUseCase;
|
||||
import com.pablotj.portfolio.application.about.GetAboutUseCase;
|
||||
import com.pablotj.portfolio.domain.about.port.AboutRepositoryPort;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class AboutApplicationConfig {
|
||||
|
||||
@Bean
|
||||
public GetAboutUseCase getAboutUseCase(AboutRepositoryPort repo) {
|
||||
return new GetAboutUseCase(repo);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CreateAboutUseCase createAboutUseCase(AboutRepositoryPort repo) {
|
||||
return new CreateAboutUseCase(repo);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.pablotj.portfolio.bootstrap.contact;
|
||||
|
||||
import com.pablotj.portfolio.application.contact.CreateContactUseCase;
|
||||
import com.pablotj.portfolio.application.contact.GetContactUseCase;
|
||||
import com.pablotj.portfolio.domain.contact.port.ContactRepositoryPort;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class ContactApplicationConfig {
|
||||
|
||||
@Bean
|
||||
public GetContactUseCase getContactUseCase(ContactRepositoryPort repo) {
|
||||
return new GetContactUseCase(repo);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CreateContactUseCase createContactUseCase(ContactRepositoryPort repo) {
|
||||
return new CreateContactUseCase(repo);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.pablotj.portfolio.bootstrap.home;
|
||||
|
||||
import com.pablotj.portfolio.application.home.CreateHomeUseCase;
|
||||
import com.pablotj.portfolio.application.home.GetHomeUseCase;
|
||||
import com.pablotj.portfolio.domain.home.port.HomeRepositoryPort;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class HomeApplicationConfig {
|
||||
|
||||
@Bean
|
||||
public GetHomeUseCase getHomeUseCase(HomeRepositoryPort repo) {
|
||||
return new GetHomeUseCase(repo);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CreateHomeUseCase createHomeUseCase(HomeRepositoryPort repo) {
|
||||
return new CreateHomeUseCase(repo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.pablotj.portfolio.bootstrap.profile;
|
||||
|
||||
import com.pablotj.portfolio.application.profile.CreateProfileUseCase;
|
||||
import com.pablotj.portfolio.application.profile.GetProfileUseCase;
|
||||
import com.pablotj.portfolio.domain.profile.port.ProfileRepositoryPort;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class ProfileApplicationConfig {
|
||||
|
||||
@Bean
|
||||
public GetProfileUseCase getHomeUseCase(ProfileRepositoryPort repo) {
|
||||
return new GetProfileUseCase(repo);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CreateProfileUseCase createHomeUseCase(ProfileRepositoryPort repo) {
|
||||
return new CreateProfileUseCase(repo);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,9 @@
|
||||
info:
|
||||
app:
|
||||
version: @project.version@
|
||||
app:
|
||||
cors:
|
||||
allowed-origins: ${APP_ALLOWED_ORIGINS:http://localhost:8080}
|
||||
spring:
|
||||
application:
|
||||
name: portfolio-api
|
||||
@@ -5,13 +11,26 @@ spring:
|
||||
resources:
|
||||
add-mappings: false
|
||||
|
||||
datasource:
|
||||
url: jdbc:postgresql://${DB_HOST:localhost}:${DB_PORT:5432}/${DB_NAME:portfolio}
|
||||
username: ${DB_USER:postgres}
|
||||
password: ${DB_PASSWORD:postgres}
|
||||
driver-class-name: org.postgresql.Driver
|
||||
hikari:
|
||||
maximum-pool-size: 3
|
||||
minimum-idle: 1
|
||||
idle-timeout: 30000
|
||||
connection-timeout: 10000
|
||||
leak-detection-threshold: 10000
|
||||
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: update
|
||||
ddl-auto: validate
|
||||
properties:
|
||||
hibernate.transaction.jta.platform: org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform
|
||||
hibernate:
|
||||
format_sql: true
|
||||
dialect: org.hibernate.dialect.PostgreSQLDialect
|
||||
show-sql: true
|
||||
|
||||
jackson:
|
||||
@@ -28,37 +47,8 @@ server:
|
||||
port: 8080
|
||||
servlet:
|
||||
context-path: /api
|
||||
forward-headers-strategy: framework
|
||||
|
||||
---
|
||||
|
||||
spring:
|
||||
config:
|
||||
activate:
|
||||
on-profile: default
|
||||
|
||||
datasource:
|
||||
url: jdbc:h2:mem:portfolio_db;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
|
||||
username: sa
|
||||
password:
|
||||
|
||||
h2:
|
||||
console:
|
||||
enabled: true
|
||||
path: /h2-console
|
||||
|
||||
---
|
||||
|
||||
spring:
|
||||
config:
|
||||
activate:
|
||||
on-profile: prod
|
||||
|
||||
datasource:
|
||||
url: jdbc:postgresql://${DB_HOST:localhost}:${DB_PORT:5432}/${DB_NAME:portfolio}
|
||||
username: ${DB_USER:postgres}
|
||||
password: ${DB_PASSWORD:postgres}
|
||||
driver-class-name: org.postgresql.Driver
|
||||
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: validate
|
||||
38
docker-compose.yml
Normal file
38
docker-compose.yml
Normal file
@@ -0,0 +1,38 @@
|
||||
services:
|
||||
db:
|
||||
image: postgres:15-alpine
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_DB: ${DB_NAME}
|
||||
POSTGRES_USER: ${DB_USER}
|
||||
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||
ports:
|
||||
- "5432:5432"
|
||||
networks:
|
||||
network:
|
||||
volumes:
|
||||
- db_data:/var/lib/postgresql/data
|
||||
|
||||
api:
|
||||
build: .
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8095:8080"
|
||||
networks:
|
||||
network:
|
||||
environment:
|
||||
DB_NAME: ${DB_NAME}
|
||||
DB_HOST: ${DB_HOST}
|
||||
DB_PORT: ${DB_PORT}
|
||||
DB_USER: ${DB_USER}
|
||||
DB_PASSWORD: ${DB_PASSWORD}
|
||||
APP_ALLOWED_ORIGINS: ${APP_ALLOWED_ORIGINS}
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
volumes:
|
||||
db_data:
|
||||
|
||||
networks:
|
||||
network:
|
||||
driver: bridge
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.pablotj.portfolio.domain.about;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class About {
|
||||
private final AboutId id;
|
||||
private final String title;
|
||||
private final String description;
|
||||
private final String url;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.pablotj.portfolio.domain.about;
|
||||
|
||||
public record AboutId(Long value) {
|
||||
public AboutId {
|
||||
if (value != null && value < 0) throw new IllegalArgumentException("AboutId must be positive");
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.pablotj.portfolio.domain.about.port;
|
||||
|
||||
import com.pablotj.portfolio.domain.about.About;
|
||||
import com.pablotj.portfolio.domain.about.AboutId;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface AboutRepositoryPort {
|
||||
|
||||
About save(About p);
|
||||
|
||||
Optional<About> findById(AboutId id);
|
||||
|
||||
List<About> findAll();
|
||||
}
|
||||
@@ -7,7 +7,8 @@ import lombok.Getter;
|
||||
@Builder
|
||||
public class Certification {
|
||||
private final CertificationId id;
|
||||
private final String title;
|
||||
private final String description;
|
||||
private final String url;
|
||||
private final String name;
|
||||
private final String issuer;
|
||||
private final String date;
|
||||
private final String credentialId;
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
package com.pablotj.portfolio.domain.certification;
|
||||
|
||||
public record CertificationId(Long value) {
|
||||
public record CertificationId(Long profileId, Long certificationId) {
|
||||
|
||||
public CertificationId(Long profileId) {
|
||||
this(profileId, null);
|
||||
}
|
||||
|
||||
public CertificationId {
|
||||
if (value != null && value < 0) throw new IllegalArgumentException("CertificationId must be positive");
|
||||
if (certificationId != null && certificationId < 0) throw new IllegalArgumentException("CertificationId must be positive");
|
||||
}
|
||||
}
|
||||
@@ -10,5 +10,5 @@ public interface CertificationRepositoryPort {
|
||||
|
||||
Optional<Certification> findById(CertificationId id);
|
||||
|
||||
List<Certification> findAll();
|
||||
List<Certification> findAll(Long profileId);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.pablotj.portfolio.domain.contact;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class Contact {
|
||||
private final ContactId id;
|
||||
private final String title;
|
||||
private final String description;
|
||||
private final String url;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.pablotj.portfolio.domain.contact;
|
||||
|
||||
public record ContactId(Long value) {
|
||||
public ContactId {
|
||||
if (value != null && value < 0) throw new IllegalArgumentException("ContactId must be positive");
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.pablotj.portfolio.domain.contact.port;
|
||||
|
||||
import com.pablotj.portfolio.domain.contact.Contact;
|
||||
import com.pablotj.portfolio.domain.contact.ContactId;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ContactRepositoryPort {
|
||||
Contact save(Contact p);
|
||||
|
||||
Optional<Contact> findById(ContactId id);
|
||||
|
||||
List<Contact> findAll();
|
||||
}
|
||||
@@ -7,7 +7,9 @@ import lombok.Getter;
|
||||
@Builder
|
||||
public class Education {
|
||||
private final EducationId id;
|
||||
private final String title;
|
||||
private final String institution;
|
||||
private final String degree;
|
||||
private final String period;
|
||||
private final String grade;
|
||||
private final String description;
|
||||
private final String url;
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.pablotj.portfolio.domain.education;
|
||||
|
||||
public record EducationId(Long value) {
|
||||
public record EducationId(Long profileId, Long educationId) {
|
||||
public EducationId(Long profileId) {
|
||||
this(profileId, null);
|
||||
}
|
||||
|
||||
public EducationId {
|
||||
if (value != null && value < 0) throw new IllegalArgumentException("EducationId must be positive");
|
||||
if (educationId != null && educationId < 0) throw new IllegalArgumentException("EducationId must be positive");
|
||||
}
|
||||
}
|
||||
@@ -10,5 +10,5 @@ public interface EducationRepositoryPort {
|
||||
|
||||
Optional<Education> findById(EducationId id);
|
||||
|
||||
List<Education> findAll();
|
||||
List<Education> findAll(Long profileId);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.pablotj.portfolio.domain.experience;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class Achievement {
|
||||
private final ArchivementId id;
|
||||
private String description;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.pablotj.portfolio.domain.experience;
|
||||
|
||||
public record ArchivementId(Long value) {
|
||||
public ArchivementId {
|
||||
if (value != null && value < 0) throw new IllegalArgumentException("ArchivementId must be positive");
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.pablotj.portfolio.domain.experience;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -7,7 +8,11 @@ import lombok.Getter;
|
||||
@Builder
|
||||
public class Experience {
|
||||
private final ExperienceId id;
|
||||
private final String title;
|
||||
private final String company;
|
||||
private final String position;
|
||||
private final String period;
|
||||
private final String location;
|
||||
private final String description;
|
||||
private final String url;
|
||||
private final List<Technology> technologies;
|
||||
private final List<Achievement> achievements;
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
package com.pablotj.portfolio.domain.experience;
|
||||
|
||||
public record ExperienceId(Long value) {
|
||||
public record ExperienceId(Long profileId, Long experienceId) {
|
||||
|
||||
public ExperienceId(Long profileId) {
|
||||
this(profileId, null);
|
||||
}
|
||||
|
||||
public ExperienceId {
|
||||
if (value != null && value < 0) throw new IllegalArgumentException("ExperienceId must be positive");
|
||||
if (experienceId != null && experienceId < 0) throw new IllegalArgumentException("ProfileSocialLinkId must be positive");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.pablotj.portfolio.domain.experience;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class Technology {
|
||||
private final TechnologyId id;
|
||||
private String name;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.pablotj.portfolio.domain.experience;
|
||||
|
||||
public record TechnologyId(Long value) {
|
||||
public TechnologyId {
|
||||
if (value != null && value < 0) throw new IllegalArgumentException("TechnologyId must be positive");
|
||||
}
|
||||
}
|
||||
@@ -10,5 +10,6 @@ public interface ExperienceRepositoryPort {
|
||||
|
||||
Optional<Experience> findById(ExperienceId id);
|
||||
|
||||
List<Experience> findAll();
|
||||
List<Experience> findAll(Long profileId);
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.pablotj.portfolio.domain.home;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class Home {
|
||||
private final HomeId id;
|
||||
private final String title;
|
||||
private final String description;
|
||||
private final String url;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.pablotj.portfolio.domain.home;
|
||||
|
||||
public record HomeId(Long value) {
|
||||
public HomeId {
|
||||
if (value != null && value < 0) throw new IllegalArgumentException("HomeId must be positive");
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.pablotj.portfolio.domain.home.port;
|
||||
|
||||
import com.pablotj.portfolio.domain.home.Home;
|
||||
import com.pablotj.portfolio.domain.home.HomeId;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface HomeRepositoryPort {
|
||||
Home save(Home p);
|
||||
|
||||
Optional<Home> findById(HomeId id);
|
||||
|
||||
List<Home> findAll();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.pablotj.portfolio.domain.profile;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Singular;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class Profile {
|
||||
private final ProfileId id;
|
||||
private final String slug;
|
||||
private final String name;
|
||||
private final String title;
|
||||
private final String subtitle;
|
||||
private final String email;
|
||||
private final String phone;
|
||||
private final String location;
|
||||
private final String avatar;
|
||||
private final String bio;
|
||||
@Singular("social")
|
||||
private final List<ProfileSocialLink> social;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.pablotj.portfolio.domain.profile;
|
||||
|
||||
public record ProfileId(Long id, String slug) {
|
||||
|
||||
public ProfileId(Long id) {
|
||||
this(id, null);
|
||||
}
|
||||
|
||||
public ProfileId(String slug) {
|
||||
this(null, slug);
|
||||
}
|
||||
|
||||
public ProfileId {
|
||||
if (id != null && id < 0) throw new IllegalArgumentException("ProfileId must be positive");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.pablotj.portfolio.domain.profile;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class ProfileSocialLink {
|
||||
private final ProfileSocialLinkId id;
|
||||
private final String url;
|
||||
private final String platform;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.pablotj.portfolio.domain.profile;
|
||||
|
||||
public record ProfileSocialLinkId(Long value) {
|
||||
public ProfileSocialLinkId {
|
||||
if (value != null && value < 0) throw new IllegalArgumentException("ProfileSocialLinkId must be positive");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.pablotj.portfolio.domain.profile.port;
|
||||
|
||||
import com.pablotj.portfolio.domain.profile.Profile;
|
||||
import com.pablotj.portfolio.domain.profile.ProfileId;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ProfileRepositoryPort {
|
||||
Profile save(Profile p);
|
||||
|
||||
Optional<Profile> findBySlug(ProfileId id);
|
||||
|
||||
Optional<Profile> findById(ProfileId id);
|
||||
|
||||
List<Profile> findAll();
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.pablotj.portfolio.domain.project;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -9,5 +10,9 @@ public class Project {
|
||||
private final ProjectId id;
|
||||
private final String title;
|
||||
private final String description;
|
||||
private final String url;
|
||||
private final String image;
|
||||
private final List<ProjectTechnology> technologies;
|
||||
private final List<ProjectFeature> features;
|
||||
private final String demo;
|
||||
private final String repository;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.pablotj.portfolio.domain.project;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class ProjectFeature {
|
||||
private final ProjectFeatureId id;
|
||||
private final String name;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.pablotj.portfolio.domain.project;
|
||||
|
||||
public record ProjectFeatureId(Long value) {
|
||||
public ProjectFeatureId {
|
||||
if (value != null && value < 0) throw new IllegalArgumentException("ProjectFeatureId must be positive");
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
package com.pablotj.portfolio.domain.project;
|
||||
|
||||
public record ProjectId(Long value) {
|
||||
public record ProjectId(Long profileId, Long projectId) {
|
||||
|
||||
public ProjectId(Long profileId) {
|
||||
this(profileId, null);
|
||||
}
|
||||
|
||||
public ProjectId {
|
||||
if (value != null && value < 0) throw new IllegalArgumentException("ProjectId must be positive");
|
||||
if (projectId != null && projectId < 0) throw new IllegalArgumentException("ProjectId must be positive");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.pablotj.portfolio.domain.project;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class ProjectTechnology {
|
||||
private final ProjectTechnologyId id;
|
||||
private final String name;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.pablotj.portfolio.domain.project;
|
||||
|
||||
public record ProjectTechnologyId(Long value) {
|
||||
public ProjectTechnologyId {
|
||||
if (value != null && value < 0) throw new IllegalArgumentException("ProjectTechnologyId must be positive");
|
||||
}
|
||||
}
|
||||
@@ -9,5 +9,5 @@ import java.util.Optional;
|
||||
public interface ProjectRepositoryPort {
|
||||
Project save(Project p);
|
||||
Optional<Project> findById(ProjectId id);
|
||||
List<Project> findAll();
|
||||
List<Project> findAll(Long profileId);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import lombok.Getter;
|
||||
@Builder
|
||||
public class Skill {
|
||||
private final SkillId id;
|
||||
private final String title;
|
||||
private final String description;
|
||||
private final String url;
|
||||
private final String name;
|
||||
private final Integer level;
|
||||
private final Integer years;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.pablotj.portfolio.domain.skill;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class SkillGroup {
|
||||
private final SkillGroupId id;
|
||||
private final String name;
|
||||
private final String icon;
|
||||
private final List<Skill> skills;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.pablotj.portfolio.domain.skill;
|
||||
|
||||
public record SkillGroupId(Long profileId, Long skillGroupId) {
|
||||
|
||||
public SkillGroupId(Long profileId) {
|
||||
this(profileId, null);
|
||||
}
|
||||
|
||||
public SkillGroupId {
|
||||
if (skillGroupId != null && skillGroupId < 0) throw new IllegalArgumentException("SkillId must be positive");
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.pablotj.portfolio.domain.skill.port;
|
||||
|
||||
import com.pablotj.portfolio.domain.skill.Skill;
|
||||
import com.pablotj.portfolio.domain.skill.SkillId;
|
||||
import com.pablotj.portfolio.domain.skill.SkillGroup;
|
||||
import com.pablotj.portfolio.domain.skill.SkillGroupId;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface SkillRepositoryPort {
|
||||
Skill save(Skill p);
|
||||
SkillGroup save(SkillGroup p);
|
||||
|
||||
Optional<Skill> findById(SkillId id);
|
||||
Optional<SkillGroup> findById(SkillGroupId id);
|
||||
|
||||
List<Skill> findAll();
|
||||
List<SkillGroup> findAll(Long profileId);
|
||||
}
|
||||
@@ -33,6 +33,11 @@
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MapStruct -->
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.pablotj.portfolio.infrastructure.config;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.CorsConfigurationSource;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
|
||||
@Configuration
|
||||
public class CorsConfig {
|
||||
|
||||
@Value("${app.cors.allowed-origins}")
|
||||
private String allowedOriginsString;
|
||||
|
||||
@Bean
|
||||
public CorsConfigurationSource corsConfigurationSource() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
|
||||
List<String> allowedOrigins = Arrays.asList(allowedOriginsString.split(","));
|
||||
config.setAllowedOriginPatterns(allowedOrigins);
|
||||
|
||||
config.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS"));
|
||||
config.setAllowedHeaders(List.of("*"));
|
||||
config.setAllowCredentials(true);
|
||||
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**", config);
|
||||
|
||||
return source;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.pablotj.portfolio.infrastructure.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.web.cors.CorsConfigurationSource;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
public class SecurityConfig {
|
||||
|
||||
private final CorsConfigurationSource corsConfigurationSource;
|
||||
|
||||
public SecurityConfig(CorsConfigurationSource corsConfigurationSource) {
|
||||
this.corsConfigurationSource = corsConfigurationSource;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||
http
|
||||
.csrf(AbstractHttpConfigurer::disable)
|
||||
.cors(cors -> cors.configurationSource(corsConfigurationSource))
|
||||
.authorizeHttpRequests(auth -> auth
|
||||
.anyRequest().permitAll()
|
||||
);
|
||||
return http.build();
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.about.adapter;
|
||||
|
||||
import com.pablotj.portfolio.domain.about.About;
|
||||
import com.pablotj.portfolio.domain.about.AboutId;
|
||||
import com.pablotj.portfolio.domain.about.port.AboutRepositoryPort;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.about.entity.AboutJpaEntity;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.about.mapper.AboutJpaMapper;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.about.repo.SpringDataAboutRepository;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class AboutRepositoryAdapter implements AboutRepositoryPort {
|
||||
|
||||
private final SpringDataAboutRepository repo;
|
||||
private final AboutJpaMapper mapper;
|
||||
|
||||
public AboutRepositoryAdapter(SpringDataAboutRepository repo, AboutJpaMapper mapper) {
|
||||
this.repo = repo;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public About save(About p) {
|
||||
AboutJpaEntity entity = mapper.toEntity(p);
|
||||
AboutJpaEntity saved = repo.save(entity);
|
||||
return mapper.toDomain(saved);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<About> findById(AboutId id) {
|
||||
return repo.findById(id.value()).map(mapper::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<About> findAll() {
|
||||
return repo.findAll().stream().map(mapper::toDomain).toList();
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.about.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.about.About;
|
||||
import com.pablotj.portfolio.domain.about.AboutId;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.about.entity.AboutJpaEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface AboutJpaMapper {
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
AboutJpaEntity toEntity(About domain);
|
||||
|
||||
default About toDomain(AboutJpaEntity e) {
|
||||
if (e == null) return null;
|
||||
return About.builder()
|
||||
.id(e.getId() == null ? null : new AboutId(e.getId()))
|
||||
.title(e.getTitle())
|
||||
.description(e.getDescription())
|
||||
.url(e.getUrl())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.about.repo;
|
||||
|
||||
import com.pablotj.portfolio.infrastructure.persistence.about.entity.AboutJpaEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SpringDataAboutRepository extends JpaRepository<AboutJpaEntity, Long> {
|
||||
}
|
||||
@@ -30,11 +30,11 @@ public class CertificationRepositoryAdapter implements CertificationRepositoryPo
|
||||
|
||||
@Override
|
||||
public Optional<Certification> findById(CertificationId id) {
|
||||
return repo.findById(id.value()).map(mapper::toDomain);
|
||||
return repo.findByProfileIdAndId(id.profileId(), id.certificationId()).map(mapper::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Certification> findAll() {
|
||||
return repo.findAll().stream().map(mapper::toDomain).toList();
|
||||
public List<Certification> findAll(Long profileId) {
|
||||
return repo.findAllByProfileId(profileId).stream().map(mapper::toDomain).toList();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,20 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.certification.entity;
|
||||
|
||||
import com.pablotj.portfolio.infrastructure.persistence.profile.entity.ProfileJpaEntity;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "certifications")
|
||||
@Table(name = "CERTIFICATION")
|
||||
@Getter
|
||||
@Setter
|
||||
public class CertificationJpaEntity {
|
||||
@@ -19,11 +23,19 @@ public class CertificationJpaEntity {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String title;
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "profile_id", nullable = false)
|
||||
private ProfileJpaEntity profile;
|
||||
|
||||
@Column(columnDefinition = "text")
|
||||
private String description;
|
||||
@Column
|
||||
private String name;
|
||||
|
||||
private String url;
|
||||
@Column
|
||||
private String issuer;
|
||||
|
||||
@Column
|
||||
private String date;
|
||||
|
||||
@Column
|
||||
private String credentialId;
|
||||
}
|
||||
@@ -10,15 +10,9 @@ import org.mapstruct.Mapping;
|
||||
public interface CertificationJpaMapper {
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
@Mapping(target = "profile.id", source = "id.profileId")
|
||||
CertificationJpaEntity toEntity(Certification domain);
|
||||
|
||||
default Certification toDomain(CertificationJpaEntity e) {
|
||||
if (e == null) return null;
|
||||
return Certification.builder()
|
||||
.id(e.getId() == null ? null : new CertificationId(e.getId()))
|
||||
.title(e.getTitle())
|
||||
.description(e.getDescription())
|
||||
.url(e.getUrl())
|
||||
.build();
|
||||
}
|
||||
@Mapping(target = "id", expression = "java(new CertificationId(e.getProfile().getId(), e.getId()))")
|
||||
Certification toDomain(CertificationJpaEntity e);
|
||||
}
|
||||
@@ -1,7 +1,14 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.certification.repo;
|
||||
|
||||
import com.pablotj.portfolio.infrastructure.persistence.certification.entity.CertificationJpaEntity;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SpringDataCertificationRepository extends JpaRepository<CertificationJpaEntity, Long> {
|
||||
|
||||
Optional<CertificationJpaEntity> findByProfileIdAndId(Long profileId, Long id);
|
||||
|
||||
List<CertificationJpaEntity> findAllByProfileId(Long profileId);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.contact.adapter;
|
||||
|
||||
import com.pablotj.portfolio.domain.contact.Contact;
|
||||
import com.pablotj.portfolio.domain.contact.ContactId;
|
||||
import com.pablotj.portfolio.domain.contact.port.ContactRepositoryPort;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.contact.entity.ContactJpaEntity;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.contact.mapper.ContactJpaMapper;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.contact.repo.SpringDataContactRepository;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class ContactRepositoryAdapter implements ContactRepositoryPort {
|
||||
|
||||
private final SpringDataContactRepository repo;
|
||||
private final ContactJpaMapper mapper;
|
||||
|
||||
public ContactRepositoryAdapter(SpringDataContactRepository repo, ContactJpaMapper mapper) {
|
||||
this.repo = repo;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Contact save(Contact p) {
|
||||
ContactJpaEntity entity = mapper.toEntity(p);
|
||||
ContactJpaEntity saved = repo.save(entity);
|
||||
return mapper.toDomain(saved);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Contact> findById(ContactId id) {
|
||||
return repo.findById(id.value()).map(mapper::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Contact> findAll() {
|
||||
return repo.findAll().stream().map(mapper::toDomain).toList();
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.contact.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.contact.Contact;
|
||||
import com.pablotj.portfolio.domain.contact.ContactId;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.contact.entity.ContactJpaEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface ContactJpaMapper {
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
ContactJpaEntity toEntity(Contact domain);
|
||||
|
||||
default Contact toDomain(ContactJpaEntity e) {
|
||||
if (e == null) return null;
|
||||
return Contact.builder()
|
||||
.id(e.getId() == null ? null : new ContactId(e.getId()))
|
||||
.title(e.getTitle())
|
||||
.description(e.getDescription())
|
||||
.url(e.getUrl())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.contact.repo;
|
||||
|
||||
import com.pablotj.portfolio.infrastructure.persistence.contact.entity.ContactJpaEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SpringDataContactRepository extends JpaRepository<ContactJpaEntity, Long> {
|
||||
}
|
||||
@@ -30,11 +30,11 @@ public class EducationRepositoryAdapter implements EducationRepositoryPort {
|
||||
|
||||
@Override
|
||||
public Optional<Education> findById(EducationId id) {
|
||||
return repo.findById(id.value()).map(mapper::toDomain);
|
||||
return repo.findByProfileIdAndId(id.profileId(), id.educationId()).map(mapper::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Education> findAll() {
|
||||
return repo.findAll().stream().map(mapper::toDomain).toList();
|
||||
public List<Education> findAll(Long profileId) {
|
||||
return repo.findAllByProfileId(profileId).stream().map(mapper::toDomain).toList();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,20 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.education.entity;
|
||||
|
||||
import com.pablotj.portfolio.infrastructure.persistence.profile.entity.ProfileJpaEntity;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "educations")
|
||||
@Table(name = "EDUCATION")
|
||||
@Getter
|
||||
@Setter
|
||||
public class EducationJpaEntity {
|
||||
@@ -19,11 +23,22 @@ public class EducationJpaEntity {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String title;
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "profile_id", nullable = false)
|
||||
private ProfileJpaEntity profile;
|
||||
|
||||
@Column
|
||||
private String institution;
|
||||
|
||||
@Column
|
||||
private String degree;
|
||||
|
||||
@Column
|
||||
private String period;
|
||||
|
||||
@Column
|
||||
private String grade;
|
||||
|
||||
@Column(columnDefinition = "text")
|
||||
private String description;
|
||||
|
||||
private String url;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,15 +10,9 @@ import org.mapstruct.Mapping;
|
||||
public interface EducationJpaMapper {
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
@Mapping(target = "profile.id", source = "id.profileId")
|
||||
EducationJpaEntity toEntity(Education domain);
|
||||
|
||||
default Education toDomain(EducationJpaEntity e) {
|
||||
if (e == null) return null;
|
||||
return Education.builder()
|
||||
.id(e.getId() == null ? null : new EducationId(e.getId()))
|
||||
.title(e.getTitle())
|
||||
.description(e.getDescription())
|
||||
.url(e.getUrl())
|
||||
.build();
|
||||
}
|
||||
@Mapping(target = "id", expression = "java(new EducationId(e.getProfile().getId(), e.getId()))")
|
||||
Education toDomain(EducationJpaEntity e);
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.education.repo;
|
||||
|
||||
import com.pablotj.portfolio.infrastructure.persistence.certification.entity.CertificationJpaEntity;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.education.entity.EducationJpaEntity;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SpringDataEducationRepository extends JpaRepository<EducationJpaEntity, Long> {
|
||||
Optional<EducationJpaEntity> findByProfileIdAndId(Long profileId, Long id);
|
||||
|
||||
List<EducationJpaEntity> findAllByProfileId(Long profileId);
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@ public class ExperienceRepositoryAdapter implements ExperienceRepositoryPort {
|
||||
|
||||
@Override
|
||||
public Optional<Experience> findById(ExperienceId id) {
|
||||
return repo.findById(id.value()).map(mapper::toDomain);
|
||||
return repo.findByProfileIdAndId(id.profileId(), id.experienceId()).map(mapper::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Experience> findAll() {
|
||||
return repo.findAll().stream().map(mapper::toDomain).toList();
|
||||
public List<Experience> findAll(Long profileId) {
|
||||
return repo.findAllByProfileId(profileId).stream().map(mapper::toDomain).toList();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.about.entity;
|
||||
package com.pablotj.portfolio.infrastructure.persistence.experience.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -6,24 +6,26 @@ import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "abouts")
|
||||
@Table(name = "EXPERIENCE_ACHIEVEMENT")
|
||||
@Getter
|
||||
@Setter
|
||||
public class AboutJpaEntity {
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@Builder
|
||||
public class ExperienceAchievementJpaEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String title;
|
||||
|
||||
@Column(columnDefinition = "text")
|
||||
private String description;
|
||||
|
||||
private String url;
|
||||
}
|
||||
@@ -1,29 +1,62 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.experience.entity;
|
||||
|
||||
import com.pablotj.portfolio.infrastructure.persistence.profile.entity.ProfileJpaEntity;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
import java.util.List;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "experiences")
|
||||
@Table(name = "EXPERIENCE")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@Builder
|
||||
public class ExperienceJpaEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String title;
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "profile_id", nullable = false)
|
||||
private ProfileJpaEntity profile;
|
||||
|
||||
@Column
|
||||
private String position;
|
||||
|
||||
@Column
|
||||
private String company;
|
||||
|
||||
@Column
|
||||
private String period;
|
||||
|
||||
@Column
|
||||
private String location;
|
||||
|
||||
@Column(columnDefinition = "text")
|
||||
private String description;
|
||||
|
||||
private String url;
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@JoinColumn(name = "EXPERIENCE_ID")
|
||||
private List<ExperienceSkillJpaEntity> technologies;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@JoinColumn(name = "EXPERIENCE_ID")
|
||||
private List<ExperienceAchievementJpaEntity> achievements;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.experience.entity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "EXPERIENCE_SKILL")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@Builder
|
||||
public class ExperienceSkillJpaEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.experience.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.experience.Achievement;
|
||||
import com.pablotj.portfolio.domain.experience.Experience;
|
||||
import com.pablotj.portfolio.domain.experience.ExperienceId;
|
||||
import com.pablotj.portfolio.domain.experience.Technology;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.experience.entity.ExperienceAchievementJpaEntity;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.experience.entity.ExperienceJpaEntity;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.experience.entity.ExperienceSkillJpaEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@@ -10,15 +13,23 @@ import org.mapstruct.Mapping;
|
||||
public interface ExperienceJpaMapper {
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
@Mapping(target = "profile.id", source = "id.profileId")
|
||||
ExperienceJpaEntity toEntity(Experience domain);
|
||||
|
||||
default Experience toDomain(ExperienceJpaEntity e) {
|
||||
if (e == null) return null;
|
||||
return Experience.builder()
|
||||
.id(e.getId() == null ? null : new ExperienceId(e.getId()))
|
||||
.title(e.getTitle())
|
||||
.description(e.getDescription())
|
||||
.url(e.getUrl())
|
||||
.build();
|
||||
}
|
||||
@Mapping(target = "id", expression = "java(new ExperienceId(entity.getProfile().getId(), entity.getId()))")
|
||||
Experience toDomain(ExperienceJpaEntity entity);
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
ExperienceAchievementJpaEntity toEntity(Achievement entity);
|
||||
|
||||
@Mapping(target = "id.value", source = "id")
|
||||
Achievement toDomain(ExperienceAchievementJpaEntity entity);
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
ExperienceSkillJpaEntity toEntity(Technology entity);
|
||||
|
||||
@Mapping(target = "id.value", source = "id")
|
||||
Technology toDomain(ExperienceSkillJpaEntity entity);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.experience.repo;
|
||||
|
||||
import com.pablotj.portfolio.infrastructure.persistence.education.entity.EducationJpaEntity;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.experience.entity.ExperienceJpaEntity;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SpringDataExperienceRepository extends JpaRepository<ExperienceJpaEntity, Long> {
|
||||
Optional<ExperienceJpaEntity> findByProfileIdAndId(Long profileId, Long id);
|
||||
|
||||
List<ExperienceJpaEntity> findAllByProfileId(Long profileId);
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.home.adapter;
|
||||
|
||||
import com.pablotj.portfolio.domain.home.Home;
|
||||
import com.pablotj.portfolio.domain.home.HomeId;
|
||||
import com.pablotj.portfolio.domain.home.port.HomeRepositoryPort;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.home.entity.HomeJpaEntity;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.home.mapper.HomeJpaMapper;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.home.repo.SpringDataHomeRepository;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class HomeRepositoryAdapter implements HomeRepositoryPort {
|
||||
|
||||
private final SpringDataHomeRepository repo;
|
||||
private final HomeJpaMapper mapper;
|
||||
|
||||
public HomeRepositoryAdapter(SpringDataHomeRepository repo, HomeJpaMapper mapper) {
|
||||
this.repo = repo;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Home save(Home p) {
|
||||
HomeJpaEntity entity = mapper.toEntity(p);
|
||||
HomeJpaEntity saved = repo.save(entity);
|
||||
return mapper.toDomain(saved);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Home> findById(HomeId id) {
|
||||
return repo.findById(id.value()).map(mapper::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Home> findAll() {
|
||||
return repo.findAll().stream().map(mapper::toDomain).toList();
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.home.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.home.Home;
|
||||
import com.pablotj.portfolio.domain.home.HomeId;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.home.entity.HomeJpaEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface HomeJpaMapper {
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
HomeJpaEntity toEntity(Home domain);
|
||||
|
||||
default Home toDomain(HomeJpaEntity e) {
|
||||
if (e == null) return null;
|
||||
return Home.builder()
|
||||
.id(e.getId() == null ? null : new HomeId(e.getId()))
|
||||
.title(e.getTitle())
|
||||
.description(e.getDescription())
|
||||
.url(e.getUrl())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.home.repo;
|
||||
|
||||
import com.pablotj.portfolio.infrastructure.persistence.home.entity.HomeJpaEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SpringDataHomeRepository extends JpaRepository<HomeJpaEntity, Long> {
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.profile.adapter;
|
||||
|
||||
import com.pablotj.portfolio.domain.profile.Profile;
|
||||
import com.pablotj.portfolio.domain.profile.ProfileId;
|
||||
import com.pablotj.portfolio.domain.profile.port.ProfileRepositoryPort;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.profile.entity.ProfileJpaEntity;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.profile.entity.ProfileSocialLinkJpaEntity;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.profile.mapper.ProfileJpaMapper;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.profile.repo.SpringDataProfileRepository;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class ProfileRepositoryAdapter implements ProfileRepositoryPort {
|
||||
|
||||
private final SpringDataProfileRepository repo;
|
||||
private final ProfileJpaMapper mapper;
|
||||
|
||||
public ProfileRepositoryAdapter(SpringDataProfileRepository repo, ProfileJpaMapper mapper) {
|
||||
this.repo = repo;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile save(Profile p) {
|
||||
ProfileJpaEntity entity = mapper.toEntity(p);
|
||||
if (entity.getSocial() != null) {
|
||||
for (ProfileSocialLinkJpaEntity socialLinkJpaEntity : entity.getSocial()) {
|
||||
socialLinkJpaEntity.setProfile(entity);
|
||||
}
|
||||
}
|
||||
ProfileJpaEntity saved = repo.save(entity);
|
||||
return mapper.toDomain(saved);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Profile> findBySlug(ProfileId id) {
|
||||
return repo.findBySlug(id.slug()).map(mapper::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Profile> findById(ProfileId id) {
|
||||
return repo.findById(id.id()).map(mapper::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Profile> findAll() {
|
||||
return repo.findAll().stream().map(mapper::toDomain).toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.profile.entity;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "profile")
|
||||
@Getter
|
||||
@Setter
|
||||
public class ProfileJpaEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column
|
||||
private String slug;
|
||||
|
||||
@Column
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
private String title;
|
||||
|
||||
@Column
|
||||
private String subtitle;
|
||||
|
||||
@Column
|
||||
private String email;
|
||||
|
||||
@Column
|
||||
private String phone;
|
||||
|
||||
@Column
|
||||
private String location;
|
||||
|
||||
@Column
|
||||
private String avatar;
|
||||
|
||||
@Column
|
||||
private String bio;
|
||||
|
||||
@OneToMany(mappedBy = "profile", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private List<ProfileSocialLinkJpaEntity> social = new ArrayList<>();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.profile.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "profile_social_link")
|
||||
@Getter
|
||||
@Setter
|
||||
public class ProfileSocialLinkJpaEntity {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "profile_id", nullable = false)
|
||||
private ProfileJpaEntity profile;
|
||||
|
||||
@Column
|
||||
private String url;
|
||||
|
||||
@Column
|
||||
private String platform;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.profile.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.profile.Profile;
|
||||
import com.pablotj.portfolio.domain.profile.ProfileSocialLink;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.profile.entity.ProfileJpaEntity;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.profile.entity.ProfileSocialLinkJpaEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface ProfileJpaMapper {
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
@Mapping(target = "social", source = "social")
|
||||
ProfileJpaEntity toEntity(Profile domain);
|
||||
|
||||
@Mapping(target = "id.id", source = "id")
|
||||
@Mapping(target = "social", source = "social")
|
||||
Profile toDomain(ProfileJpaEntity e);
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
ProfileSocialLinkJpaEntity toEntitySocial(ProfileSocialLink entity);
|
||||
|
||||
@Mapping(target = "id.value", source = "id")
|
||||
ProfileSocialLink toDomainSocial(ProfileSocialLinkJpaEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.profile.repo;
|
||||
|
||||
import com.pablotj.portfolio.infrastructure.persistence.profile.entity.ProfileJpaEntity;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SpringDataProfileRepository extends JpaRepository<ProfileJpaEntity, Long> {
|
||||
|
||||
Optional<ProfileJpaEntity> findBySlug(String slug);
|
||||
}
|
||||
@@ -31,11 +31,11 @@ public class ProjectRepositoryAdapter implements ProjectRepositoryPort {
|
||||
|
||||
@Override
|
||||
public Optional<Project> findById(ProjectId id) {
|
||||
return repo.findById(id.value()).map(mapper::toDomain);
|
||||
return repo.findByProfileIdAndId(id.profileId(), id.projectId()).map(mapper::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Project> findAll() {
|
||||
return repo.findAll().stream().map(mapper::toDomain).toList();
|
||||
public List<Project> findAll(Long profileId) {
|
||||
return repo.findAllByProfileId(profileId).stream().map(mapper::toDomain).toList();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.contact.entity;
|
||||
package com.pablotj.portfolio.infrastructure.persistence.project.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -10,20 +10,16 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "contacts")
|
||||
@Table(name = "PROJECT_FEATURE")
|
||||
@Getter
|
||||
@Setter
|
||||
public class ContactJpaEntity {
|
||||
public class ProjectFeatureJpaEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String title;
|
||||
@Column
|
||||
private String name;
|
||||
|
||||
@Column(columnDefinition = "text")
|
||||
private String description;
|
||||
|
||||
private String url;
|
||||
}
|
||||
@@ -1,11 +1,23 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.project.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.profile.entity.ProfileJpaEntity;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "projects")
|
||||
@Table(name = "PROJECT")
|
||||
@Getter @Setter
|
||||
public class ProjectJpaEntity {
|
||||
|
||||
@@ -13,11 +25,31 @@ public class ProjectJpaEntity {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "profile_id", nullable = false)
|
||||
private ProfileJpaEntity profile;
|
||||
|
||||
@Column
|
||||
private String title;
|
||||
|
||||
@Column(columnDefinition = "text")
|
||||
@Column
|
||||
private String description;
|
||||
|
||||
private String url;
|
||||
@Column
|
||||
private String image;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@JoinColumn(name = "PROJECT_ID")
|
||||
private List<ProjectTechnologyJpaEntity> technologies;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@JoinColumn(name = "PROJECT_ID")
|
||||
private List<ProjectFeatureJpaEntity> features;
|
||||
|
||||
@Column
|
||||
private String demo;
|
||||
|
||||
@Column
|
||||
private String repository;
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user