diff --git a/src/main/java/org/moonshot/server/domain/log/exception/InvalidRecordException.java b/src/main/java/org/moonshot/server/domain/log/exception/InvalidRecordException.java new file mode 100644 index 00000000..2716a65e --- /dev/null +++ b/src/main/java/org/moonshot/server/domain/log/exception/InvalidRecordException.java @@ -0,0 +1,10 @@ +package org.moonshot.server.domain.log.exception; + +import org.moonshot.server.global.common.exception.MoonshotException; +import org.moonshot.server.global.common.response.ErrorType; + +public class InvalidRecordException extends MoonshotException { + + public InvalidRecordException() { super(ErrorType.INVALID_RECORD_VALUE); } + +} diff --git a/src/main/java/org/moonshot/server/domain/log/service/LogService.java b/src/main/java/org/moonshot/server/domain/log/service/LogService.java index 2862bd21..71a3837a 100644 --- a/src/main/java/org/moonshot/server/domain/log/service/LogService.java +++ b/src/main/java/org/moonshot/server/domain/log/service/LogService.java @@ -10,6 +10,7 @@ import org.moonshot.server.domain.log.dto.request.LogCreateRequestDto; import org.moonshot.server.domain.log.dto.response.LogResponseDto; import org.moonshot.server.domain.log.exception.InvalidLogValueException; +import org.moonshot.server.domain.log.exception.InvalidRecordException; import org.moonshot.server.domain.log.model.Log; import org.moonshot.server.domain.log.model.LogState; import org.moonshot.server.domain.log.repository.LogRepository; @@ -41,6 +42,9 @@ public void createRecordLog(Long userId, LogCreateRequestDto request) { if (!keyResult.getObjective().getUser().getId().equals(userId)) { throw new AccessDeniedException(); } + if(request.logNum() > keyResult.getTarget()) { + throw new InvalidRecordException(); + } Optional prevLog = logRepository.findLatestLogByKeyResultId(LogState.RECORD, request.keyResultId()); long prevNum = -1; if (!prevLog.isEmpty()) { diff --git a/src/main/java/org/moonshot/server/global/auth/jwt/TokenResponse.java b/src/main/java/org/moonshot/server/global/auth/jwt/TokenResponse.java index 1bc1d007..321de8f9 100644 --- a/src/main/java/org/moonshot/server/global/auth/jwt/TokenResponse.java +++ b/src/main/java/org/moonshot/server/global/auth/jwt/TokenResponse.java @@ -5,6 +5,6 @@ public record TokenResponse( String refreshToken ) { public static TokenResponse of(String accessToken, String refreshToken) { - return new TokenResponse(accessToken, refreshToken); + return new TokenResponse("Bearer " + accessToken, "Bearer " + refreshToken); } } \ No newline at end of file diff --git a/src/main/java/org/moonshot/server/global/common/response/ErrorType.java b/src/main/java/org/moonshot/server/global/common/response/ErrorType.java index 71f496dc..15ee78a9 100644 --- a/src/main/java/org/moonshot/server/global/common/response/ErrorType.java +++ b/src/main/java/org/moonshot/server/global/common/response/ErrorType.java @@ -24,6 +24,7 @@ public enum ErrorType { INVALID_KEY_RESULT_ORDER(HttpStatus.BAD_REQUEST, "정상적이지 않은 KeyResult 위치입니다."), INVALID_TASK_ORDER(HttpStatus.BAD_REQUEST, "정상적이지 않은 Task 위치입니다."), INVALID_LOG_VALUE(HttpStatus.BAD_REQUEST, "진척 정도는 이전 값보다 큰 값이 입력되어야합니다."), + INVALID_RECORD_VALUE(HttpStatus.BAD_REQUEST, "진척 정도는 목표값보다 작은 값이 입력되어야 합니다."), /** * 401 UNAUTHROZIED diff --git a/src/main/java/org/moonshot/server/global/constants/JWTConstants.java b/src/main/java/org/moonshot/server/global/constants/JWTConstants.java index 59509edb..380581c0 100644 --- a/src/main/java/org/moonshot/server/global/constants/JWTConstants.java +++ b/src/main/java/org/moonshot/server/global/constants/JWTConstants.java @@ -3,7 +3,7 @@ public class JWTConstants { public static final String USER_ID = "userId"; - public static final Long ACCESS_TOKEN_EXPIRATION_TIME = 60 * 1000L * 20; // 액세스 토큰 만료 시간: 20분으로 지정 - public static final Long REFRESH_TOKEN_EXPIRATION_TIME = 60 * 1000L * 60 * 24 * 7 * 2; // 리프레시 토큰 만료 시간: 2주로 지정 + public static final Long ACCESS_TOKEN_EXPIRATION_TIME = 60 * 1000L * 60 * 24 * 7 * 2; + public static final Long REFRESH_TOKEN_EXPIRATION_TIME = 60 * 1000L * 60 * 24 * 7 * 2; }