feat: implement final Contact API
This commit is contained in:
@@ -2,6 +2,8 @@ package com.pablotj.portfolio.application.contact;
|
||||
|
||||
import com.pablotj.portfolio.domain.contact.Contact;
|
||||
import com.pablotj.portfolio.domain.contact.port.ContactRepositoryPort;
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public class CreateContactUseCase {
|
||||
|
||||
@@ -14,13 +16,23 @@ public class CreateContactUseCase {
|
||||
public Contact handle(Command cmd) {
|
||||
var contact = Contact.builder()
|
||||
.id(null)
|
||||
.title(cmd.title())
|
||||
.description(cmd.description())
|
||||
.url(cmd.url())
|
||||
.country(cmd.country())
|
||||
.city(cmd.city())
|
||||
.email(cmd.email())
|
||||
.phone(cmd.phone())
|
||||
.linkedin(cmd.linkedin())
|
||||
.github(cmd.github())
|
||||
.build();
|
||||
return repository.save(contact);
|
||||
}
|
||||
|
||||
public record Command(String title, String description, String url) {
|
||||
public record Command(
|
||||
String country,
|
||||
String city,
|
||||
String email,
|
||||
String phone,
|
||||
String linkedin,
|
||||
String github
|
||||
) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user