chore: add minimal implementations for all portfolio API endpoints
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.about.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "abouts")
|
||||
@Getter
|
||||
@Setter
|
||||
public class AboutJpaEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String title;
|
||||
|
||||
@Column(columnDefinition = "text")
|
||||
private String description;
|
||||
|
||||
private String url;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
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> {
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.certification.adapter;
|
||||
|
||||
import com.pablotj.portfolio.domain.certification.Certification;
|
||||
import com.pablotj.portfolio.domain.certification.CertificationId;
|
||||
import com.pablotj.portfolio.domain.certification.port.CertificationRepositoryPort;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.certification.entity.CertificationJpaEntity;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.certification.mapper.CertificationJpaMapper;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.certification.repo.SpringDataCertificationRepository;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class CertificationRepositoryAdapter implements CertificationRepositoryPort {
|
||||
|
||||
private final SpringDataCertificationRepository repo;
|
||||
private final CertificationJpaMapper mapper;
|
||||
|
||||
public CertificationRepositoryAdapter(SpringDataCertificationRepository repo, CertificationJpaMapper mapper) {
|
||||
this.repo = repo;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Certification save(Certification p) {
|
||||
CertificationJpaEntity entity = mapper.toEntity(p);
|
||||
CertificationJpaEntity saved = repo.save(entity);
|
||||
return mapper.toDomain(saved);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Certification> findById(CertificationId id) {
|
||||
return repo.findById(id.value()).map(mapper::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Certification> findAll() {
|
||||
return repo.findAll().stream().map(mapper::toDomain).toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.certification.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "certifications")
|
||||
@Getter
|
||||
@Setter
|
||||
public class CertificationJpaEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String title;
|
||||
|
||||
@Column(columnDefinition = "text")
|
||||
private String description;
|
||||
|
||||
private String url;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.certification.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.certification.Certification;
|
||||
import com.pablotj.portfolio.domain.certification.CertificationId;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.certification.entity.CertificationJpaEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface CertificationJpaMapper {
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.certification.repo;
|
||||
|
||||
import com.pablotj.portfolio.infrastructure.persistence.certification.entity.CertificationJpaEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SpringDataCertificationRepository extends JpaRepository<CertificationJpaEntity, Long> {
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.contact.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "contacts")
|
||||
@Getter
|
||||
@Setter
|
||||
public class ContactJpaEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String title;
|
||||
|
||||
@Column(columnDefinition = "text")
|
||||
private String description;
|
||||
|
||||
private String url;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
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> {
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.education.adapter;
|
||||
|
||||
import com.pablotj.portfolio.domain.education.Education;
|
||||
import com.pablotj.portfolio.domain.education.EducationId;
|
||||
import com.pablotj.portfolio.domain.education.port.EducationRepositoryPort;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.education.entity.EducationJpaEntity;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.education.mapper.EducationJpaMapper;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.education.repo.SpringDataEducationRepository;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class EducationRepositoryAdapter implements EducationRepositoryPort {
|
||||
|
||||
private final SpringDataEducationRepository repo;
|
||||
private final EducationJpaMapper mapper;
|
||||
|
||||
public EducationRepositoryAdapter(SpringDataEducationRepository repo, EducationJpaMapper mapper) {
|
||||
this.repo = repo;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Education save(Education p) {
|
||||
EducationJpaEntity entity = mapper.toEntity(p);
|
||||
EducationJpaEntity saved = repo.save(entity);
|
||||
return mapper.toDomain(saved);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Education> findById(EducationId id) {
|
||||
return repo.findById(id.value()).map(mapper::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Education> findAll() {
|
||||
return repo.findAll().stream().map(mapper::toDomain).toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.education.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "educations")
|
||||
@Getter
|
||||
@Setter
|
||||
public class EducationJpaEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String title;
|
||||
|
||||
@Column(columnDefinition = "text")
|
||||
private String description;
|
||||
|
||||
private String url;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.education.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.education.Education;
|
||||
import com.pablotj.portfolio.domain.education.EducationId;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.education.entity.EducationJpaEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface EducationJpaMapper {
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.education.repo;
|
||||
|
||||
import com.pablotj.portfolio.infrastructure.persistence.education.entity.EducationJpaEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SpringDataEducationRepository extends JpaRepository<EducationJpaEntity, Long> {
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.experience.adapter;
|
||||
|
||||
import com.pablotj.portfolio.domain.experience.Experience;
|
||||
import com.pablotj.portfolio.domain.experience.ExperienceId;
|
||||
import com.pablotj.portfolio.domain.experience.port.ExperienceRepositoryPort;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.experience.entity.ExperienceJpaEntity;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.experience.mapper.ExperienceJpaMapper;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.experience.repo.SpringDataExperienceRepository;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class ExperienceRepositoryAdapter implements ExperienceRepositoryPort {
|
||||
|
||||
private final SpringDataExperienceRepository repo;
|
||||
private final ExperienceJpaMapper mapper;
|
||||
|
||||
public ExperienceRepositoryAdapter(SpringDataExperienceRepository repo, ExperienceJpaMapper mapper) {
|
||||
this.repo = repo;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Experience save(Experience p) {
|
||||
ExperienceJpaEntity entity = mapper.toEntity(p);
|
||||
ExperienceJpaEntity saved = repo.save(entity);
|
||||
return mapper.toDomain(saved);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Experience> findById(ExperienceId id) {
|
||||
return repo.findById(id.value()).map(mapper::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Experience> findAll() {
|
||||
return repo.findAll().stream().map(mapper::toDomain).toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.experience.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "experiences")
|
||||
@Getter
|
||||
@Setter
|
||||
public class ExperienceJpaEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String title;
|
||||
|
||||
@Column(columnDefinition = "text")
|
||||
private String description;
|
||||
|
||||
private String url;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.experience.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.experience.Experience;
|
||||
import com.pablotj.portfolio.domain.experience.ExperienceId;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.experience.entity.ExperienceJpaEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface ExperienceJpaMapper {
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.experience.repo;
|
||||
|
||||
import com.pablotj.portfolio.infrastructure.persistence.experience.entity.ExperienceJpaEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SpringDataExperienceRepository extends JpaRepository<ExperienceJpaEntity, Long> {
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.home.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "homes")
|
||||
@Getter
|
||||
@Setter
|
||||
public class HomeJpaEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String title;
|
||||
|
||||
@Column(columnDefinition = "text")
|
||||
private String description;
|
||||
|
||||
private String url;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
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,40 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.skill.adapter;
|
||||
|
||||
import com.pablotj.portfolio.domain.skill.Skill;
|
||||
import com.pablotj.portfolio.domain.skill.SkillId;
|
||||
import com.pablotj.portfolio.domain.skill.port.SkillRepositoryPort;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.skill.entity.SkillJpaEntity;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.skill.mapper.SkillJpaMapper;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.skill.repo.SpringDataSkillRepository;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class SkillRepositoryAdapter implements SkillRepositoryPort {
|
||||
|
||||
private final SpringDataSkillRepository repo;
|
||||
private final SkillJpaMapper mapper;
|
||||
|
||||
public SkillRepositoryAdapter(SpringDataSkillRepository repo, SkillJpaMapper mapper) {
|
||||
this.repo = repo;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Skill save(Skill p) {
|
||||
SkillJpaEntity entity = mapper.toEntity(p);
|
||||
SkillJpaEntity saved = repo.save(entity);
|
||||
return mapper.toDomain(saved);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Skill> findById(SkillId id) {
|
||||
return repo.findById(id.value()).map(mapper::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Skill> findAll() {
|
||||
return repo.findAll().stream().map(mapper::toDomain).toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.skill.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "skills")
|
||||
@Getter
|
||||
@Setter
|
||||
public class SkillJpaEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String title;
|
||||
|
||||
@Column(columnDefinition = "text")
|
||||
private String description;
|
||||
|
||||
private String url;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.skill.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.skill.Skill;
|
||||
import com.pablotj.portfolio.domain.skill.SkillId;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.skill.entity.SkillJpaEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface SkillJpaMapper {
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
SkillJpaEntity toEntity(Skill domain);
|
||||
|
||||
default Skill toDomain(SkillJpaEntity e) {
|
||||
if (e == null) return null;
|
||||
return Skill.builder()
|
||||
.id(e.getId() == null ? null : new SkillId(e.getId()))
|
||||
.title(e.getTitle())
|
||||
.description(e.getDescription())
|
||||
.url(e.getUrl())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.skill.repo;
|
||||
|
||||
import com.pablotj.portfolio.infrastructure.persistence.skill.entity.SkillJpaEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SpringDataSkillRepository extends JpaRepository<SkillJpaEntity, Long> {
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.about.controller;
|
||||
|
||||
import com.pablotj.portfolio.application.about.CreateAboutUseCase;
|
||||
import com.pablotj.portfolio.application.about.GetAboutUseCase;
|
||||
import com.pablotj.portfolio.infrastructure.rest.about.dto.AboutDto;
|
||||
import com.pablotj.portfolio.infrastructure.rest.about.mapper.AboutRestMapper;
|
||||
import jakarta.validation.Valid;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/abouts")
|
||||
public class AboutController {
|
||||
|
||||
private final CreateAboutUseCase createUC;
|
||||
private final GetAboutUseCase getUC;
|
||||
private final AboutRestMapper mapper;
|
||||
|
||||
public AboutController(CreateAboutUseCase createUC, GetAboutUseCase getUC, AboutRestMapper mapper) {
|
||||
this.createUC = createUC;
|
||||
this.getUC = getUC;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<AboutDto> all() {
|
||||
return getUC.all().stream().map(mapper::toDto).toList();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<AboutDto> byId(@PathVariable Long id) {
|
||||
return getUC.byId(id)
|
||||
.map(mapper::toDto)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<AboutDto> create(@Valid @RequestBody com.pablotj.portfolio.infrastructure.rest.about.dto.CreateAboutRequest request) {
|
||||
var cmd = new CreateAboutUseCase.Command(
|
||||
request.title(),
|
||||
request.description(),
|
||||
request.url()
|
||||
);
|
||||
var created = createUC.handle(cmd);
|
||||
var body = mapper.toDto(created);
|
||||
return ResponseEntity.created(URI.create("/api/abouts/" + body.id())).body(body);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.about.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record AboutDto(Long id, @NotBlank String title, String description, String url) {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.about.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record CreateAboutRequest(
|
||||
@NotBlank String title,
|
||||
String description,
|
||||
String url
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.about.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.about.About;
|
||||
import com.pablotj.portfolio.infrastructure.rest.about.dto.AboutDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface AboutRestMapper {
|
||||
|
||||
@Mapping(target = "id", source = "id.value")
|
||||
AboutDto toDto(About domain);
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.api;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping
|
||||
public class ApiRootController {
|
||||
@@ -20,9 +19,14 @@ public class ApiRootController {
|
||||
"doc", "/v3/api-docs",
|
||||
"swagger", "/swagger-ui",
|
||||
"endpoints", List.of(
|
||||
Map.of("path", "/v1/homes", "description", "Manage projects"),
|
||||
Map.of("path", "/v1/certifications", "description", "Manage projects"),
|
||||
Map.of("path", "/v1/projects", "description", "Manage projects"),
|
||||
Map.of("path", "/v1/experience", "description", "Experience entries"),
|
||||
Map.of("path", "/v1/about", "description", "About me")
|
||||
Map.of("path", "/v1/contacts", "description", "Manage projects"),
|
||||
Map.of("path", "/v1/educations", "description", "Manage projects"),
|
||||
Map.of("path", "/v1/experiences", "description", "Manage projects"),
|
||||
Map.of("path", "/v1/projects", "description", "Manage projects"),
|
||||
Map.of("path", "/v1/skills", "description", "Experience entries")
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.certification.controller;
|
||||
|
||||
import com.pablotj.portfolio.application.certification.CreateCertificationUseCase;
|
||||
import com.pablotj.portfolio.application.certification.GetCertificationUseCase;
|
||||
import com.pablotj.portfolio.infrastructure.rest.certification.dto.CertificationDto;
|
||||
import com.pablotj.portfolio.infrastructure.rest.certification.dto.CreateCertificationRequest;
|
||||
import com.pablotj.portfolio.infrastructure.rest.certification.mapper.CertificationRestMapper;
|
||||
import jakarta.validation.Valid;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/certifications")
|
||||
public class CertificationController {
|
||||
|
||||
private final CreateCertificationUseCase createUC;
|
||||
private final GetCertificationUseCase getUC;
|
||||
private final CertificationRestMapper mapper;
|
||||
|
||||
public CertificationController(CreateCertificationUseCase createUC, GetCertificationUseCase getUC, CertificationRestMapper mapper) {
|
||||
this.createUC = createUC;
|
||||
this.getUC = getUC;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<CertificationDto> all() {
|
||||
return getUC.all().stream().map(mapper::toDto).toList();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<CertificationDto> byId(@PathVariable Long id) {
|
||||
return getUC.byId(id)
|
||||
.map(mapper::toDto)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<CertificationDto> create(@Valid @RequestBody CreateCertificationRequest request) {
|
||||
var cmd = new CreateCertificationUseCase.Command(
|
||||
request.title(),
|
||||
request.description(),
|
||||
request.url()
|
||||
);
|
||||
var created = createUC.handle(cmd);
|
||||
var body = mapper.toDto(created);
|
||||
return ResponseEntity.created(URI.create("/api/certifications/" + body.id())).body(body);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.certification.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record CertificationDto(Long id, @NotBlank String title, String description, String url) {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.certification.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record CreateCertificationRequest(
|
||||
@NotBlank String title,
|
||||
String description,
|
||||
String url
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.certification.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.certification.Certification;
|
||||
import com.pablotj.portfolio.infrastructure.rest.certification.dto.CertificationDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface CertificationRestMapper {
|
||||
|
||||
@Mapping(target = "id", source = "id.value")
|
||||
CertificationDto toDto(Certification domain);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.contact.controller;
|
||||
|
||||
import com.pablotj.portfolio.application.contact.CreateContactUseCase;
|
||||
import com.pablotj.portfolio.application.contact.GetContactUseCase;
|
||||
import com.pablotj.portfolio.infrastructure.rest.contact.dto.ContactDto;
|
||||
import com.pablotj.portfolio.infrastructure.rest.contact.dto.CreateContactRequest;
|
||||
import com.pablotj.portfolio.infrastructure.rest.contact.mapper.ContactRestMapper;
|
||||
import jakarta.validation.Valid;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/contacts")
|
||||
public class ContactController {
|
||||
|
||||
private final CreateContactUseCase createUC;
|
||||
private final GetContactUseCase getUC;
|
||||
private final ContactRestMapper mapper;
|
||||
|
||||
public ContactController(CreateContactUseCase createUC, GetContactUseCase getUC, ContactRestMapper mapper) {
|
||||
this.createUC = createUC;
|
||||
this.getUC = getUC;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<ContactDto> all() {
|
||||
return getUC.all().stream().map(mapper::toDto).toList();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<ContactDto> byId(@PathVariable Long id) {
|
||||
return getUC.byId(id)
|
||||
.map(mapper::toDto)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<ContactDto> create(@Valid @RequestBody CreateContactRequest request) {
|
||||
var cmd = new CreateContactUseCase.Command(
|
||||
request.title(),
|
||||
request.description(),
|
||||
request.url()
|
||||
);
|
||||
var created = createUC.handle(cmd);
|
||||
var body = mapper.toDto(created);
|
||||
return ResponseEntity.created(URI.create("/api/contacts/" + body.id())).body(body);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.contact.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record ContactDto(Long id, @NotBlank String title, String description, String url) {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.contact.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record CreateContactRequest(
|
||||
@NotBlank String title,
|
||||
String description,
|
||||
String url
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.contact.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.contact.Contact;
|
||||
import com.pablotj.portfolio.infrastructure.rest.contact.dto.ContactDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface ContactRestMapper {
|
||||
|
||||
@Mapping(target = "id", source = "id.value")
|
||||
ContactDto toDto(Contact domain);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.education.controller;
|
||||
|
||||
import com.pablotj.portfolio.application.education.CreateEducationUseCase;
|
||||
import com.pablotj.portfolio.application.education.GetEducationUseCase;
|
||||
import com.pablotj.portfolio.infrastructure.rest.education.dto.CreateEducationRequest;
|
||||
import com.pablotj.portfolio.infrastructure.rest.education.dto.EducationDto;
|
||||
import com.pablotj.portfolio.infrastructure.rest.education.mapper.EducationRestMapper;
|
||||
import jakarta.validation.Valid;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/educations")
|
||||
public class EducationController {
|
||||
|
||||
private final CreateEducationUseCase createUC;
|
||||
private final GetEducationUseCase getUC;
|
||||
private final EducationRestMapper mapper;
|
||||
|
||||
public EducationController(CreateEducationUseCase createUC, GetEducationUseCase getUC, EducationRestMapper mapper) {
|
||||
this.createUC = createUC;
|
||||
this.getUC = getUC;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<EducationDto> all() {
|
||||
return getUC.all().stream().map(mapper::toDto).toList();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<EducationDto> byId(@PathVariable Long id) {
|
||||
return getUC.byId(id)
|
||||
.map(mapper::toDto)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<EducationDto> create(@Valid @RequestBody CreateEducationRequest request) {
|
||||
var cmd = new CreateEducationUseCase.Command(
|
||||
request.title(),
|
||||
request.description(),
|
||||
request.url()
|
||||
);
|
||||
var created = createUC.handle(cmd);
|
||||
var body = mapper.toDto(created);
|
||||
return ResponseEntity.created(URI.create("/api/educations/" + body.id())).body(body);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.education.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record CreateEducationRequest(
|
||||
@NotBlank String title,
|
||||
String description,
|
||||
String url
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.education.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record EducationDto(Long id, @NotBlank String title, String description, String url) {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.education.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.education.Education;
|
||||
import com.pablotj.portfolio.infrastructure.rest.education.dto.EducationDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface EducationRestMapper {
|
||||
|
||||
@Mapping(target = "id", source = "id.value")
|
||||
EducationDto toDto(Education domain);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.experience.controller;
|
||||
|
||||
import com.pablotj.portfolio.application.experience.CreateExperienceUseCase;
|
||||
import com.pablotj.portfolio.application.experience.GetExperienceUseCase;
|
||||
import com.pablotj.portfolio.infrastructure.rest.experience.dto.CreateExperienceRequest;
|
||||
import com.pablotj.portfolio.infrastructure.rest.experience.dto.ExperienceDto;
|
||||
import com.pablotj.portfolio.infrastructure.rest.experience.mapper.ExperienceRestMapper;
|
||||
import jakarta.validation.Valid;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/experiences")
|
||||
public class ExperienceController {
|
||||
|
||||
private final CreateExperienceUseCase createUC;
|
||||
private final GetExperienceUseCase getUC;
|
||||
private final ExperienceRestMapper mapper;
|
||||
|
||||
public ExperienceController(CreateExperienceUseCase createUC, GetExperienceUseCase getUC, ExperienceRestMapper mapper) {
|
||||
this.createUC = createUC;
|
||||
this.getUC = getUC;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<ExperienceDto> all() {
|
||||
return getUC.all().stream().map(mapper::toDto).toList();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<ExperienceDto> byId(@PathVariable Long id) {
|
||||
return getUC.byId(id)
|
||||
.map(mapper::toDto)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<ExperienceDto> create(@Valid @RequestBody CreateExperienceRequest request) {
|
||||
var cmd = new CreateExperienceUseCase.Command(
|
||||
request.title(),
|
||||
request.description(),
|
||||
request.url()
|
||||
);
|
||||
var created = createUC.handle(cmd);
|
||||
var body = mapper.toDto(created);
|
||||
return ResponseEntity.created(URI.create("/api/experiences/" + body.id())).body(body);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.experience.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record CreateExperienceRequest(
|
||||
@NotBlank String title,
|
||||
String description,
|
||||
String url
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.experience.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record ExperienceDto(Long id, @NotBlank String title, String description, String url) {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.experience.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.experience.Experience;
|
||||
import com.pablotj.portfolio.infrastructure.rest.experience.dto.ExperienceDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface ExperienceRestMapper {
|
||||
|
||||
@Mapping(target = "id", source = "id.value")
|
||||
ExperienceDto toDto(Experience domain);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.home.controller;
|
||||
|
||||
import com.pablotj.portfolio.application.home.CreateHomeUseCase;
|
||||
import com.pablotj.portfolio.application.home.GetHomeUseCase;
|
||||
import com.pablotj.portfolio.infrastructure.rest.home.dto.CreateHomeRequest;
|
||||
import com.pablotj.portfolio.infrastructure.rest.home.dto.HomeDto;
|
||||
import com.pablotj.portfolio.infrastructure.rest.home.mapper.HomeRestMapper;
|
||||
import jakarta.validation.Valid;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/homes")
|
||||
public class HomeController {
|
||||
|
||||
private final CreateHomeUseCase createUC;
|
||||
private final GetHomeUseCase getUC;
|
||||
private final HomeRestMapper mapper;
|
||||
|
||||
public HomeController(CreateHomeUseCase createUC, GetHomeUseCase getUC, HomeRestMapper mapper) {
|
||||
this.createUC = createUC;
|
||||
this.getUC = getUC;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<HomeDto> all() {
|
||||
return getUC.all().stream().map(mapper::toDto).toList();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<HomeDto> byId(@PathVariable Long id) {
|
||||
return getUC.byId(id)
|
||||
.map(mapper::toDto)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<HomeDto> create(@Valid @RequestBody CreateHomeRequest request) {
|
||||
var cmd = new CreateHomeUseCase.Command(
|
||||
request.title(),
|
||||
request.description(),
|
||||
request.url()
|
||||
);
|
||||
var created = createUC.handle(cmd);
|
||||
var body = mapper.toDto(created);
|
||||
return ResponseEntity.created(URI.create("/api/homes/" + body.id())).body(body);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.home.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record CreateHomeRequest(
|
||||
@NotBlank String title,
|
||||
String description,
|
||||
String url
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.home.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record HomeDto(Long id, @NotBlank String title, String description, String url) {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.home.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.home.Home;
|
||||
import com.pablotj.portfolio.infrastructure.rest.home.dto.HomeDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface HomeRestMapper {
|
||||
|
||||
@Mapping(target = "id", source = "id.value")
|
||||
HomeDto toDto(Home domain);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.skill.controller;
|
||||
|
||||
import com.pablotj.portfolio.application.skill.CreateSkillUseCase;
|
||||
import com.pablotj.portfolio.application.skill.GetSkillUseCase;
|
||||
import com.pablotj.portfolio.infrastructure.rest.skill.dto.CreateSkillRequest;
|
||||
import com.pablotj.portfolio.infrastructure.rest.skill.dto.SkillDto;
|
||||
import com.pablotj.portfolio.infrastructure.rest.skill.mapper.SkillRestMapper;
|
||||
import jakarta.validation.Valid;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/skills")
|
||||
public class SkillController {
|
||||
|
||||
private final CreateSkillUseCase createUC;
|
||||
private final GetSkillUseCase getUC;
|
||||
private final SkillRestMapper mapper;
|
||||
|
||||
public SkillController(CreateSkillUseCase createUC, GetSkillUseCase getUC, SkillRestMapper mapper) {
|
||||
this.createUC = createUC;
|
||||
this.getUC = getUC;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<SkillDto> all() {
|
||||
return getUC.all().stream().map(mapper::toDto).toList();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<SkillDto> byId(@PathVariable Long id) {
|
||||
return getUC.byId(id)
|
||||
.map(mapper::toDto)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<SkillDto> create(@Valid @RequestBody CreateSkillRequest request) {
|
||||
var cmd = new CreateSkillUseCase.Command(
|
||||
request.title(),
|
||||
request.description(),
|
||||
request.url()
|
||||
);
|
||||
var created = createUC.handle(cmd);
|
||||
var body = mapper.toDto(created);
|
||||
return ResponseEntity.created(URI.create("/api/skills/" + body.id())).body(body);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.skill.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record CreateSkillRequest(
|
||||
@NotBlank String title,
|
||||
String description,
|
||||
String url
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.skill.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record SkillDto(Long id, @NotBlank String title, String description, String url) {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.skill.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.skill.Skill;
|
||||
import com.pablotj.portfolio.infrastructure.rest.skill.dto.SkillDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface SkillRestMapper {
|
||||
|
||||
@Mapping(target = "id", source = "id.value")
|
||||
SkillDto toDto(Skill domain);
|
||||
}
|
||||
Reference in New Issue
Block a user