Skip to content

Commit

Permalink
♻️ refactor: 프로필 조회시 팔로잉 수, 찜 수 조회되도록 수정(#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoungj00n committed Mar 25, 2024
1 parent 05ca28e commit 3b78aa8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ public static ProfileImg toProfileImg(String url, Member member) {
.build();
}

public static MemberResponseDTO.ProfileResultDTO toProfile(Member member, String url, List<Account> account, List<Address> address) {
public static MemberResponseDTO.ProfileResultDTO toProfile(Member member, String url, List<Account> account,
List<Address> address, Long following, Long dibs) {

List<MemberResponseDTO.AccountDTO> accountList = account.stream().map(a -> MemberResponseDTO.AccountDTO.builder()
.id(a.getId())
Expand All @@ -261,6 +262,8 @@ public static MemberResponseDTO.ProfileResultDTO toProfile(Member member, String
.url(url)
.accountList(null)
.addressList(null)
.following(following)
.dibs(dibs)
.build();
}
if (account.isEmpty()){
Expand All @@ -270,6 +273,8 @@ public static MemberResponseDTO.ProfileResultDTO toProfile(Member member, String
.url(url)
.addressList(addressList)
.accountList(accountList)
.following(following)
.dibs(dibs)
.build();
}
if(address.isEmpty()){
Expand All @@ -279,6 +284,8 @@ public static MemberResponseDTO.ProfileResultDTO toProfile(Member member, String
.url(url)
.addressList(null)
.accountList(accountList)
.following(following)
.dibs(dibs)
.build();
}

Expand All @@ -288,6 +295,8 @@ public static MemberResponseDTO.ProfileResultDTO toProfile(Member member, String
.url(url)
.addressList(addressList)
.accountList(accountList)
.following(following)
.dibs(dibs)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,28 +233,6 @@ public ApiResponse<?> naverCallback(@RequestParam String code, String state) {
}


@GetMapping(value = "/profile")
@Operation(summary = "프로필 조회 api", description = "프로필이미지, 닉네임을 조회할 수 있습니다.")
public ApiResponse<MemberResponseDTO.ProfileResultDTO> getProfile(Authentication authentication) {



Member member = memberQueryService.findMemberById(Long.valueOf(authentication.getName().toString())).orElseThrow(() -> new MemberHandler(ErrorStatus.MEMBER_NOT_FOUND));
Optional<ProfileImg> profileImg = memberQueryService.findProfileImgByMember(member.getId());
List<Address> address = memberQueryService.findAllAddressById(member.getId());
List<Account> account = memberQueryService.findAllAccountById(member.getId());



if(profileImg.isEmpty()){
return ApiResponse.onSuccess(MemberConverter.toProfile(member, null, account, address));
}
else {
return ApiResponse.onSuccess(MemberConverter.toProfile(member, profileImg.get().getUrl(),account, address));
}


}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.umc.TheGoods.apiPayload.exception.handler.MemberHandler;
import com.umc.TheGoods.converter.member.MemberConverter;
import com.umc.TheGoods.domain.enums.OrderStatus;
import com.umc.TheGoods.domain.images.ProfileImg;
import com.umc.TheGoods.domain.item.Category;
import com.umc.TheGoods.domain.item.Tag;
import com.umc.TheGoods.domain.member.Auth;
Expand Down Expand Up @@ -292,6 +293,30 @@ public ApiResponse<?> postContact(Authentication authentication,
return ApiResponse.of(SuccessStatus.MEMBER_CONTACT_SUCCESS,null);
}

@GetMapping(value = "/profile")
@Operation(summary = "프로필 조회 api", description = "프로필이미지, 닉네임, 주소, 계좌, 팔로잉 수, 찜 수를 조회할 수 있습니다.")
public ApiResponse<MemberResponseDTO.ProfileResultDTO> getProfile(Authentication authentication) {



Member member = memberQueryService.findMemberById(Long.valueOf(authentication.getName().toString())).orElseThrow(() -> new MemberHandler(ErrorStatus.MEMBER_NOT_FOUND));
Optional<ProfileImg> profileImg = memberQueryService.findProfileImgByMember(member.getId());
List<Address> address = memberQueryService.findAllAddressById(member.getId());
List<Account> account = memberQueryService.findAllAccountById(member.getId());
Long following = Long.valueOf(member.getFollowingList().size());
Long dibs = Long.valueOf(member.getDibsList().size());



if(profileImg.isEmpty()){
return ApiResponse.onSuccess(MemberConverter.toProfile(member, null, account, address,following,dibs));
}
else {
return ApiResponse.onSuccess(MemberConverter.toProfile(member, profileImg.get().getUrl(),account, address,following,dibs));
}


}
/**
* 주문 상세 내역
* 입금처, 입금 은행, 상품 사진, 상품 이름, 상품 옵션, 주문 상태(결제 전, 결제 완료), 주문자명, 주문자 연락처, 주문 번호, 상품 주문 개수, 상품가격
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ public static class ProfileResultDTO {
String phone;
List<MemberResponseDTO.AddressDTO> addressList;
List<MemberResponseDTO.AccountDTO> accountList;
Long following;
Long dibs;

}

Expand Down

0 comments on commit 3b78aa8

Please sign in to comment.