From 7c215e601ff0272cc474881f7b6640bbe3c0ae15 Mon Sep 17 00:00:00 2001 From: dudxo Date: Fri, 23 Aug 2024 19:34:07 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[feat]=20:=20=ED=9A=8C=EC=9B=90=20=EC=A0=84?= =?UTF-8?q?=EC=B2=B4=20=EC=A0=95=EB=B3=B4=20=EC=9D=91=EB=8B=B5=20DTO=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/MemberInformationResponse.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/com/dnd/gongmuin/member/dto/response/MemberInformationResponse.java diff --git a/src/main/java/com/dnd/gongmuin/member/dto/response/MemberInformationResponse.java b/src/main/java/com/dnd/gongmuin/member/dto/response/MemberInformationResponse.java new file mode 100644 index 00000000..de100dec --- /dev/null +++ b/src/main/java/com/dnd/gongmuin/member/dto/response/MemberInformationResponse.java @@ -0,0 +1,14 @@ +package com.dnd.gongmuin.member.dto.response; + +public record MemberInformationResponse( + Long memberId, + String nickname, + String socialName, + String officialEmail, + String socialEmail, + String jobGroup, + String jobCategory, + int credit, + int profileImageNo +) { +} From e90e391f1b7a0a4cea29b70c31e99101da20e454 Mon Sep 17 00:00:00 2001 From: dudxo Date: Fri, 23 Aug 2024 19:34:24 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[feat]=20:=20=ED=9A=8C=EC=9B=90=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dnd/gongmuin/member/controller/MemberController.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/dnd/gongmuin/member/controller/MemberController.java b/src/main/java/com/dnd/gongmuin/member/controller/MemberController.java index f916ba4a..d5ae0cfd 100644 --- a/src/main/java/com/dnd/gongmuin/member/controller/MemberController.java +++ b/src/main/java/com/dnd/gongmuin/member/controller/MemberController.java @@ -16,6 +16,7 @@ import com.dnd.gongmuin.member.dto.response.AnsweredQuestionPostsResponse; import com.dnd.gongmuin.member.dto.response.BookmarksResponse; import com.dnd.gongmuin.member.dto.response.CreditHistoryResponse; +import com.dnd.gongmuin.member.dto.response.MemberInformationResponse; import com.dnd.gongmuin.member.dto.response.MemberProfileResponse; import com.dnd.gongmuin.member.dto.response.QuestionPostsResponse; import com.dnd.gongmuin.member.service.MemberService; @@ -102,4 +103,12 @@ public ResponseEntity> getCreditHistoryByMem return ResponseEntity.ok(response); } + @Operation(summary = "회원 정보 전체 조회 API", description = "회원 정보를 전체 조회한다.") + @ApiResponse(useReturnTypeSchema = true) + @GetMapping("/information") + public ResponseEntity getMemberInformation(@AuthenticationPrincipal Member member) { + MemberInformationResponse response = memberService.getMemberInformation(member); + + return ResponseEntity.ok(response); + } } From 4849b0bb5f3415f69083813847f4ba57286af4a7 Mon Sep 17 00:00:00 2001 From: dudxo Date: Fri, 23 Aug 2024 19:34:42 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[feat]=20:=20=ED=9A=8C=EC=9B=90=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20API=20=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/dnd/gongmuin/member/service/MemberService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/dnd/gongmuin/member/service/MemberService.java b/src/main/java/com/dnd/gongmuin/member/service/MemberService.java index 9424ca47..0a10d40c 100644 --- a/src/main/java/com/dnd/gongmuin/member/service/MemberService.java +++ b/src/main/java/com/dnd/gongmuin/member/service/MemberService.java @@ -18,6 +18,7 @@ import com.dnd.gongmuin.member.dto.response.AnsweredQuestionPostsResponse; import com.dnd.gongmuin.member.dto.response.BookmarksResponse; import com.dnd.gongmuin.member.dto.response.CreditHistoryResponse; +import com.dnd.gongmuin.member.dto.response.MemberInformationResponse; import com.dnd.gongmuin.member.dto.response.MemberProfileResponse; import com.dnd.gongmuin.member.dto.response.QuestionPostsResponse; import com.dnd.gongmuin.member.exception.MemberErrorCode; @@ -139,4 +140,13 @@ public PageResponse getCreditHistoryByMember(String type, } } + + public MemberInformationResponse getMemberInformation(Member member) { + try { + Member findMember = memberRepository.findByOfficialEmail(member.getOfficialEmail()); + return MemberMapper.toMemberInformationResponse(findMember); + } catch (Exception e) { + throw new NotFoundException(MemberErrorCode.NOT_FOUND_MEMBER); + } + } } \ No newline at end of file From c038bc9801e91a516177f69b0412023ea5e0aafa Mon Sep 17 00:00:00 2001 From: dudxo Date: Fri, 23 Aug 2024 19:35:06 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[feat]=20:=20=ED=9A=8C=EC=9B=90=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20->=20=ED=9A=8C=EC=9B=90=20=EC=A0=95?= =?UTF-8?q?=EB=8F=84=20=EC=9D=91=EB=8B=B5=20DTO=20=EB=B3=80=ED=99=98=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/dnd/gongmuin/member/dto/MemberMapper.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/dnd/gongmuin/member/dto/MemberMapper.java b/src/main/java/com/dnd/gongmuin/member/dto/MemberMapper.java index f8d4a75a..1d5079db 100644 --- a/src/main/java/com/dnd/gongmuin/member/dto/MemberMapper.java +++ b/src/main/java/com/dnd/gongmuin/member/dto/MemberMapper.java @@ -1,6 +1,7 @@ package com.dnd.gongmuin.member.dto; import com.dnd.gongmuin.member.domain.Member; +import com.dnd.gongmuin.member.dto.response.MemberInformationResponse; import com.dnd.gongmuin.member.dto.response.MemberProfileResponse; import lombok.AccessLevel; @@ -19,4 +20,18 @@ public static MemberProfileResponse toMemberProfileResponse(Member member) { member.getProfileImageNo() ); } + + public static MemberInformationResponse toMemberInformationResponse(Member member) { + return new MemberInformationResponse( + member.getId(), + member.getNickname(), + member.getSocialName(), + member.getOfficialEmail(), + member.getSocialEmail(), + member.getJobGroup().getLabel(), + member.getJobCategory().getLabel(), + member.getCredit(), + member.getProfileImageNo() + ); + } } From d9bd219c91bc9f4a2a649090f7eb5fec0741dd6c Mon Sep 17 00:00:00 2001 From: dudxo Date: Fri, 23 Aug 2024 19:35:27 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[test]=20:=20=ED=9A=8C=EC=9B=90=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20API=20=ED=86=B5=ED=95=A9=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MemberControllerTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/test/java/com/dnd/gongmuin/member/controller/MemberControllerTest.java b/src/test/java/com/dnd/gongmuin/member/controller/MemberControllerTest.java index 3b4b126e..3c3aa5cb 100644 --- a/src/test/java/com/dnd/gongmuin/member/controller/MemberControllerTest.java +++ b/src/test/java/com/dnd/gongmuin/member/controller/MemberControllerTest.java @@ -332,4 +332,23 @@ void getCreditHistoryByMemberInDeposit() throws Exception { .andExpect(jsonPath("$.content[0].detail").value(ch4.getDetail())) .andExpect(jsonPath("$.content[0].amount").value(ch4.getAmount())); } + + @DisplayName("로그인 된 사용자 프로필 정보를 조회한다.") + @Test + void getMemberInformation() throws Exception { + // when // then + mockMvc.perform(get("/api/members/information") + .cookie(accessToken) + ) + .andExpect(status().isOk()) + .andExpect(jsonPath("memberId").value(loginMember.getId())) + .andExpect(jsonPath("nickname").value(loginMember.getNickname())) + .andExpect(jsonPath("socialName").value(loginMember.getSocialName())) + .andExpect(jsonPath("officialEmail").value(loginMember.getOfficialEmail())) + .andExpect(jsonPath("socialEmail").value(loginMember.getSocialEmail())) + .andExpect(jsonPath("jobGroup").value(loginMember.getJobGroup().getLabel())) + .andExpect(jsonPath("jobCategory").value(loginMember.getJobCategory().getLabel())) + .andExpect(jsonPath("profileImageNo").value(loginMember.getProfileImageNo())) + .andExpect(jsonPath("credit").value(10000)); + } } From d8875776ece401f43254ba187ccfaa367691ec56 Mon Sep 17 00:00:00 2001 From: dudxo Date: Fri, 23 Aug 2024 19:35:42 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[test]=20:=20=ED=9A=8C=EC=9B=90=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EB=8B=A8=EC=9C=84=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/service/MemberServiceTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/test/java/com/dnd/gongmuin/member/service/MemberServiceTest.java b/src/test/java/com/dnd/gongmuin/member/service/MemberServiceTest.java index e1c36c25..a8a06c08 100644 --- a/src/test/java/com/dnd/gongmuin/member/service/MemberServiceTest.java +++ b/src/test/java/com/dnd/gongmuin/member/service/MemberServiceTest.java @@ -20,6 +20,7 @@ import com.dnd.gongmuin.common.fixture.MemberFixture; import com.dnd.gongmuin.member.domain.Member; import com.dnd.gongmuin.member.dto.request.UpdateMemberProfileRequest; +import com.dnd.gongmuin.member.dto.response.MemberInformationResponse; import com.dnd.gongmuin.member.dto.response.MemberProfileResponse; import com.dnd.gongmuin.member.repository.MemberRepository; @@ -136,6 +137,39 @@ void updateMemberProfileThrowException() { // when // then assertThrows(ValidationException.class, () -> memberService.updateMemberProfile(request, member)); + } + + @DisplayName("회원 정보를 전체 조회한다.") + @Test + void getMemberInformation() { + // given + Member member = MemberFixture.member(); + given(memberRepository.findByOfficialEmail(anyString())).willReturn(member); + + // when + MemberInformationResponse memberInformation = memberService.getMemberInformation(member); + + // then + assertAll( + () -> assertThat(memberInformation.memberId()).isEqualTo(member.getId()), + () -> assertThat(memberInformation.nickname()).isEqualTo(member.getNickname()), + () -> assertThat(memberInformation.socialName()).isEqualTo(member.getSocialName()), + () -> assertThat(memberInformation.officialEmail()).isEqualTo(member.getOfficialEmail()), + () -> assertThat(memberInformation.socialEmail()).isEqualTo(member.getSocialEmail()), + () -> assertThat(memberInformation.jobGroup()).isEqualTo(member.getJobGroup().getLabel()), + () -> assertThat(memberInformation.jobCategory()).isEqualTo(member.getJobCategory().getLabel()), + () -> assertThat(memberInformation.credit()).isEqualTo(member.getCredit()), + () -> assertThat(memberInformation.profileImageNo()).isEqualTo(member.getProfileImageNo()) + ); + } + @DisplayName("회원 정보를 전체 조회 시 회원을 찾을 수 없으면 예외가 발생한다.") + @Test + void getMemberInformationThrowException() { + // given + Member member = MemberFixture.member(); + + // when // then + assertThrows(NotFoundException.class, () -> memberService.getMemberInformation(member)); } } \ No newline at end of file