Skip to content

Commit

Permalink
대표 badgeId 조회 추가
Browse files Browse the repository at this point in the history
SeWooooong committed Aug 21, 2024
1 parent 2225c68 commit 9c2d776
Showing 3 changed files with 39 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -4,9 +4,10 @@
import com.example.mssaembackendv2.domain.member.dto.MemberRequestDto.ModifyProfile;
import com.example.mssaembackendv2.domain.member.dto.MemberRequestDto.RegisterMember;
import com.example.mssaembackendv2.domain.member.dto.MemberRequestDto.SocialLoginToken;
import com.example.mssaembackendv2.domain.member.dto.MemberResponseDto;
import com.example.mssaembackendv2.domain.member.dto.MemberResponseDto.CheckNickNameRes;
import com.example.mssaembackendv2.domain.member.dto.MemberResponseDto.MemberProfileInfo;
import com.example.mssaembackendv2.domain.member.dto.MemberResponseDto.MemberSimpleInfo;
import com.example.mssaembackendv2.domain.member.dto.MemberResponseDto.MemberInfo;
import com.example.mssaembackendv2.domain.member.dto.MemberResponseDto.TeacherInfo;
import com.example.mssaembackendv2.domain.member.dto.MemberResponseDto.TokenInfo;
import com.example.mssaembackendv2.global.config.security.auth.CurrentMember;
@@ -101,7 +102,7 @@ public ResponseEntity<TokenInfo> refreshLogin(@CurrentMember Member member) {
* [GET] 로그인한 유저 정보 조회
*/
@GetMapping("/member/info")
public ResponseEntity<MemberSimpleInfo> getCurrentMemberInfo(@CurrentMember Member member) {
public ResponseEntity<MemberInfo> getCurrentMemberInfo(@CurrentMember Member member) {
return new ResponseEntity<>(memberService.getMemberInfo(member), HttpStatus.OK);
}

Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@
import com.example.mssaembackendv2.domain.member.dto.MemberRequestDto.CheckNickName;
import com.example.mssaembackendv2.domain.member.dto.MemberRequestDto.RegisterMember;
import com.example.mssaembackendv2.domain.member.dto.MemberRequestDto.SocialLoginToken;
import com.example.mssaembackendv2.domain.member.dto.MemberResponseDto;
import com.example.mssaembackendv2.domain.member.dto.MemberResponseDto.MemberInfo;
import com.example.mssaembackendv2.domain.member.dto.MemberResponseDto.MemberSimpleInfo;
import com.example.mssaembackendv2.domain.member.dto.MemberResponseDto.MemberProfileInfo;
import com.example.mssaembackendv2.domain.member.dto.MemberResponseDto.CheckNickNameRes;
@@ -28,6 +30,7 @@
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
@@ -174,8 +177,16 @@ public TokenInfo refreshAccessToken(Member member) {
.build();
}

public MemberSimpleInfo getMemberInfo(Member member) {
return new MemberSimpleInfo(member);
public MemberInfo getMemberInfo(Member member) {
List<Badge> allByMember = badgeRepository.findAllByMember(member).orElseThrow();
Long badgeId = null;
for (Badge badge : allByMember) {
if(badge.getBadgeEnum().getName().equals(member.getBadgeName())){
badgeId = badge.getId();
break;
}
}
return new MemberInfo(member, badgeId);
}

public String deleteProfileImage(Member member) {
Original file line number Diff line number Diff line change
@@ -45,7 +45,30 @@ public MemberSimpleInfo(Member member) {
this.profileImgUrl = member.getProfileImageUrl();
this.introduction = member.getIntroduction();
}
}

@Getter
@AllArgsConstructor
@NoArgsConstructor
public static class MemberInfo {

private Long id;
private String nickName;
private String mbti;
private String badge;
private String profileImgUrl;
private String introduction;
private Long badgeId;

public MemberInfo(Member member, Long badgeId) {
this.id = member.getId();
this.nickName = member.getNickName();
this.mbti = member.getDetailMbti();
this.badge = member.getBadgeName();
this.profileImgUrl = member.getProfileImageUrl();
this.introduction = member.getIntroduction();
this.badgeId = badgeId;
}
}

@Getter

0 comments on commit 9c2d776

Please sign in to comment.