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

[STEP 3-1-1] 만료시간 추가 #95

Open
wants to merge 1 commit into
base: jiheon2234
Choose a base branch
from

Conversation

jiheon2234
Copy link
Collaborator

  • api 사용자가 단축 url을 만들 때, ttlMinutes를 추가할 수 있도록 변경
  • 원래는 단축된 URL만 저장했으나, 요구사항의 변경에 따라 ID, 원본URL, 단축URL, expiredAt 을 한번에 저장하도록 변경
  • 만료시간이 지난 URL은 조회할 수 없도록 변경 (추후에 스케줄링을 통한 논리적 삭제로 변경 예정)

- api 사용자가 단축 url을 만들 때, ttlMinutes를 추가할 수 있도록 변경
- 원래는 단축된 URL만 저장했으나, 요구사항의 변경에 따라 ID, 원본URL, 단축URL, expiredAt 을 한번에 저장하도록 변경
- 만료시간이 지난 URL은 조회할 수 없도록 변경 (추후에 스케줄링을 통한 논리적 삭제로 변경 예정)
@jiheon2234 jiheon2234 changed the title feature : 만료시간 추가 [STEP 3-1-1] 만료시간 추가 Mar 6, 2025
Copy link
Collaborator Author

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));
Copy link
Collaborator Author

@jiheon2234 jiheon2234 Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

만료시간이 지난 URL들은 조회시 응답하지 않도록 설정했습니다.
추후 스케줄러를 통한 논리적 삭제 방식으로 변경할 생각입니다.

@jiheon2234 jiheon2234 requested a review from Hyune-c March 6, 2025 12:48

@Min(value = 0, message = "만료 기간은 음수일 수 없습니다.")
@Max(value = 1440, message = "만료 기간은 최대 하루(1440분) 입니다.")
int ttlMinutes
Copy link
Collaborator

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;
}
Copy link
Collaborator

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;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi. disable, expiry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants