Skip to content

Commit

Permalink
fix: Record Member to Member Id
Browse files Browse the repository at this point in the history
  • Loading branch information
nanna29 committed Aug 2, 2024
1 parent da2dd38 commit a44884b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
10 changes: 4 additions & 6 deletions src/main/java/umc/kkijuk/server/record/domain/Record.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,16 @@ public class Record extends BaseEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@OneToOne
@JoinColumn(name = "member_id", nullable = false)
@NotNull
private Member member;
@Column(nullable = false)
private Long memberId;

private String address;

private String profileImageUrl;

@Builder
public Record(Member member, String address, String profileImageUrl) {
this.member = member;
public Record(Long memberId, String address, String profileImageUrl) {
this.memberId = memberId;
this.address = address;
this.profileImageUrl = profileImageUrl;
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/umc/kkijuk/server/record/dto/RecordResDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ public RecordResDto(Member member,

// 이력서 있을 때
@Builder
public RecordResDto(Record record,
public RecordResDto(Record record, Member member,
List<RecordListResDto> activitiesAndExperiences,
List<RecordListResDto> jobs) {
this.address = record.getAddress();
this.profileImageUrl=record.getProfileImageUrl();
this.activitiesAndExperiences=activitiesAndExperiences;
this.jobs=jobs;
this.name = record.getMember().getName();
this.birthday=record.getMember().getBirthDate();
this.phone=record.getMember().getPhoneNumber();
this.email=record.getMember().getEmail();
this.name = member.getName();
this.birthday=member.getBirthDate();
this.phone=member.getPhoneNumber();
this.email=member.getEmail();
this.updatedAt = formatUpdatedAt(record.getUpdatedAt());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Long saveRecord(Member requestMember, RecordReqDto recordReqDto){
}

Record record=Record.builder()
.member(requestMember)
.memberId(requestMember.getId())
.address(recordReqDto.getAddress())
.profileImageUrl(recordReqDto.getProfileImageUrl())
.build();
Expand All @@ -49,7 +49,7 @@ public RecordResDto getRecord(Member requestMember) {
.orElseThrow(() -> new ResourceNotFoundException("member ", requestMember.getId()));

List<Record> records = recordRepository.findAll();
List<Career> careers = careerRepository.findAll(); // null 처리 필요
List<Career> careers = careerRepository.findAll();

// 활동 및 경험으로 필터링하고, endDate 기준으로 내림차순 정렬
List<RecordListResDto> activitiesAndExperiences = careers.stream()
Expand All @@ -71,7 +71,7 @@ public RecordResDto getRecord(Member requestMember) {
// 이력서 있을 때
if (!records.isEmpty()) {
Record record = records.get(0);
return new RecordResDto(record, activitiesAndExperiences, jobs);
return new RecordResDto(record, member, activitiesAndExperiences, jobs);
}

// 이력서 없을 때
Expand All @@ -83,11 +83,14 @@ public RecordResDto updateRecord(Member requestMember, Long recordId, RecordReqD
Record record = recordRepository.findById(recordId)
.orElseThrow(() -> new ResourceNotFoundException("record ", recordId));

if (!record.getMember().getId().equals(requestMember.getId())) {
if (!record.getMemberId().equals(requestMember.getId())) {
throw new IntroOwnerMismatchException();
}

List<Career> careers = careerRepository.findAll(); // null 처리 필요
Member member=memberJpaRepository.findById(requestMember.getId())
.orElseThrow(() -> new ResourceNotFoundException("member ", requestMember.getId()));

List<Career> careers = careerRepository.findAll();

// 활동 및 경험으로 필터링하고, endDate 기준으로 내림차순 정렬
List<RecordListResDto> activitiesAndExperiences = careers.stream()
Expand All @@ -109,7 +112,7 @@ public RecordResDto updateRecord(Member requestMember, Long recordId, RecordReqD
recordReqDto.getAddress(),
recordReqDto.getProfileImageUrl());

return new RecordResDto(record, activitiesAndExperiences, jobs);
return new RecordResDto(record, member, activitiesAndExperiences, jobs);
}

}

0 comments on commit a44884b

Please sign in to comment.