Skip to content

Commit

Permalink
Merge pull request #22 from Na-o-man/feature/#12/members-memberinfo-api
Browse files Browse the repository at this point in the history
[FEAT] 특정 회원 정보 조회 api
  • Loading branch information
bflykky authored Jul 29, 2024
2 parents caca82c + 9cf27a5 commit cae2bdc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package com.umc.naoman.domain.member.controller;

import com.umc.naoman.domain.member.converter.MemberConverter;
import com.umc.naoman.domain.member.dto.MemberResponse;
import com.umc.naoman.domain.member.entity.Member;
import com.umc.naoman.domain.member.service.MemberService;
import com.umc.naoman.global.result.ResultResponse;
import com.umc.naoman.global.result.code.MemberResultCode;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -12,4 +19,11 @@
@RequiredArgsConstructor
public class MemberController {
private final MemberService memberService;

@GetMapping("/{memberId}") // memberId를 사용해 특정 회원 정보 조회
public ResultResponse<MemberResponse.MemberInfo> getMemberInfo(@PathVariable(name = "memberId") Long memberId) {
Member member = memberService.findMember(memberId);
return ResultResponse.of(MemberResultCode.MEMBER_INFO,
MemberConverter.toMemberInfo(member));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.umc.naoman.domain.member.converter;

import com.umc.naoman.domain.member.dto.MemberRequest.SignupRequest;
import com.umc.naoman.domain.member.dto.MemberResponse;
import com.umc.naoman.domain.member.dto.MemberResponse.LoginInfo;
import com.umc.naoman.domain.member.entity.Member;
import com.umc.naoman.domain.member.entity.SocialType;
Expand Down Expand Up @@ -39,4 +40,12 @@ public SignupRequest toSignupRequest(Claims payload, boolean marketingAgreed) {
.build();
}

public static MemberResponse.MemberInfo toMemberInfo(Member member) {
return MemberResponse.MemberInfo.builder()
.name(member.getName())
.email(member.getEmail())
.image(member.getImage())
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,13 @@ public static class LoginInfo {
private String accessToken;
private String refreshToken;
}

@Builder
@Getter
@AllArgsConstructor
public static class MemberInfo { //특정 회원 조회
private String name;
private String email;
private String image;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public enum MemberResultCode implements ResultCode {
MYPAGE_INFO(200, "SM001", "내 정보를 성공적으로 조회하였습니다."),
EDIT_MYPAGE_INFO(200, "SM002", "내 정보를 성공적으로 수정하였습니다."),
CHECK_MEMBER_REGISTRATION(200, "SM000", "해당 이메일을 가진 회원의 가입 여부를 성공적으로 조회하였습니다."),

MEMBER_INFO (200,"SM005","회원 정보를 성공적으로 조회하였습니다."),
;
private final int status;
private final String code;
Expand Down

0 comments on commit cae2bdc

Please sign in to comment.