Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 102 additions & 96 deletions backend/src/main/java/com/va2es/backend/dto/StudentResponseDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,101 +3,107 @@
import java.time.LocalDate;

public class StudentResponseDTO {
private Long id;
private String fullName;
private LocalDate birthDate;
private String cpf;
private String phone;
private String course;
private Integer currentPeriod;
private String academicSummary;
private String userEmail;

// Construtor
public StudentResponseDTO(Long id, String fullName, LocalDate birthDate, String cpf,
String phone, String course, int currentPeriod,
String academicSummary, String userEmail) {
this.id = id;
this.fullName = fullName;
this.birthDate = birthDate;
this.cpf = cpf;
this.phone = phone;
this.course = course;
this.currentPeriod = currentPeriod;
this.academicSummary = academicSummary;
this.userEmail = userEmail;
}

// Getters e Setters
public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getFullName() {
return fullName;
}

public void setFullName(String fullName) {
this.fullName = fullName;
}

public LocalDate getBirthDate() {
return birthDate;
}

public void setBirthDate(LocalDate birthDate) {
this.birthDate = birthDate;
}

public String getCpf() {
return cpf;
}

public void setCpf(String cpf) {
this.cpf = cpf;
}

public String getPhone() {
return phone;
}

public void setPhone(String phone) {
this.phone = phone;
}

public String getCourse() {
return course;
}

public void setCourse(String course) {
this.course = course;
}

public Integer getCurrentPeriod() {
return currentPeriod;
}

public void setCurrentPeriod(Integer currentPeriod) {
this.currentPeriod = currentPeriod;
}

public String getAcademicSummary() {
return academicSummary;
}

public void setAcademicSummary(String academicSummary) {
this.academicSummary = academicSummary;
}

public String getUserEmail() {
return userEmail;
}

public void setUserEmail(String userEmail) {
this.userEmail = userEmail;
private final Long id;
private final String fullName;
private final LocalDate birthDate;
private final String cpf;
private final String phone;
private final String course;
private final Integer currentPeriod;
private final String academicSummary;
private final String userEmail;

// Construtor é privado e só pode ser chamado pelo Builder
private StudentResponseDTO(Builder builder) {
this.id = builder.id;
this.fullName = builder.fullName;
this.birthDate = builder.birthDate;
this.cpf = builder.cpf;
this.phone = builder.phone;
this.course = builder.course;
this.currentPeriod = builder.currentPeriod;
this.academicSummary = builder.academicSummary;
this.userEmail = builder.userEmail;
}

// Apenas Getters são públicos para manter o objeto imutável após a criação
public Long getId() { return id; }
public String getFullName() { return fullName; }
public LocalDate getBirthDate() { return birthDate; }
public String getCpf() { return cpf; }
public String getPhone() { return phone; }
public String getCourse() { return course; }
public Integer getCurrentPeriod() { return currentPeriod; }
public String getAcademicSummary() { return academicSummary; }
public String getUserEmail() { return userEmail; }

// Método estático para obter uma nova instância do Builder
public static Builder builder() {
return new Builder();
}

// Classe interna estática Builder
public static final class Builder {
private Long id;
private String fullName;
private LocalDate birthDate;
private String cpf;
private String phone;
private String course;
private Integer currentPeriod;
private String academicSummary;
private String userEmail;

private Builder() {}

public Builder id(Long id) {
this.id = id;
return this;
}

public Builder fullName(String fullName) {
this.fullName = fullName;
return this;
}

public Builder birthDate(LocalDate birthDate) {
this.birthDate = birthDate;
return this;
}

public Builder cpf(String cpf) {
this.cpf = cpf;
return this;
}

public Builder phone(String phone) {
this.phone = phone;
return this;
}

public Builder course(String course) {
this.course = course;
return this;
}

public Builder currentPeriod(Integer currentPeriod) {
this.currentPeriod = currentPeriod;
return this;
}

public Builder academicSummary(String academicSummary) {
this.academicSummary = academicSummary;
return this;
}

public Builder userEmail(String userEmail) {
this.userEmail = userEmail;
return this;
}

// Método final que constrói e retorna o objeto StudentResponseDTO
public StudentResponseDTO build() {
return new StudentResponseDTO(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,17 @@ public void applyToVacancy(Long studentId, Long vacancyId) {

// convert objet to dto to request
private StudentResponseDTO toDTO(Student s) {
return new StudentResponseDTO(
s.getId(),
s.getFullName(),
s.getBirthDate(),
s.getCpf(),
s.getPhone(),
s.getCourse(),
s.getCurrentPeriod(),
s.getAcademicSummary(),
s.getUser().getEmail()
);
return StudentResponseDTO.builder()
.id(s.getId())
.fullName(s.getFullName())
.birthDate(s.getBirthDate())
.cpf(s.getCpf())
.phone(s.getPhone())
.course(s.getCourse())
.currentPeriod(s.getCurrentPeriod())
.academicSummary(s.getAcademicSummary())
.userEmail(s.getUser().getEmail())
.build();
}

public List<Application> getApplicationsByStudentId(Long studentId) {
Expand Down