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

[4기 - 박세영] Url Shortener 과제 PR입니다 #45

Open
wants to merge 29 commits into
base: SY97P
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
41b1706
chore: initial commit
onetuks Oct 4, 2023
ded88b0
feat: Url 엔티티 및 값 객체 생성
onetuks Oct 4, 2023
4e9c2c6
chore: 타임리프 의존성 추가
onetuks Oct 5, 2023
20c2897
docs: README 파일 수정
onetuks Oct 5, 2023
30c883f
feat: UrlMapping 모델 추가
onetuks Oct 5, 2023
b6340dc
feat: 매핑 정보 조회
onetuks Oct 5, 2023
aa32d66
chore: test 설정 추가
onetuks Oct 6, 2023
e12e000
feat: 단축 알고리즘 추가
onetuks Oct 6, 2023
b4afbd1
feat: url 단축 기능 추가 (등록)
onetuks Oct 6, 2023
09e4b55
feat: 단축 URL 리다이렉션 기능 추가
onetuks Oct 6, 2023
0376159
refactor: 매핑 단건 조회를 전체 조회로 변경
onetuks Oct 6, 2023
55557a2
docs: README 파일 수정
onetuks Oct 6, 2023
f32d336
refactor: 타임리프 UI 수정
onetuks Oct 6, 2023
7c9985b
docs: README 파일 완성
onetuks Oct 6, 2023
af827aa
style: 코드 포매팅
onetuks Oct 6, 2023
a2c16e3
refactor: 알고리즘 클래스에서 외부 변수명 제거
onetuks Oct 8, 2023
c01bc13
refactor: page 스펙을 백엔드에서 제어하도록 수정
onetuks Oct 8, 2023
6827891
refactor: NPE 방어 위해 result 에서 값 객체 값 찾도록 수정
onetuks Oct 8, 2023
7ca12ed
refactor: 단축url 생성 로직 수정
onetuks Oct 8, 2023
d80e827
refactor: 미디어 타입 명시
onetuks Oct 8, 2023
5aedbbf
refactor: 리다이렉션 경로 반환을 OriginUrl 객체 내에서 생성하도록 수정
onetuks Oct 8, 2023
ff0837d
refactor: Exception, logging 관련 처리
onetuks Oct 9, 2023
46dfa03
refactor: 문맥 따라 개행
onetuks Oct 9, 2023
adffb08
refactor: DTO 변환 static 메소드 인스턴스화
onetuks Oct 9, 2023
337bfe2
refactor: Algorithm enum 클래스의 JPA 의존성 제거
onetuks Oct 9, 2023
cb5fbf9
refactor: UrlMapping 엔티티 생성자 수정
onetuks Oct 9, 2023
f003c42
test: 테스트 DisplayName 변경
onetuks Oct 9, 2023
79620d8
refactor: POST 요청 body 방식으로 변경
onetuks Oct 9, 2023
bd55aad
fix: 패키지명 수정
onetuks Oct 9, 2023
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
refactor: page 스펙을 백엔드에서 제어하도록 수정
onetuks committed Oct 8, 2023
commit c01bc131f992c4539e8758e6901ac21796dad305
Original file line number Diff line number Diff line change
@@ -9,17 +9,21 @@
import com.tangerine.urlshortener.url.service.UrlService;
import com.tangerine.urlshortener.url.service.dto.UrlMappingResult;
import com.tangerine.urlshortener.url.service.dto.UrlMappingResults;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class UrlController {

private static final int DEFAULT_PAGE_SIZE = 10;

private final UrlService urlService;

public UrlController(UrlService urlService) {
@@ -72,15 +76,16 @@ public String redirectToOriginUrl(
* 모든 매핑 정보 조회
*
* @param model
* @param pageable
* @param page
* @return "mapping-info"
*/
@GetMapping(path = "/mappings")
public String mappingInfos(
Model model,
Pageable pageable
@RequestParam(defaultValue = "0") int page
) {
UrlMappingResults allMappings = urlService.findAllMappings(pageable);
PageRequest pageRequest = PageRequest.of(page, DEFAULT_PAGE_SIZE);
UrlMappingResults allMappings = urlService.findAllMappings(pageRequest);
UrlMappingResponses mappings = UrlMappingResponses.of(allMappings);
PageInfo pageInfo = PageInfo.from(
mappings.results().getPageable(),