-
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.
- Loading branch information
Showing
140 changed files
with
3,361 additions
and
1,260 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
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
7 changes: 4 additions & 3 deletions
7
...tion/src/main/java/org/depromeet/spot/application/block/dto/response/RowInfoResponse.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 |
---|---|---|
@@ -1,18 +1,19 @@ | ||
package org.depromeet.spot.application.block.dto.response; | ||
|
||
import java.util.List; | ||
|
||
import org.depromeet.spot.usecase.port.in.block.BlockReadUsecase.RowInfo; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record RowInfoResponse(Long id, int number, int minSeatNum, int maxSeatNum) { | ||
public record RowInfoResponse(Long id, int number, List<Integer> seatNumList) { | ||
|
||
public static RowInfoResponse from(RowInfo rowInfo) { | ||
return RowInfoResponse.builder() | ||
.id(rowInfo.getId()) | ||
.number(rowInfo.getNumber()) | ||
.minSeatNum(rowInfo.getMinSeatNum()) | ||
.maxSeatNum(rowInfo.getMaxSeatNum()) | ||
.seatNumList(rowInfo.getSeatNumList()) | ||
.build(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ication/src/main/java/org/depromeet/spot/application/common/annotation/CurrentMember.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,18 @@ | ||
package org.depromeet.spot.application.common.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* 해당 어노테이션은 헤더에 담긴 Jwt 토큰에서 <b>memberId</b> 값을 가져오는 어노테이션입니다. <br> | ||
* 컨트롤러에서 사용하려는 <b>메소드</b>에 사용하면됩니다. <br> | ||
* <br> | ||
* <b>파라미터</b>에 <b>Long memberId</b>를 추가해주어야 합니다. <br> | ||
* <b>@Parameter(hidden = true) Long memberId</b>로 하시면 <br> | ||
* 해당 파라미터는 Swagger에서 제외됩니다. :) | ||
*/ | ||
@Target(ElementType.METHOD) // 적용 대상 : 메소드 | ||
@Retention(RetentionPolicy.RUNTIME) // 런타임에 사용할 수 있도록 설정 | ||
public @interface CurrentMember {} |
44 changes: 44 additions & 0 deletions
44
application/src/main/java/org/depromeet/spot/application/common/aop/JwtTokenAspect.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,44 @@ | ||
package org.depromeet.spot.application.common.aop; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
|
||
import org.aspectj.lang.ProceedingJoinPoint; | ||
import org.aspectj.lang.annotation.Around; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.aspectj.lang.reflect.MethodSignature; | ||
import org.depromeet.spot.application.common.jwt.JwtTokenUtil; | ||
import org.springframework.stereotype.Component; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Component | ||
@Aspect | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class JwtTokenAspect { | ||
|
||
private final JwtTokenUtil jwtTokenUtil; | ||
|
||
private final HttpServletRequest request; | ||
|
||
@Around("@annotation(org.depromeet.spot.application.common.annotation.CurrentMember)") | ||
public Object getMemberIdFromTokenAspect(ProceedingJoinPoint joinPoint) throws Throwable { | ||
Long memberId = jwtTokenUtil.getIdFromJWT(jwtTokenUtil.getAccessToken(request)); | ||
|
||
// 동작하는 메소드의 시그니처를 가져옴. | ||
MethodSignature signature = (MethodSignature) joinPoint.getSignature(); | ||
Object[] args = joinPoint.getArgs(); | ||
Class<?>[] parameterTypes = signature.getParameterTypes(); | ||
String[] parameterNames = signature.getParameterNames(); | ||
|
||
for (int i = 0; i < args.length; i++) { | ||
if ("memberId".equals(parameterNames[i]) && parameterTypes[i] == Long.class) { | ||
args[i] = memberId; // memberId로 변경 | ||
} | ||
} | ||
|
||
// 변경된 인자로 메서드 실행 | ||
return joinPoint.proceed(args); | ||
} | ||
} |
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
53 changes: 53 additions & 0 deletions
53
application/src/main/java/org/depromeet/spot/application/common/config/SwaggerConfig.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,53 @@ | ||
package org.depromeet.spot.application.common.config; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.servlet.ServletContext; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import io.swagger.v3.oas.models.Components; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.info.Info; | ||
import io.swagger.v3.oas.models.security.SecurityRequirement; | ||
import io.swagger.v3.oas.models.security.SecurityScheme; | ||
import io.swagger.v3.oas.models.security.SecurityScheme.In; | ||
import io.swagger.v3.oas.models.security.SecurityScheme.Type; | ||
import io.swagger.v3.oas.models.servers.Server; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
public class SwaggerConfig { | ||
|
||
@Bean | ||
public OpenAPI openAPI(ServletContext servletContext) { | ||
String contextPath = servletContext.getContextPath(); | ||
Server server = new Server().url(contextPath); | ||
return new OpenAPI() | ||
.servers(List.of(server)) | ||
.addSecurityItem(new SecurityRequirement().addList("accessToken")) | ||
.components(authSetting()) | ||
.info(swaggerInfo()); | ||
} | ||
|
||
private Info swaggerInfo() { | ||
return new Info() | ||
.version("v0.0.1") | ||
.title("야구장 좌석 시야 서비스, SPOT API 문서") | ||
.description("SPOT 서버의 API 문서입니다."); | ||
} | ||
|
||
private Components authSetting() { | ||
return new Components() | ||
.addSecuritySchemes( | ||
"accessToken", | ||
new SecurityScheme() | ||
.type(Type.HTTP) | ||
.scheme("Bearer") | ||
.bearerFormat("JWT") | ||
.in(In.HEADER) | ||
.name("Authorization")); | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
application/src/main/java/org/depromeet/spot/application/common/jwt/JwtTokenEnums.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,12 @@ | ||
package org.depromeet.spot.application.common.jwt; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum JwtTokenEnums { | ||
BEARER("Bearer"); | ||
|
||
private final String value; | ||
} |
Oops, something went wrong.