-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
138 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/br/com/zupacademy/fabiano/mercadolivre/dto/PerguntaDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package br.com.zupacademy.fabiano.mercadolivre.dto; | ||
|
||
import br.com.zupacademy.fabiano.mercadolivre.modelo.Pergunta; | ||
import br.com.zupacademy.fabiano.mercadolivre.modelo.Produto; | ||
import br.com.zupacademy.fabiano.mercadolivre.modelo.Usuario; | ||
|
||
import javax.validation.constraints.NotEmpty; | ||
import javax.validation.constraints.NotNull; | ||
|
||
public class PerguntaDto { | ||
@NotNull | ||
@NotEmpty | ||
private String titulo; | ||
|
||
public PerguntaDto() { | ||
} | ||
|
||
public PerguntaDto(String titulo) { | ||
this.titulo = titulo; | ||
} | ||
|
||
public Pergunta converter(Usuario usuario, Produto produto){ | ||
return new Pergunta(titulo, usuario, produto); | ||
} | ||
|
||
public String getTitulo() { | ||
return titulo; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/main/java/br/com/zupacademy/fabiano/mercadolivre/modelo/Pergunta.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package br.com.zupacademy.fabiano.mercadolivre.modelo; | ||
|
||
import org.hibernate.annotations.CreationTimestamp; | ||
|
||
import javax.persistence.*; | ||
import javax.validation.constraints.NotEmpty; | ||
import javax.validation.constraints.NotNull; | ||
import java.time.LocalDateTime; | ||
|
||
@Entity | ||
public class Pergunta { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@NotNull | ||
@NotEmpty | ||
private String titulo; | ||
@NotNull | ||
@ManyToOne | ||
private Usuario usuario; | ||
@NotNull | ||
@ManyToOne | ||
private Produto produto; | ||
@CreationTimestamp | ||
private LocalDateTime createdAt; | ||
|
||
public Pergunta() { | ||
} | ||
|
||
public Pergunta(@NotNull @NotEmpty String titulo, | ||
@NotNull Usuario usuario, | ||
@NotNull Produto produto) { | ||
this.titulo = titulo; | ||
this.usuario = usuario; | ||
this.produto = produto; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public String getTitulo() { | ||
return titulo; | ||
} | ||
|
||
public Usuario getUsuario() { | ||
return usuario; | ||
} | ||
|
||
public Produto getProduto() { | ||
return produto; | ||
} | ||
|
||
public LocalDateTime getCreatedAt() { | ||
return createdAt; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/br/com/zupacademy/fabiano/mercadolivre/repository/PerguntaRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package br.com.zupacademy.fabiano.mercadolivre.repository; | ||
|
||
import br.com.zupacademy.fabiano.mercadolivre.modelo.Pergunta; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface PerguntaRepository extends JpaRepository<Pergunta, Long> { | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/br/com/zupacademy/fabiano/mercadolivre/utils/EnviadorEmail.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package br.com.zupacademy.fabiano.mercadolivre.utils; | ||
|
||
import br.com.zupacademy.fabiano.mercadolivre.modelo.Usuario; | ||
|
||
public interface EnviadorEmail { | ||
void enviaEmail(Usuario usuario); | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/br/com/zupacademy/fabiano/mercadolivre/utils/SendGridFake.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package br.com.zupacademy.fabiano.mercadolivre.utils; | ||
|
||
import br.com.zupacademy.fabiano.mercadolivre.modelo.Usuario; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class SendGridFake implements EnviadorEmail{ | ||
@Override | ||
public void enviaEmail(Usuario usuario) { | ||
/* | ||
Envia email pro login do usuario | ||
* */ | ||
System.out.println("Email enviado para " + usuario.getLogin()); | ||
} | ||
} |