diff --git a/src/main/java/com/example/mssaembackendv2/domain/member/MemberController.java b/src/main/java/com/example/mssaembackendv2/domain/member/MemberController.java index edd75e8..4b14f24 100644 --- a/src/main/java/com/example/mssaembackendv2/domain/member/MemberController.java +++ b/src/main/java/com/example/mssaembackendv2/domain/member/MemberController.java @@ -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 refreshLogin(@CurrentMember Member member) { * [GET] 로그인한 유저 정보 조회 */ @GetMapping("/member/info") - public ResponseEntity getCurrentMemberInfo(@CurrentMember Member member) { + public ResponseEntity getCurrentMemberInfo(@CurrentMember Member member) { return new ResponseEntity<>(memberService.getMemberInfo(member), HttpStatus.OK); } diff --git a/src/main/java/com/example/mssaembackendv2/domain/member/MemberService.java b/src/main/java/com/example/mssaembackendv2/domain/member/MemberService.java index ebf2948..5a39583 100644 --- a/src/main/java/com/example/mssaembackendv2/domain/member/MemberService.java +++ b/src/main/java/com/example/mssaembackendv2/domain/member/MemberService.java @@ -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 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) { diff --git a/src/main/java/com/example/mssaembackendv2/domain/member/dto/MemberResponseDto.java b/src/main/java/com/example/mssaembackendv2/domain/member/dto/MemberResponseDto.java index 98613a3..51e7522 100644 --- a/src/main/java/com/example/mssaembackendv2/domain/member/dto/MemberResponseDto.java +++ b/src/main/java/com/example/mssaembackendv2/domain/member/dto/MemberResponseDto.java @@ -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