Skip to content

Commit

Permalink
feat: Add Eduation
Browse files Browse the repository at this point in the history
  • Loading branch information
nanna29 committed Aug 3, 2024
1 parent 7797e7d commit 43795a9
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public class IntroduceResDto {
private String link;
private String updatedAt;
private String timeSinceUpdate;
private List<String> introduceList;
/* private List<String> introduceList;*/
private int state;

@Builder
public IntroduceResDto(Introduce introduce, List<QuestionDto> questionList, List<String> introduceList) {
public IntroduceResDto(Introduce introduce, List<QuestionDto> questionList/*, List<String> introduceList*/) {
this.id = introduce.getId();
this.recruitId=introduce.getRecruit().toModel().getId();
this.memberId=introduce.getMemberId();
Expand All @@ -40,7 +40,7 @@ public IntroduceResDto(Introduce introduce, List<QuestionDto> questionList, List
this.link=introduce.getRecruit().toModel().getLink();
this.updatedAt = formatUpdatedAt(introduce.getUpdatedAt());
this.timeSinceUpdate = calculateTimeUntilDeadline(introduce.getUpdatedAt(), introduce.getRecruit().toModel().getEndTime());
this.introduceList = introduceList;
/*this.introduceList = introduceList;*/
this.state=introduce.getState();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public IntroduceResDto saveIntro(Member requestMember, Long recruitId, Introduce
.build();

introduceRepository.save(introduce);
List<String> introduceList=getIntroduceTitles();
return new IntroduceResDto(introduce, introduceReqDto.getQuestionList(),introduceList);
/*List<String> introduceList=getIntroduceTitles();*/
return new IntroduceResDto(introduce, introduceReqDto.getQuestionList()/*,introduceList*/);
}

@Transactional
Expand All @@ -59,9 +59,9 @@ public IntroduceResDto getIntro(Member requestMember, Long introId){
.map(question -> new QuestionDto(question.getTitle(), question.getContent(), question.getNumber()))
.collect(Collectors.toList());

List<String> introduceList=getIntroduceTitles();
/*List<String> introduceList=getIntroduceTitles();*/

return new IntroduceResDto(introduce, questionList, introduceList);
return new IntroduceResDto(introduce, questionList/*, introduceList*/);
}

@Transactional
Expand Down Expand Up @@ -152,7 +152,7 @@ public Long deleteIntro(Member requestMember, Long introId){
return introduce.getId();
}

@Transactional
/* @Transactional
public List<String> getIntroduceTitles() {
// Fetch all Introduce entities
List<Introduce> introduces = introduceRepository.findAll();
Expand All @@ -163,5 +163,5 @@ public List<String> getIntroduceTitles() {
.filter(Optional::isPresent) // Filter out any empty results
.map(opt -> opt.get().toModel().getTitle()) // Get the title of the Recruit
.collect(Collectors.toList()); // Collect titles into a List
}
}*/
}
56 changes: 56 additions & 0 deletions src/main/java/umc/kkijuk/server/record/domain/Education.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package umc.kkijuk.server.record.domain;

import jakarta.persistence.*;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import umc.kkijuk.server.career.domain.base.BaseEntity;
import umc.kkijuk.server.introduce.domain.Introduce;

import java.time.LocalDateTime;

@Entity
@Table(name="education")
@Getter
@NoArgsConstructor
public class Education extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne
@JoinColumn(name = "record_id", nullable = false)
private Record record;

private String category;
private String schoolName;
private String major;
private String state;
private LocalDateTime admissionDate;
private LocalDateTime graduationDate;

@Builder
public Education(String category, String schoolName, String major
, String state, LocalDateTime admissionDate, LocalDateTime graduationDate) {
this.category = category;
this.schoolName = schoolName;
this.major = major;
this.state = state;
this.admissionDate = admissionDate;
this.graduationDate = graduationDate;
}

public void setRecord(Record record) {
this.record = record;
}

public void update(String category, String schoolName, String major
, String state, LocalDateTime admissionDate, LocalDateTime graduationDate) {
this.category = category;
this.schoolName = schoolName;
this.major = major;
this.state = state;
this.admissionDate = admissionDate;
this.graduationDate = graduationDate;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package umc.kkijuk.server.record.domain;

import org.springframework.data.jpa.repository.JpaRepository;

public interface EducationRepository extends JpaRepository<Education, Long> {
}
22 changes: 14 additions & 8 deletions src/main/java/umc/kkijuk/server/record/domain/Record.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import umc.kkijuk.server.career.domain.Career;
import umc.kkijuk.server.career.domain.base.BaseEntity;
import umc.kkijuk.server.introduce.domain.Question;
import umc.kkijuk.server.member.domain.Member;
import umc.kkijuk.server.recruit.infrastructure.RecruitEntity;

import java.util.ArrayList;
import java.util.List;

@Entity
Expand All @@ -27,14 +21,26 @@ public class Record extends BaseEntity {
private Long memberId;

private String address;

private String profileImageUrl;

@NotNull
@OneToMany(mappedBy = "record", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Education> educations;

@Builder
public Record(Long memberId, String address, String profileImageUrl) {
public Record(Long memberId, String address, String profileImageUrl, List<Education> educations) {
this.memberId = memberId;
this.address = address;
this.profileImageUrl = profileImageUrl;
this.educations = educations;
setEducations(educations);
}

public void setEducations(List<Education> educations) {
this.educations= educations;
for (Education education : educations) {
education.setRecord(this);
}
}

public void update(String address, String profileImageUrl) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package umc.kkijuk.server.record.domain;

import org.springframework.data.jpa.repository.JpaRepository;
import umc.kkijuk.server.introduce.domain.MasterIntroduce;
import umc.kkijuk.server.record.domain.Record;

import java.util.List;
import java.util.Optional;

public interface RecordRepository extends JpaRepository<Record, Long> {

Expand Down
32 changes: 32 additions & 0 deletions src/main/java/umc/kkijuk/server/record/dto/EducationDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package umc.kkijuk.server.record.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import umc.kkijuk.server.introduce.domain.Question;
import umc.kkijuk.server.record.domain.Education;

import java.time.LocalDateTime;

@Getter
@Setter
@AllArgsConstructor
@Builder
public class EducationDto {
private String category;
private String schoolName;
private String major;
private String state;
private LocalDateTime admissionDate;
private LocalDateTime graduationDate;

public EducationDto(Education education) {
this.category = education.getCategory();
this.schoolName = education.getSchoolName();
this.major = education.getMajor();
this.state = education.getState();
this.admissionDate = education.getAdmissionDate();
this.graduationDate = education.getGraduationDate();
}
}

0 comments on commit 43795a9

Please sign in to comment.