Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 나의 id를 확인하는 api 추가 #110

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
)
));
}
}
Loading