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

[5기 조인수] Shorten URL 과제 PR입니다. #71

Open
wants to merge 42 commits into
base: ZZAMBAs
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
8a638f9
Initial commit
ZZAMBAs Dec 12, 2023
476b930
Feat: short url에 대한 도메인 클래스와 스키마를 추가한다.
ZZAMBAs Dec 13, 2023
7ddf83f
Feat: ShortUrlRepository를 추가한다.
ZZAMBAs Dec 13, 2023
f545f35
Feat: int 값을 6자리 BASE62 문자열로 인코딩하는 UrlTransformer를 추가한다.
ZZAMBAs Dec 13, 2023
9e9b702
Feat: ShortUrl에 빌더 패턴을 추가한다.
ZZAMBAs Dec 13, 2023
c9891ae
Feat: UrlTransformer를 인터페이스 형식으로 변경하고 BASE62 기반 구현체를 추가한다.
ZZAMBAs Dec 13, 2023
ee7e781
Feat: Url 처리 관련 예외, 에러코드 클래스를 추가한다.
ZZAMBAs Dec 14, 2023
77d1b9e
Chore: MySQL을 사용하도록 빌드 파일과 yml 파일의 내용을 수정한다.
ZZAMBAs Dec 14, 2023
960b602
Fix: 일부 잘못된 환경 설정, visitCount를 더하는 쿼리를 제대로 수정한다.
ZZAMBAs Dec 14, 2023
6b261f9
Feat: 코드를 가독성 좋게 수정하고 ShortUrl에서 방문 카운트를 올리는 메서드를 추가한다.
ZZAMBAs Dec 15, 2023
7643d3c
Feat: URL 저장, 가져오기를 구현한 서비스를 추가한다.
ZZAMBAs Dec 15, 2023
41e8704
Test: 테스트용 yml 파일을 생성한다.
ZZAMBAs Dec 15, 2023
c26e7e5
Fix: 랜덤 정수가 음수가 되지 않도록 수정한다.
ZZAMBAs Dec 15, 2023
7d638e7
Feat: null은 쿼리에 포함시키지 않도록 하고 originalUrl에 getter를 추가한다.
ZZAMBAs Dec 15, 2023
9172394
Test: shortUrlService의 기능을 테스트하는 코드를 추가한다.
ZZAMBAs Dec 15, 2023
2b83465
Feat: saveOriginalUrl()에서 이미 저장된 original Url은 바로 반환하도록 한다.
ZZAMBAs Dec 15, 2023
4f9300b
Test: 이미 저장된 url에 대해 같은 url을 반환하는 테스트를 추가한다.
ZZAMBAs Dec 15, 2023
2853a6d
Rename: 패키지를 세분화한다.
ZZAMBAs Dec 15, 2023
027c909
Feat: 최초 페이지를 생성한다.
ZZAMBAs Dec 16, 2023
b41f1de
Feat: 빠른 탐색을 위해 인덱싱을 추가한다.
ZZAMBAs Dec 17, 2023
9970d68
Feat: DTO를 추가하고 적용한다.
ZZAMBAs Dec 17, 2023
d069253
Test: DTO에 맞게 테스트 코드를 수정하고, short url 방문 시 업데이트 되는지 확인하는 테스트를 추가한다.
ZZAMBAs Dec 17, 2023
c0c134c
Feat: 변환 URL을 보여주는 페이지를 추가한다.
ZZAMBAs Dec 17, 2023
df62215
Feat: ShortUrl 관련 공통 상수를 관리하는 클래스를 추가한다.
ZZAMBAs Dec 17, 2023
9dc80e2
Feat: ShortUrl 관련 공통 메서드를 관리하는 클래스를 추가한다.
ZZAMBAs Dec 17, 2023
da170d3
Feat: HTTP 프로토콜을 제거하여 DB 저장 공간을 절약한다.
ZZAMBAs Dec 17, 2023
1093c0c
Feat: favicon.ico를 불러오지 않도록 하는 MVC 설정을 추가한다.
ZZAMBAs Dec 17, 2023
e51224f
Feat: ShortUrl 처리 컨트롤러를 추가한다.
ZZAMBAs Dec 17, 2023
7077d58
Feat: ShortUrl 복사 기능을 추가한다.
ZZAMBAs Dec 17, 2023
3853796
Feat: 잘못된 요청 혹은 서버 예외에 대한 컨트롤러 처리를 추가한다.
ZZAMBAs Dec 17, 2023
237dc39
Feat: 변환 URL 정보에 원본 URL도 나타나도록 한다.
ZZAMBAs Dec 17, 2023
2f4e65b
Feat: originalUrl을 고유하도록 컬럼 속성을 추가한다.
ZZAMBAs Dec 26, 2023
db1d232
Refactor: stream을 이용하여 간략화한다.
ZZAMBAs Jan 1, 2024
d30ee0b
feat: 예외 처리를 위한 Controller를 따로 생성한다.
ZZAMBAs Jan 1, 2024
ff371c7
Refactor: 에러 코드를 HTTP와 강결합되지 않도록 자체 코드로 수정한다.
ZZAMBAs Jan 1, 2024
9ea0a29
Refactor: BASE62의 62를 상수로 관리한다.
ZZAMBAs Jan 1, 2024
3a248f5
Chore: 상수 네이밍을 통일한다.
ZZAMBAs Jan 1, 2024
507ebba
Rename: 이미 클래스 명에 URL임이 명시되어 있기에 더 직관적인 메서드 명으로 변경한다.
ZZAMBAs Jan 1, 2024
8081b48
Chore: 일부 코드를 다듬는다.
ZZAMBAs Jan 1, 2024
817e9eb
Refactor: 메서드 내부로 랜덤 정수 만드는 로직을 포함시킨다.
ZZAMBAs Jan 1, 2024
bc3dbb5
Refactor: 리다이렉트 서버가 변경될 것을 생각해 상수화한다.
ZZAMBAs Jan 1, 2024
0a15a04
Chore: 사용하지 않는 import 문을 정리한다.
ZZAMBAs Jan 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: 예외 처리를 위한 Controller를 따로 생성한다.
ZZAMBAs committed Jan 1, 2024
commit d30ee0ba6cdbeb50c38916c4c2e4aa8b7719fd4f
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.prgms.springbooturlshortener.domain.shorturl.controller;

import lombok.extern.slf4j.Slf4j;
import org.prgms.springbooturlshortener.domain.shorturl.exception.UrlException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
@Slf4j
public class ExceptionController {
private static final int HTTP_500_ERROR_BOUND = 400;
@ExceptionHandler(UrlException.class)
public String showUrlErrorPage(UrlException ex) {
if (ex.getUrlErrorCode() > HTTP_500_ERROR_BOUND) {
log.warn("서버에서의 에러: {}", ex.getMessage());

return "error/500";
}

log.info("클라이언트에서 잘못된 입력. {}", ex.getMessage());

return "error/400";
}

@ExceptionHandler(Exception.class)
public String showDefaultError(Exception ex) {
log.error("예상하지 못한 에러 발생: {}", ex.getMessage());

return "error/500";
}
}
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
import org.prgms.springbooturlshortener.domain.shorturl.service.dto.TransformedShortUrlDto;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@@ -18,7 +17,6 @@
@Controller
@Slf4j
public class ShortUrlController {
private static final int HTTP_500_ERROR_BOUND = 400;

private final ShortUrlService shortUrlService;

@@ -58,24 +56,4 @@ public String showTransformedUrl(TransformedShortUrlDto transformedShortUrlDto,

return "short-url-info";
}

@ExceptionHandler(UrlException.class)
public String showUrlErrorPage(UrlException ex) {
if (ex.getUrlErrorCode() > HTTP_500_ERROR_BOUND) {
log.warn("서버에서의 에러: {}", ex.getMessage());

return "error/500";
}

log.info("클라이언트에서 잘못된 입력. {}", ex.getMessage());

return "error/400";
}

@ExceptionHandler(Exception.class)
public String showDefaultError(Exception ex) {
log.error("예상하지 못한 에러 발생: {}", ex.getMessage());

return "error/400";
}
}