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") + ) + )); + } }