From 2f9c2f69a06f84a9de351361e60218812f3b238e Mon Sep 17 00:00:00 2001 From: Jaeyoon Lee <63213487+sosow0212@users.noreply.github.com> Date: Fri, 31 May 2024 19:11:56 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=82=98=EC=9D=98=20id=EB=A5=BC=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8=ED=95=98=EB=8A=94=20api=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20(#110)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- market-api/src/docs/asciidoc/member.adoc | 12 ++++++++++++ .../infrastructure/chat/ChatQueryRepository.java | 4 ++-- .../server/member/ui/member/MemberController.java | 6 ++++++ .../member/ui/member/dto/MemberIdResponse.java | 6 ++++++ .../member/ui/member/MemberControllerTest.java | 15 +++++++++++++++ 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 market-api/src/main/java/com/server/member/ui/member/dto/MemberIdResponse.java diff --git a/market-api/src/docs/asciidoc/member.adoc b/market-api/src/docs/asciidoc/member.adoc index 8dd34b5..bdc27b0 100644 --- a/market-api/src/docs/asciidoc/member.adoc +++ b/market-api/src/docs/asciidoc/member.adoc @@ -18,3 +18,15 @@ include::{snippets}/member-controller-test/find_trade_histories/http-request.ado include::{snippets}/member-controller-test/find_trade_histories/response-fields.adoc[] include::{snippets}/member-controller-test/find_trade_histories/http-response.adoc[] +== 나의 id 반환 (GET /api/members) + +=== Request + +include::{snippets}/member-controller-test/find_my_id/request-headers.adoc[] +include::{snippets}/member-controller-test/find_my_id/http-request.adoc[] + +=== Response + +include::{snippets}/member-controller-test/find_my_id/response-fields.adoc[] +include::{snippets}/member-controller-test/find_my_id/http-response.adoc[] + diff --git a/market-api/src/main/java/com/server/market/infrastructure/chat/ChatQueryRepository.java b/market-api/src/main/java/com/server/market/infrastructure/chat/ChatQueryRepository.java index ba8fedb..3661caf 100644 --- a/market-api/src/main/java/com/server/market/infrastructure/chat/ChatQueryRepository.java +++ b/market-api/src/main/java/com/server/market/infrastructure/chat/ChatQueryRepository.java @@ -41,9 +41,9 @@ public List findChattingHistoryByChatId(final Long authId, chat.chatRoomId, chat.id, chat.senderId, - member.nickname, // join + member.nickname, chat.message, - chat.senderId.eq(authId), // 보낸 사람이 인증된 사용자인지 여부 + chat.senderId.eq(authId), chat.createdAt )).from(chat) .leftJoin(member).on(member.id.eq(chat.senderId)) // 이 부분이 잘못됨 diff --git a/market-api/src/main/java/com/server/member/ui/member/MemberController.java b/market-api/src/main/java/com/server/member/ui/member/MemberController.java index e3b3c2c..9b0c9c4 100644 --- a/market-api/src/main/java/com/server/member/ui/member/MemberController.java +++ b/market-api/src/main/java/com/server/member/ui/member/MemberController.java @@ -3,6 +3,7 @@ import com.server.member.application.member.MemberService; import com.server.member.domain.member.dto.TradeHistoryResponse; import com.server.member.ui.auth.support.AuthMember; +import com.server.member.ui.member.dto.MemberIdResponse; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -29,4 +30,9 @@ public ResponseEntity> findTradeHistories( List response = memberService.findTradeHistories(memberId, authId, isSeller); return ResponseEntity.ok(response); } + + @GetMapping + public ResponseEntity getMyId(@AuthMember final Long authId) { + return ResponseEntity.ok(new MemberIdResponse(authId)); + } } diff --git a/market-api/src/main/java/com/server/member/ui/member/dto/MemberIdResponse.java b/market-api/src/main/java/com/server/member/ui/member/dto/MemberIdResponse.java new file mode 100644 index 0000000..d8a678e --- /dev/null +++ b/market-api/src/main/java/com/server/member/ui/member/dto/MemberIdResponse.java @@ -0,0 +1,6 @@ +package com.server.member.ui.member.dto; + +public record MemberIdResponse( + Long id +) { +} diff --git a/market-api/src/test/java/com/server/member/ui/member/MemberControllerTest.java b/market-api/src/test/java/com/server/member/ui/member/MemberControllerTest.java index d0f717e..a846e5f 100644 --- a/market-api/src/test/java/com/server/member/ui/member/MemberControllerTest.java +++ b/market-api/src/test/java/com/server/member/ui/member/MemberControllerTest.java @@ -71,4 +71,19 @@ class MemberControllerTest extends MockBeanInjection { )); } + @Test + void 나의_id를_반환한다() throws Exception { + // when & then + mockMvc.perform(get("/api/members") + .header(HttpHeaders.AUTHORIZATION, "Bearer tokenInfo~") + ).andExpect(status().isOk()) + .andDo(customDocument("find_my_id", + requestHeaders( + headerWithName(AUTHORIZATION).description("유저 토큰 정보") + ), + responseFields( + fieldWithPath("id").description("로그인 한 유저의 id") + ) + )); + } }