Skip to content

Commit

Permalink
change profile controller pk -> id #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingadinga committed Aug 28, 2022
1 parent 86cac20 commit b7ff110
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
7 changes: 4 additions & 3 deletions src/main/java/com/team20/t4/member/MemberController.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import javax.validation.Valid;
import java.util.List;
import java.util.Map;

@RequiredArgsConstructor
@RestController
Expand Down Expand Up @@ -38,9 +39,9 @@ public MemberInfoResponseDto getInfo(){
return memberService.getMemberInfo();
}

@GetMapping("/member/{memberPk}/info")
public MemberInfoAndReviewListResponseDto getInfoAnotherMember(@PathVariable Long memberPk){
return memberService.getMemberInfo(memberPk);
@GetMapping("/member/info/other")
public MemberInfoAndReviewListResponseDto getInfoAnotherMember(@RequestBody Map<String, String> memberId){
return memberService.getMemberInfo(memberId.get("memberId"));
}

@GetMapping("/member/plans")
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/team20/t4/member/MemberService.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,21 @@ public MemberInfoResponseDto getMemberInfo(){
}

@Transactional
public MemberInfoAndReviewListResponseDto getMemberInfo(Long memberPk){
Member memberByMemberPk = getMemberByMemberPk(memberPk);
List<ReviewResponseDtoByTarget> reviewListOfOther = getReviewListOfOther(memberPk);
MemberInfoResponseDto memberInfoResponseDto = MemberInfoResponseDto.toDtoWithProfileImage(memberByMemberPk, getImgUrl(memberByMemberPk));
public MemberInfoAndReviewListResponseDto getMemberInfo(String memberId){
Member memberByMemberId = getMemberByMemberId(memberId);
List<ReviewResponseDtoByTarget> reviewListOfOther = getReviewListOfOther(memberId);
MemberInfoResponseDto memberInfoResponseDto = MemberInfoResponseDto.toDtoWithProfileImage(memberByMemberId, getImgUrl(memberByMemberId));
return new MemberInfoAndReviewListResponseDto(reviewListOfOther, memberInfoResponseDto);
}

public List<ReviewResponseDtoByTarget> getReviewListOfOther(Long memberPk) throws RequestException {
Member target = getMemberByMemberPk(memberPk);
public List<ReviewResponseDtoByTarget> getReviewListOfOther(String memberId) throws RequestException {
Member target = getMemberByMemberId(memberId);
List<Review> reviewList = reviewRepository.findAllByTarget(target);
return getReviewResponseDtoByTargetList(reviewList);
}

private Member getMemberByMemberPk(Long memberPk) {
return memberRepository.findById(memberPk)
private Member getMemberByMemberId(String memberId) {
return memberRepository.findByMemberId(memberId)
.orElseThrow(() -> new RequestException(RequestErrorCode.NOT_FOUND, "회원가입하지 않은 아이디입니다."));
}

Expand Down

0 comments on commit b7ff110

Please sign in to comment.