feat: implement final Resume API
This commit is contained in:
parent
7f12034174
commit
9ff4b21dd9
@ -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,35 @@
|
||||
package com.pablotj.portfolio.application.resume;
|
||||
|
||||
import com.pablotj.portfolio.domain.resume.Resume;
|
||||
import com.pablotj.portfolio.domain.resume.port.ResumeRepositoryPort;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public class CreateResumeUseCase {
|
||||
|
||||
private final ResumeRepositoryPort repository;
|
||||
|
||||
public CreateResumeUseCase(ResumeRepositoryPort repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Resume handle(Command cmd) {
|
||||
var home = Resume.builder()
|
||||
.id(null)
|
||||
.name(cmd.title())
|
||||
.surnames(cmd.surnames())
|
||||
.title(cmd.title())
|
||||
.summary(cmd.summary())
|
||||
.icon(cmd.icon())
|
||||
.build();
|
||||
return repository.save(home);
|
||||
}
|
||||
|
||||
public record Command(
|
||||
String name,
|
||||
String surnames,
|
||||
String title,
|
||||
String summary,
|
||||
String icon
|
||||
) {
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.pablotj.portfolio.application.resume;
|
||||
|
||||
import com.pablotj.portfolio.domain.resume.Resume;
|
||||
import com.pablotj.portfolio.domain.resume.ResumeId;
|
||||
import com.pablotj.portfolio.domain.resume.port.ResumeRepositoryPort;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class GetResumeUseCase {
|
||||
|
||||
private final ResumeRepositoryPort repository;
|
||||
|
||||
public GetResumeUseCase(ResumeRepositoryPort repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public Optional<Resume> byId(Long id) {
|
||||
return repository.findById(new ResumeId(id));
|
||||
}
|
||||
|
||||
public List<Resume> all() {
|
||||
return repository.findAll();
|
||||
}
|
||||
}
|
@ -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.resume;
|
||||
|
||||
import com.pablotj.portfolio.application.resume.CreateResumeUseCase;
|
||||
import com.pablotj.portfolio.application.resume.GetResumeUseCase;
|
||||
import com.pablotj.portfolio.domain.resume.port.ResumeRepositoryPort;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class ResumeApplicationConfig {
|
||||
|
||||
@Bean
|
||||
public GetResumeUseCase getHomeUseCase(ResumeRepositoryPort repo) {
|
||||
return new GetResumeUseCase(repo);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CreateResumeUseCase createHomeUseCase(ResumeRepositoryPort repo) {
|
||||
return new CreateResumeUseCase(repo);
|
||||
}
|
||||
}
|
@ -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,15 @@
|
||||
package com.pablotj.portfolio.domain.resume;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class Resume {
|
||||
private final ResumeId id;
|
||||
private final String name;
|
||||
private final String surnames;
|
||||
private final String title;
|
||||
private final String summary;
|
||||
private final String icon;
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.pablotj.portfolio.domain.resume;
|
||||
|
||||
public record ResumeId(Long value) {
|
||||
public ResumeId {
|
||||
if (value != null && value < 0) throw new IllegalArgumentException("ResumeId must be positive");
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.pablotj.portfolio.domain.resume.port;
|
||||
|
||||
import com.pablotj.portfolio.domain.resume.Resume;
|
||||
import com.pablotj.portfolio.domain.resume.ResumeId;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ResumeRepositoryPort {
|
||||
Resume save(Resume p);
|
||||
|
||||
Optional<Resume> findById(ResumeId id);
|
||||
|
||||
List<Resume> findAll();
|
||||
}
|
@ -12,13 +12,6 @@ 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();
|
||||
}
|
||||
@Mapping(target = "id.value", source = "id")
|
||||
About toDomain(AboutJpaEntity e);
|
||||
}
|
@ -12,13 +12,6 @@ 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();
|
||||
}
|
||||
@Mapping(target = "id.value", source = "id")
|
||||
Certification toDomain(CertificationJpaEntity e);
|
||||
}
|
@ -12,13 +12,6 @@ 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();
|
||||
}
|
||||
@Mapping(target = "id.value", source = "id")
|
||||
Contact toDomain(ContactJpaEntity e);
|
||||
}
|
@ -12,13 +12,6 @@ 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();
|
||||
}
|
||||
@Mapping(target = "id.value", source = "id")
|
||||
Education toDomain(EducationJpaEntity e);
|
||||
}
|
@ -12,13 +12,6 @@ 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();
|
||||
}
|
||||
@Mapping(target = "id.value", source = "id")
|
||||
Experience toDomain(ExperienceJpaEntity e);
|
||||
}
|
@ -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> {
|
||||
}
|
@ -12,13 +12,6 @@ public interface ProjectJpaMapper {
|
||||
@Mapping(target = "id", ignore = true)
|
||||
ProjectJpaEntity toEntity(Project domain);
|
||||
|
||||
default Project toDomain(ProjectJpaEntity e) {
|
||||
if (e == null) return null;
|
||||
return Project.builder()
|
||||
.id(e.getId() == null ? null : new ProjectId(e.getId()))
|
||||
.title(e.getTitle())
|
||||
.description(e.getDescription())
|
||||
.url(e.getUrl())
|
||||
.build();
|
||||
}
|
||||
@Mapping(target = "id.value", source = "id")
|
||||
Project toDomain(ProjectJpaEntity e);
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.resume.adapter;
|
||||
|
||||
import com.pablotj.portfolio.domain.resume.Resume;
|
||||
import com.pablotj.portfolio.domain.resume.ResumeId;
|
||||
import com.pablotj.portfolio.domain.resume.port.ResumeRepositoryPort;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.resume.entity.ResumeJpaEntity;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.resume.mapper.ResumeJpaMapper;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.resume.repo.SpringDataResumeRepository;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class ResumeRepositoryAdapter implements ResumeRepositoryPort {
|
||||
|
||||
private final SpringDataResumeRepository repo;
|
||||
private final ResumeJpaMapper mapper;
|
||||
|
||||
public ResumeRepositoryAdapter(SpringDataResumeRepository repo, ResumeJpaMapper mapper) {
|
||||
this.repo = repo;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resume save(Resume p) {
|
||||
ResumeJpaEntity entity = mapper.toEntity(p);
|
||||
ResumeJpaEntity saved = repo.save(entity);
|
||||
return mapper.toDomain(saved);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Resume> findById(ResumeId id) {
|
||||
return repo.findById(id.value()).map(mapper::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Resume> findAll() {
|
||||
return repo.findAll().stream().map(mapper::toDomain).toList();
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.home.entity;
|
||||
package com.pablotj.portfolio.infrastructure.persistence.resume.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@ -10,20 +10,28 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "homes")
|
||||
@Table(name = "resumes")
|
||||
@Getter
|
||||
@Setter
|
||||
public class HomeJpaEntity {
|
||||
public class ResumeJpaEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "first_name", nullable = false)
|
||||
private String name;
|
||||
|
||||
@Column(name = "last_name", nullable = false)
|
||||
private String surnames;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String title;
|
||||
|
||||
@Column(columnDefinition = "text")
|
||||
private String description;
|
||||
@Column(columnDefinition = "text", nullable = false)
|
||||
private String summary;
|
||||
|
||||
@Column
|
||||
private String icon;
|
||||
|
||||
private String url;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.resume.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.resume.Resume;
|
||||
import com.pablotj.portfolio.domain.resume.ResumeId;
|
||||
import com.pablotj.portfolio.infrastructure.persistence.resume.entity.ResumeJpaEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface ResumeJpaMapper {
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
ResumeJpaEntity toEntity(Resume domain);
|
||||
|
||||
@Mapping(target = "id.value", source = "id")
|
||||
Resume toDomain(ResumeJpaEntity e);
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.pablotj.portfolio.infrastructure.persistence.resume.repo;
|
||||
|
||||
import com.pablotj.portfolio.infrastructure.persistence.resume.entity.ResumeJpaEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SpringDataResumeRepository extends JpaRepository<ResumeJpaEntity, Long> {
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.home.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record CreateHomeRequest(
|
||||
@NotBlank String title,
|
||||
String description,
|
||||
String url
|
||||
) {
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
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) {
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
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);
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.home.controller;
|
||||
package com.pablotj.portfolio.infrastructure.rest.resume.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 com.pablotj.portfolio.application.resume.CreateResumeUseCase;
|
||||
import com.pablotj.portfolio.application.resume.GetResumeUseCase;
|
||||
import com.pablotj.portfolio.infrastructure.rest.resume.dto.ResumeCreateRequest;
|
||||
import com.pablotj.portfolio.infrastructure.rest.resume.dto.ResumeDto;
|
||||
import com.pablotj.portfolio.infrastructure.rest.resume.mapper.ResumeRestMapper;
|
||||
import jakarta.validation.Valid;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
@ -18,25 +18,25 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/homes")
|
||||
public class HomeController {
|
||||
public class ResumeController {
|
||||
|
||||
private final CreateHomeUseCase createUC;
|
||||
private final GetHomeUseCase getUC;
|
||||
private final HomeRestMapper mapper;
|
||||
private final CreateResumeUseCase createUC;
|
||||
private final GetResumeUseCase getUC;
|
||||
private final ResumeRestMapper mapper;
|
||||
|
||||
public HomeController(CreateHomeUseCase createUC, GetHomeUseCase getUC, HomeRestMapper mapper) {
|
||||
public ResumeController(CreateResumeUseCase createUC, GetResumeUseCase getUC, ResumeRestMapper mapper) {
|
||||
this.createUC = createUC;
|
||||
this.getUC = getUC;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<HomeDto> all() {
|
||||
public List<ResumeDto> all() {
|
||||
return getUC.all().stream().map(mapper::toDto).toList();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<HomeDto> byId(@PathVariable Long id) {
|
||||
public ResponseEntity<ResumeDto> byId(@PathVariable Long id) {
|
||||
return getUC.byId(id)
|
||||
.map(mapper::toDto)
|
||||
.map(ResponseEntity::ok)
|
||||
@ -44,11 +44,13 @@ public class HomeController {
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<HomeDto> create(@Valid @RequestBody CreateHomeRequest request) {
|
||||
var cmd = new CreateHomeUseCase.Command(
|
||||
public ResponseEntity<ResumeDto> create(@Valid @RequestBody ResumeCreateRequest request) {
|
||||
var cmd = new CreateResumeUseCase.Command(
|
||||
request.name(),
|
||||
request.surnames(),
|
||||
request.title(),
|
||||
request.description(),
|
||||
request.url()
|
||||
request.summary(),
|
||||
request.icon()
|
||||
);
|
||||
var created = createUC.handle(cmd);
|
||||
var body = mapper.toDto(created);
|
@ -0,0 +1,12 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.resume.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record ResumeCreateRequest(
|
||||
@NotBlank String name,
|
||||
@NotBlank String surnames,
|
||||
@NotBlank String title,
|
||||
@NotBlank String summary,
|
||||
String icon
|
||||
) {
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.resume.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public record ResumeDto(
|
||||
Long id,
|
||||
@NotBlank String name,
|
||||
@NotBlank String surnames,
|
||||
@NotBlank String title,
|
||||
@NotBlank String summary,
|
||||
String icon
|
||||
) {
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.pablotj.portfolio.infrastructure.rest.resume.mapper;
|
||||
|
||||
import com.pablotj.portfolio.domain.resume.Resume;
|
||||
import com.pablotj.portfolio.infrastructure.rest.resume.dto.ResumeDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface ResumeRestMapper {
|
||||
|
||||
@Mapping(target = "id", source = "id.value")
|
||||
ResumeDto toDto(Resume domain);
|
||||
}
|
4
mvnw
vendored
4
mvnw
vendored
@ -23,7 +23,7 @@
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# JAVA_HOME - location of a JDK home dir, required when download maven via java source
|
||||
# JAVA_HOME - location of a JDK resume dir, required when download maven via java source
|
||||
# MVNW_REPOURL - repo url base for downloading maven distribution
|
||||
# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
|
||||
# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
|
||||
@ -134,7 +134,7 @@ maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
|
||||
esac
|
||||
|
||||
# apply MVNW_REPOURL and calculate MAVEN_HOME
|
||||
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||
# maven resume pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||
[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
|
||||
distributionUrlName="${distributionUrl##*/}"
|
||||
distributionUrlNameMain="${distributionUrlName%.*}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user