Skip to content

Commit

Permalink
feat: 나의 id를 확인하는 api 추가 (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
sosow0212 authored May 31, 2024
1 parent b6b0a40 commit 2f9c2f6
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
12 changes: 12 additions & 0 deletions market-api/src/docs/asciidoc/member.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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[]

Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public List<ChatHistoryResponse> 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)) // 이 부분이 잘못됨
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,4 +30,9 @@ public ResponseEntity<List<TradeHistoryResponse>> findTradeHistories(
List<TradeHistoryResponse> response = memberService.findTradeHistories(memberId, authId, isSeller);
return ResponseEntity.ok(response);
}

@GetMapping
public ResponseEntity<MemberIdResponse> getMyId(@AuthMember final Long authId) {
return ResponseEntity.ok(new MemberIdResponse(authId));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.server.member.ui.member.dto;

public record MemberIdResponse(
Long id
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
));
}
}

0 comments on commit 2f9c2f6

Please sign in to comment.