diff --git a/src/main/java/umc/kkijuk/server/record/domain/Award.java b/src/main/java/umc/kkijuk/server/record/domain/Award.java index 117229d6..1f309981 100644 --- a/src/main/java/umc/kkijuk/server/record/domain/Award.java +++ b/src/main/java/umc/kkijuk/server/record/domain/Award.java @@ -22,9 +22,9 @@ public class Award extends BaseEntity { @Column(name = "award_id") private Long id; - @ManyToOne - @JoinColumn(name = "record_id", nullable = false) - private Record record; + @Column(nullable = false) + private Long memberId; + @Size(max = 30) private String competitionName; @Size(max = 15) @@ -40,7 +40,4 @@ public void changeAwardInfo(String competitionName, String administer, String aw this.acquireDate = acquireDate; } - public Long getMemberId() { - return this.record.getMemberId(); - } } diff --git a/src/main/java/umc/kkijuk/server/record/domain/File.java b/src/main/java/umc/kkijuk/server/record/domain/File.java index d20dea1b..369b2252 100644 --- a/src/main/java/umc/kkijuk/server/record/domain/File.java +++ b/src/main/java/umc/kkijuk/server/record/domain/File.java @@ -17,10 +17,6 @@ public class File extends BaseEntity { @Column(nullable = false) private Long memberId; - @ManyToOne - @JoinColumn(name = "record_id", nullable = false) - private Record record; - private FileType fileType; @Column(length = 20) @@ -32,7 +28,4 @@ public class File extends BaseEntity { private String url; - public Long getMemberId() { - return this.record.getMemberId(); - } } diff --git a/src/main/java/umc/kkijuk/server/record/domain/License.java b/src/main/java/umc/kkijuk/server/record/domain/License.java index 7f586060..3c7fe7a2 100644 --- a/src/main/java/umc/kkijuk/server/record/domain/License.java +++ b/src/main/java/umc/kkijuk/server/record/domain/License.java @@ -23,9 +23,8 @@ public class License extends BaseEntity { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @ManyToOne - @JoinColumn(name = "record_id", nullable = false) - private Record record; + @Column(nullable = false) + private Long memberId; @NotNull private LicenseTag licenseTag; @@ -51,8 +50,5 @@ public void changeLicenseInfo(LicenseTag licenseTag, String licenseName, String this.acquireDate = acquireDate; } - public Long getMemberId() { - return this.record.getMemberId(); - } } diff --git a/src/main/java/umc/kkijuk/server/record/domain/Record.java b/src/main/java/umc/kkijuk/server/record/domain/Record.java index 3bb7e79f..805809fd 100644 --- a/src/main/java/umc/kkijuk/server/record/domain/Record.java +++ b/src/main/java/umc/kkijuk/server/record/domain/Record.java @@ -28,18 +28,6 @@ public class Record extends BaseEntity { @OneToMany(mappedBy = "record", cascade = CascadeType.ALL, orphanRemoval = true) private List educations = new ArrayList<>(); - @OneToMany(mappedBy = "record", cascade = CascadeType.ALL, orphanRemoval = true) - private List licenses = new ArrayList<>(); - - @OneToMany(mappedBy = "record", cascade = CascadeType.ALL, orphanRemoval = true) - private List awards = new ArrayList<>(); - - @OneToMany(mappedBy = "record", cascade = CascadeType.ALL, orphanRemoval = true) - private List skills = new ArrayList<>(); - - @OneToMany(mappedBy = "record", cascade = CascadeType.ALL, orphanRemoval = true) - private List files = new ArrayList<>(); - @Builder public Record(Long memberId, String address, String profileImageUrl, List educations) { this.memberId = memberId; diff --git a/src/main/java/umc/kkijuk/server/record/domain/Skill.java b/src/main/java/umc/kkijuk/server/record/domain/Skill.java index 727286c7..2fc1cb82 100644 --- a/src/main/java/umc/kkijuk/server/record/domain/Skill.java +++ b/src/main/java/umc/kkijuk/server/record/domain/Skill.java @@ -19,9 +19,8 @@ public class Skill extends BaseEntity { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @ManyToOne - @JoinColumn(name = "record_id", nullable = false) - private Record record; + @Column(nullable = false) + private Long memberId; @NotNull private SkillTag skillTag; @@ -38,7 +37,4 @@ public void changeSkillInfo(SkillTag skillTag, String skillName, Workmanship wor this.workmanship = workmanship; } - public Long getMemberId() { - return this.record.getMemberId(); - } } diff --git a/src/main/java/umc/kkijuk/server/record/repository/AwardRepository.java b/src/main/java/umc/kkijuk/server/record/repository/AwardRepository.java index edf1454d..cd99af94 100644 --- a/src/main/java/umc/kkijuk/server/record/repository/AwardRepository.java +++ b/src/main/java/umc/kkijuk/server/record/repository/AwardRepository.java @@ -7,5 +7,5 @@ public interface AwardRepository extends JpaRepository { - List findByRecordId(Long recordId); + List findByMemberId(Long memberId); } diff --git a/src/main/java/umc/kkijuk/server/record/repository/EducationRepository.java b/src/main/java/umc/kkijuk/server/record/repository/EducationRepository.java index 9b585e8b..8f3c970e 100644 --- a/src/main/java/umc/kkijuk/server/record/repository/EducationRepository.java +++ b/src/main/java/umc/kkijuk/server/record/repository/EducationRepository.java @@ -1,7 +1,10 @@ package umc.kkijuk.server.record.repository; import org.springframework.data.jpa.repository.JpaRepository; +import umc.kkijuk.server.record.domain.Award; import umc.kkijuk.server.record.domain.Education; +import java.util.List; + public interface EducationRepository extends JpaRepository { } diff --git a/src/main/java/umc/kkijuk/server/record/repository/FileRepository.java b/src/main/java/umc/kkijuk/server/record/repository/FileRepository.java index 60e4a849..f4cca282 100644 --- a/src/main/java/umc/kkijuk/server/record/repository/FileRepository.java +++ b/src/main/java/umc/kkijuk/server/record/repository/FileRepository.java @@ -12,5 +12,5 @@ public interface FileRepository extends JpaRepository { boolean existsByMemberIdAndFileTitle(Long memberId, String fileTitle); boolean existsByMemberIdAndUrlTitle(Long memberId, String urlTitle); Optional findByMemberIdAndUrlTitle(Long memberId, String urlTitle); - List findByRecordId(Long recordId); + List findByMemberId(Long memberId); } diff --git a/src/main/java/umc/kkijuk/server/record/repository/LicenseRepository.java b/src/main/java/umc/kkijuk/server/record/repository/LicenseRepository.java index f19a4c53..92f7707d 100644 --- a/src/main/java/umc/kkijuk/server/record/repository/LicenseRepository.java +++ b/src/main/java/umc/kkijuk/server/record/repository/LicenseRepository.java @@ -7,5 +7,6 @@ import java.util.List; public interface LicenseRepository extends JpaRepository { - List findByRecordId(Long recordId); + + List findByMemberId(Long memberId); } diff --git a/src/main/java/umc/kkijuk/server/record/repository/RecordRepository.java b/src/main/java/umc/kkijuk/server/record/repository/RecordRepository.java index b93db1ca..cbda3686 100644 --- a/src/main/java/umc/kkijuk/server/record/repository/RecordRepository.java +++ b/src/main/java/umc/kkijuk/server/record/repository/RecordRepository.java @@ -6,4 +6,5 @@ public interface RecordRepository extends JpaRepository { Record findByMemberId(Long memberId); boolean existsByMemberId(Long memberId); + } diff --git a/src/main/java/umc/kkijuk/server/record/repository/SkillRepository.java b/src/main/java/umc/kkijuk/server/record/repository/SkillRepository.java index d241eb72..47ee1d5f 100644 --- a/src/main/java/umc/kkijuk/server/record/repository/SkillRepository.java +++ b/src/main/java/umc/kkijuk/server/record/repository/SkillRepository.java @@ -7,5 +7,5 @@ import java.util.List; public interface SkillRepository extends JpaRepository { - List findByRecordId(Long recordId); + List findByMemberId(Long memberId); } diff --git a/src/main/java/umc/kkijuk/server/record/service/FileServiceImpl.java b/src/main/java/umc/kkijuk/server/record/service/FileServiceImpl.java index bb2f9ace..058fff3e 100644 --- a/src/main/java/umc/kkijuk/server/record/service/FileServiceImpl.java +++ b/src/main/java/umc/kkijuk/server/record/service/FileServiceImpl.java @@ -77,11 +77,10 @@ public FileResponse saveFile(Long memberId, Long recordId, FileReqDto request) { throw new IllegalArgumentException("이미 존재하는 파일 이름입니다: " + request.getTitle()); } - Record record = recordRepository.findById(recordId) - .orElseThrow(() -> new ResourceNotFoundException("Record", recordId)); +// Record record = recordRepository.findById(recordId) +// .orElseThrow(() -> new ResourceNotFoundException("Record", recordId)); File file = File.builder() .memberId(memberId) - .record(record) .fileType(FileType.File) .fileTitle(request.getTitle()) .keyName(request.getKeyName()) @@ -133,12 +132,11 @@ public FileResponse saveUrl(Long memberId, Long recordId, UrlReqDto urlReqDto){ if (fileRepository.existsByMemberIdAndUrlTitle(memberId, urlReqDto.getUrlTitle())) { throw new IllegalArgumentException("이미 존재하는 URL 제목입니다: " + urlReqDto.getUrlTitle()); } - Record record = recordRepository.findById(recordId) - .orElseThrow(() -> new ResourceNotFoundException("Record", recordId)); +// Record record = recordRepository.findById(recordId) +// .orElseThrow(() -> new ResourceNotFoundException("Record", recordId)); File file = File.builder() .memberId(memberId) - .record(record) .fileType(FileType.URL) .urlTitle(urlReqDto.getUrlTitle()) .url(urlReqDto.getUrl()) diff --git a/src/main/java/umc/kkijuk/server/record/service/RecordServiceImpl.java b/src/main/java/umc/kkijuk/server/record/service/RecordServiceImpl.java index fdef1918..e2ff4038 100644 --- a/src/main/java/umc/kkijuk/server/record/service/RecordServiceImpl.java +++ b/src/main/java/umc/kkijuk/server/record/service/RecordServiceImpl.java @@ -104,24 +104,24 @@ public RecordResponse getRecord(Long memberId) { .toList(); // 수상 - List awards = awardRepository.findByRecordId(record.getId()).stream() + List awards = awardRepository.findByMemberId(memberId).stream() .map(AwardResponse::new) .sorted(Comparator.comparing(AwardResponse::getAcquireDate).reversed()) .toList(); // 자격증 - List licenses = licenseRepository.findByRecordId(record.getId()).stream() + List licenses = licenseRepository.findByMemberId(memberId).stream() .map(LicenseResponse::new) .sorted(Comparator.comparing(LicenseResponse::getAcquireDate).reversed()) .toList(); // 스킬 - List skills = skillRepository.findByRecordId(record.getId()).stream() + List skills = skillRepository.findByMemberId(memberId).stream() .map(SkillResponse::new) .collect(Collectors.toList()); // 파일 - List files = fileRepository.findByRecordId(record.getId()).stream() + List files = fileRepository.findByMemberId(memberId).stream() .map(FileResponse::new) .collect(Collectors.toList()); @@ -179,24 +179,24 @@ public RecordResponse updateRecord(Long memberId, Long recordId, RecordReqDto re .toList(); // 수상 - List awards = awardRepository.findByRecordId(record.getId()).stream() + List awards = awardRepository.findByMemberId(memberId).stream() .map(AwardResponse::new) .sorted(Comparator.comparing(AwardResponse::getAcquireDate).reversed()) .toList(); // 자격증 - List licenses = licenseRepository.findByRecordId(record.getId()).stream() + List licenses = licenseRepository.findByMemberId(memberId).stream() .map(LicenseResponse::new) .sorted(Comparator.comparing(LicenseResponse::getAcquireDate).reversed()) .toList(); // 스킬 - List skills = skillRepository.findByRecordId(record.getId()).stream() + List skills = skillRepository.findByMemberId(memberId).stream() .map(SkillResponse::new) .collect(Collectors.toList()); // 파일 - List files = fileRepository.findByRecordId(record.getId()).stream() + List files = fileRepository.findByMemberId(memberId).stream() .map(FileResponse::new) .collect(Collectors.toList()); @@ -259,36 +259,32 @@ public RecordDownResponse downloadResume(Long recordId, Long memberId) { .collect(Collectors.toList()); // 수상 - List awards = awardRepository.findByRecordId(record.getId()).stream() + List awards = awardRepository.findByMemberId(memberId).stream() .map(AwardResponse::new) .sorted(Comparator.comparing(AwardResponse::getAcquireDate).reversed()) .toList(); // 자격증 - List licenses = licenseRepository.findByRecordId(record.getId()).stream() + List licenses = licenseRepository.findByMemberId(memberId).stream() .map(LicenseResponse::new) .sorted(Comparator.comparing(LicenseResponse::getAcquireDate).reversed()) .toList(); // 스킬 - List skills = skillRepository.findByRecordId(record.getId()).stream() + List skills = skillRepository.findByMemberId(memberId).stream() .map(SkillResponse::new) .collect(Collectors.toList()); // 파일 - List files = fileRepository.findByRecordId(record.getId()).stream() + List files = fileRepository.findByMemberId(memberId).stream() .map(FileResponse::new) .collect(Collectors.toList()); return new RecordDownResponse(record, member, educationList, employments, activitiesAndExperiences, projectsAndComp, eduCareers, awards, licenses, skills, files); - } - - - @Override @Transactional public EducationResponse saveEducation(Member requestMember, Long recordId, EducationReqDto educationReqDto) { @@ -356,7 +352,7 @@ public LicenseResponse saveLicense(Member requestMember, Long recordId, LicenseR } License license = License.builder() - .record(record) + .memberId(requestMember.getId()) .licenseTag((licenseReqDto.getLicenseTag())) .licenseName(licenseReqDto.getLicenseName()) .administer(licenseReqDto.getAdminister()) @@ -377,7 +373,7 @@ public LicenseResponse updateLicense(Member requestMember, Long licenseId, Licen License license = licenseRepository.findById(licenseId) .orElseThrow(() -> new ResourceNotFoundException("License", licenseId)); - if (!license.getRecord().getMemberId().equals(requestMember.getId())) { + if (!license.getMemberId().equals(requestMember.getId())) { throw new IntroOwnerMismatchException(); } @@ -399,7 +395,7 @@ public Long deleteLicense(Member requestMember, Long licenseId) { License license = licenseRepository.findById(licenseId) .orElseThrow(() -> new ResourceNotFoundException("License", licenseId)); - if (!license.getRecord().getMemberId().equals(requestMember.getId())) { + if (!license.getMemberId().equals(requestMember.getId())) { throw new IntroOwnerMismatchException(); } @@ -420,7 +416,7 @@ public AwardResponse saveAward(Member requestMember, Long recordId, AwardReqDto } Award award = Award.builder() - .record(record) + .memberId(requestMember.getId()) .competitionName(awardReqDto.getCompetitionName()) .administer(awardReqDto.getAdminister()) .awardName(awardReqDto.getAwardName()) @@ -439,7 +435,7 @@ public AwardResponse updateAward(Member requestMember, Long awardId, AwardReqDto Award award = awardRepository.findById(awardId) .orElseThrow(() -> new ResourceNotFoundException("Award", awardId)); - if (!award.getRecord().getMemberId().equals(requestMember.getId())) { + if (!award.getMemberId().equals(requestMember.getId())) { throw new IntroOwnerMismatchException(); } @@ -460,7 +456,7 @@ public Long deleteAward(Member requestMember, Long awardId) { Award award = awardRepository.findById(awardId) .orElseThrow(() -> new ResourceNotFoundException("Award", awardId)); - if (!award.getRecord().getMemberId().equals(requestMember.getId())) { + if (!award.getMemberId().equals(requestMember.getId())) { throw new IntroOwnerMismatchException(); } @@ -481,7 +477,7 @@ public SkillResponse saveSkill(Member requestMember, Long recordId, SkillReqDto } Skill skill = Skill.builder() - .record(record) + .memberId(requestMember.getId()) .skillTag(skillReqDto.getSkillTag()) .skillName(skillReqDto.getSkillName()) .workmanship(skillReqDto.getWorkmanship()) @@ -499,7 +495,7 @@ public SkillResponse updateSkill(Member requestMember, Long skillId, SkillReqDto Skill skill = skillRepository.findById(skillId) .orElseThrow(() -> new ResourceNotFoundException("Skill", skillId)); - if (!skill.getRecord().getMemberId().equals(requestMember.getId())) { + if (!skill.getMemberId().equals(requestMember.getId())) { throw new IntroOwnerMismatchException(); } @@ -519,7 +515,7 @@ public Long deleteSkill(Member requestMember, Long skillId) { Skill skill = skillRepository.findById(skillId) .orElseThrow(() -> new ResourceNotFoundException("Skill", skillId)); - if (!skill.getRecord().getMemberId().equals(requestMember.getId())) { + if (!skill.getMemberId().equals(requestMember.getId())) { throw new IntroOwnerMismatchException(); }