From 9de47a77d2cfa1ab5f44e562caed22d6e16d2818 Mon Sep 17 00:00:00 2001 From: nanna29 Date: Sat, 3 Aug 2024 02:36:19 +0900 Subject: [PATCH] fix: masterIntroduce Member to MemberId --- .../server/introduce/domain/MasterIntroduce.java | 11 +++++++---- .../server/introduce/dto/MasterIntroduceResDto.java | 2 +- .../introduce/service/MasterIntroduceService.java | 4 ++-- .../controller/MasterIntroduceControllerTest.java | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/umc/kkijuk/server/introduce/domain/MasterIntroduce.java b/src/main/java/umc/kkijuk/server/introduce/domain/MasterIntroduce.java index 1a00b2f5..e35a98de 100644 --- a/src/main/java/umc/kkijuk/server/introduce/domain/MasterIntroduce.java +++ b/src/main/java/umc/kkijuk/server/introduce/domain/MasterIntroduce.java @@ -23,10 +23,13 @@ public class MasterIntroduce extends BaseEntity { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @OneToOne + /*@OneToOne @JoinColumn(name = "member_id", nullable = false) @NotNull - private Member member; + private Member member;*/ + + @Column(nullable = false) + private Long memberId; @Size(max = 24) private String oneLiner; @@ -37,8 +40,8 @@ public class MasterIntroduce extends BaseEntity { @Builder - public MasterIntroduce(Member member, String oneLiner, String introduction, String motive, String prosAndCons, String jobSuitability) { - this.member = member; + public MasterIntroduce(Long memberId, String oneLiner, String introduction, String motive, String prosAndCons, String jobSuitability) { + this.memberId = memberId; this.oneLiner = oneLiner; this.introduction = introduction; this.motive = motive; diff --git a/src/main/java/umc/kkijuk/server/introduce/dto/MasterIntroduceResDto.java b/src/main/java/umc/kkijuk/server/introduce/dto/MasterIntroduceResDto.java index c3534537..a054617d 100644 --- a/src/main/java/umc/kkijuk/server/introduce/dto/MasterIntroduceResDto.java +++ b/src/main/java/umc/kkijuk/server/introduce/dto/MasterIntroduceResDto.java @@ -33,7 +33,7 @@ public class MasterIntroduceResDto { public MasterIntroduceResDto(MasterIntroduce masterIntroduce/*, List introduceList*/) { this.id = masterIntroduce.getId(); - this.memberId=masterIntroduce.getMember().getId(); + this.memberId=masterIntroduce.getMemberId(); this.oneLiner = masterIntroduce.getOneLiner(); this.introduction = masterIntroduce.getIntroduction(); this.motive = masterIntroduce.getMotive(); diff --git a/src/main/java/umc/kkijuk/server/introduce/service/MasterIntroduceService.java b/src/main/java/umc/kkijuk/server/introduce/service/MasterIntroduceService.java index 631d3a17..88ce7c1c 100644 --- a/src/main/java/umc/kkijuk/server/introduce/service/MasterIntroduceService.java +++ b/src/main/java/umc/kkijuk/server/introduce/service/MasterIntroduceService.java @@ -35,7 +35,7 @@ public MasterIntroduceResDto saveMasterIntro(Member requestMember, MasterIntrodu } MasterIntroduce masterIntroduce=MasterIntroduce.builder() - .member(requestMember) + .memberId(requestMember.getId()) .oneLiner(masterIntroduceReqDto.getOneLiner()) .motive(masterIntroduceReqDto.getMotive()) .introduction(masterIntroduceReqDto.getIntroduction()) @@ -66,7 +66,7 @@ public List getMasterIntro(Member requestMember){ public MasterIntroduceResDto updateMasterIntro(Member requestMember, Long id, MasterIntroduceReqDto masterIntroduceReqDto) throws Exception{ MasterIntroduce masterIntroduce = masterIntroduceRepository.findById(id) .orElseThrow(() -> new ResourceNotFoundException("masterIntroduce ", id)); - if (!masterIntroduce.getMember().getId().equals(requestMember.getId())) { + if (!masterIntroduce.getMemberId().equals(requestMember.getId())) { throw new IntroOwnerMismatchException(); } masterIntroduce.update( diff --git a/src/test/java/umc/kkijuk/server/introduce/controller/MasterIntroduceControllerTest.java b/src/test/java/umc/kkijuk/server/introduce/controller/MasterIntroduceControllerTest.java index 62300ff5..d14f04c1 100644 --- a/src/test/java/umc/kkijuk/server/introduce/controller/MasterIntroduceControllerTest.java +++ b/src/test/java/umc/kkijuk/server/introduce/controller/MasterIntroduceControllerTest.java @@ -100,7 +100,7 @@ public void updateMaster() throws Exception { final String jobSuitability="jobSuitability-test"; MasterIntroduce masterIntroduce = masterIntroduceRepository.save(MasterIntroduce.builder() - .member(requestMember) + .memberId(requestMember.getId()) .oneLiner(oneLiner) .introduction(introduction) .motive(motive)