-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
모임 재참여 api, 스냅 조회 api 개발
- Loading branch information
Showing
30 changed files
with
568 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
[[인증-API]] | ||
== 인증 API | ||
|
||
include::login.adoc[] | ||
|
||
include::refresh-token.adoc[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
=== 모임 재참여 | ||
==== 성공 | ||
Request | ||
include::{snippets}/auth-controller-test/login/http-request.adoc[] | ||
include::{snippets}/auth-controller-test/login/path-parameters.adoc[] | ||
Request Cookie | ||
include::{snippets}/auth-controller-test/login/request-cookies.adoc[] | ||
Request Body | ||
include::{snippets}/auth-controller-test/login/request-body.adoc[] | ||
include::{snippets}/auth-controller-test/login/request-fields.adoc[] | ||
|
||
Response | ||
include::{snippets}/auth-controller-test/login/http-response.adoc[] | ||
Response Cookie | ||
include::{snippets}/auth-controller-test/login/response-cookies.adoc[] | ||
|
||
|
||
==== 실패 | ||
===== `요청 쿠키로 access token이 없는경우` | ||
include::{snippets}/auth-controller-test/login_no_access_token/response-body.adoc[] | ||
|
||
===== `모임의 참여자가 아닌 사용자가 로그인을 시도하는 경우` | ||
include::{snippets}/auth-controller-test/login_no_participation_meeting/response-body.adoc[] | ||
|
||
===== `모임의 비밀번호가 틀린 경우` | ||
include::{snippets}/auth-controller-test/login_incorrect_password/response-body.adoc[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
=== snap id로 snap 상세 조회 | ||
|
||
==== 성공 | ||
|
||
===== Request | ||
include::{snippets}/snap-controller-test/find-snap-by-id/http-request.adoc[] | ||
===== Query Parameter | ||
include::{snippets}/snap-controller-test/find-snap-by-id/path-parameters.adoc[] | ||
===== Request Cookie | ||
include::{snippets}/snap-controller-test/find-snap-by-id/request-cookies.adoc[] | ||
|
||
===== Response | ||
SIMPLE 타입의 snap 일떄 | ||
include::{snippets}/snap-controller-test/find-snap-by-id/http-response.adoc[] | ||
|
||
RANDOM_MISSION 타입의 snap 일떄 | ||
include::{snippets}/snap-controller-test/find-random-mission-snap-by-id/http-response.adoc[] | ||
|
||
MEETING_MISSION 타입의 snap 일떄 | ||
include::{snippets}/snap-controller-test/find-meeting-mission-snap-by-id/http-response.adoc[] | ||
|
||
include::{snippets}/snap-controller-test/find-snap-by-id/response-fields.adoc[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/com/dnd/snappy/controller/v1/auth/interceptor/LoginInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.dnd.snappy.controller.v1.auth.interceptor; | ||
|
||
import com.dnd.snappy.common.error.exception.BusinessException; | ||
import com.dnd.snappy.domain.auth.dto.response.TokenInfo; | ||
import com.dnd.snappy.domain.auth.exception.AuthErrorCode; | ||
import com.dnd.snappy.domain.auth.service.JwtTokenStrategy; | ||
import com.dnd.snappy.domain.auth.service.PathVariableExtractor; | ||
import com.dnd.snappy.domain.participant.repository.ParticipantRepository; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.servlet.HandlerInterceptor; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class LoginInterceptor implements HandlerInterceptor { | ||
|
||
private final PathVariableExtractor pathVariableExtractor; | ||
private final JwtTokenStrategy jwtTokenStrategy; | ||
private final ParticipantRepository participantRepository; | ||
|
||
@Override | ||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { | ||
|
||
final Long meetingId = pathVariableExtractor.extractMeetingId(request); | ||
TokenInfo tokenInfo = jwtTokenStrategy.loginProcess(request); | ||
validationParticipantInMeeting(tokenInfo.payload(), meetingId); | ||
return true; | ||
} | ||
|
||
private void validationParticipantInMeeting(Long participantId, Long meetingId) { | ||
if(!participantRepository.existsByIdAndMeetingId(participantId, meetingId)) { | ||
throw new BusinessException(AuthErrorCode.FORBIDDEN); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/com/dnd/snappy/controller/v1/auth/request/LoginRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.dnd.snappy.controller.v1.auth.request; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
|
||
public record LoginRequest( | ||
@NotBlank(message = "비밀번호는 필수입니다.") | ||
String password | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/com/dnd/snappy/domain/snap/dto/response/MissionDetailResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.dnd.snappy.domain.snap.dto.response; | ||
|
||
public record MissionDetailResponseDto( | ||
Long missionId, | ||
String content | ||
) { | ||
public MissionDetailResponseDto(Integer missionId, String content) { | ||
this(Long.valueOf(missionId), content); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/dnd/snappy/domain/snap/dto/response/ParticipantDetailResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.dnd.snappy.domain.snap.dto.response; | ||
|
||
public record ParticipantDetailResponseDto( | ||
Long participantId, | ||
String nickname | ||
) { | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/dnd/snappy/domain/snap/dto/response/SnapDetailResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.dnd.snappy.domain.snap.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import java.time.LocalDateTime; | ||
|
||
public record SnapDetailResponseDto( | ||
Long snapId, | ||
String snapUrl, | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm", timezone = "Asia/Seoul") | ||
LocalDateTime shootDate, | ||
String type, | ||
ParticipantDetailResponseDto photographer, | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
MissionDetailResponseDto mission | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.