-
Notifications
You must be signed in to change notification settings - Fork 11
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
[STEP 3-1-1] 만료시간 추가 #95
base: jiheon2234
Are you sure you want to change the base?
[STEP 3-1-1] 만료시간 추가 #95
Conversation
jiheon2234
commented
Mar 6, 2025
- api 사용자가 단축 url을 만들 때, ttlMinutes를 추가할 수 있도록 변경
- 원래는 단축된 URL만 저장했으나, 요구사항의 변경에 따라 ID, 원본URL, 단축URL, expiredAt 을 한번에 저장하도록 변경
- 만료시간이 지난 URL은 조회할 수 없도록 변경 (추후에 스케줄링을 통한 논리적 삭제로 변경 예정)
- api 사용자가 단축 url을 만들 때, ttlMinutes를 추가할 수 있도록 변경 - 원래는 단축된 URL만 저장했으나, 요구사항의 변경에 따라 ID, 원본URL, 단축URL, expiredAt 을 한번에 저장하도록 변경 - 만료시간이 지난 URL은 조회할 수 없도록 변경 (추후에 스케줄링을 통한 논리적 삭제로 변경 예정)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존에 단축된 url string값만 저장하는대신, 연관된 정보들을 함께 저장하도록 변경하였습니다.
@@ -29,28 +33,35 @@ public class ShortenURLService { | |||
* @throws BusinessLogicException 원본 URL을 찾을 수 없는 경우 | |||
*/ | |||
public String getOriginURL(String shortenedURL) { | |||
String originURL = repository.findByShortenedURL(shortenedURL) | |||
ShortenedURLEntity entity = repository.findByShortenedURL(shortenedURL) | |||
.filter((se) -> se.getExpiredAt().isAfter(LocalDateTime.now())) | |||
.orElseThrow(() -> BusinessLogicException.from(BusinessExceptionCode.ORIGIN_URL_NOT_FOUND)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
만료시간이 지난 URL들은 조회시 응답하지 않도록 설정했습니다.
추후 스케줄러를 통한 논리적 삭제 방식으로 변경할 생각입니다.
|
||
@Min(value = 0, message = "만료 기간은 음수일 수 없습니다.") | ||
@Max(value = 1440, message = "만료 기간은 최대 하루(1440분) 입니다.") | ||
int ttlMinutes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
wrapper 자료형 사용을 권장 합니다.
this.originURL = originURL; | ||
this.shortenedURL = shortenedURL; | ||
this.expiredAt = expiredAt; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
빌더는 위험 합니다. 불가피하다면 생성자나 팩토리 메서드 안에서만 사용을 권장 합니다.
- 위험한 이유는 직접 검색해보세요.
|
||
public void markDelete() { | ||
this.isDeleted = true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi. disable, expiry