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 과제 제출합니다. #70

Open
wants to merge 35 commits into
base: eugene
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f21a7cc
init commit
eugene225 Dec 7, 2023
3b879ef
docs: h2 database, jpa, server 환경설정
eugene225 Dec 10, 2023
7836615
docs: h2 database, guava 의존성 추가
eugene225 Dec 10, 2023
9f89a4f
feat: Url 엔티티 구성 및 repository 생성
eugene225 Dec 10, 2023
4926d6a
feat: UrlService 기본 기능 구현 (인코딩 방식 추가 필요)
eugene225 Dec 10, 2023
1be563c
feat: UrlController 기본구현
eugene225 Dec 10, 2023
4ebb782
feat: shortenURL 화면 구성
eugene225 Dec 11, 2023
43a530d
Chore: 패키지 수정
eugene225 Dec 11, 2023
3e78f05
chore: 패키지 구조 변경
eugene225 Dec 11, 2023
74b0d62
refactor: 기본 service 구성
eugene225 Dec 11, 2023
38b98c0
refactor: 기본 rest api 구성
eugene225 Dec 11, 2023
3029ced
feat: web controller 구성
eugene225 Dec 11, 2023
f77ca25
refactor: 기본 api 주소 변경
eugene225 Dec 11, 2023
ff3d166
chore: 패키지 구조 변경
eugene225 Dec 11, 2023
10d658b
feat: GlobalExceptionHandler 구성 및 적용
eugene225 Dec 11, 2023
d11a9ea
feat: base62 인코딩 방식 추가
eugene225 Dec 11, 2023
80b6440
feat: 이진수, 16진수 converter 추가
eugene225 Dec 11, 2023
dcf2fb1
refactor: Base62 Encoding 클래스명 변경 (이넘명 중복)
eugene225 Dec 16, 2023
0702ff3
feat: encodingType 이넘 생성 및 함수형 인터페이스 적용
eugene225 Dec 16, 2023
585d81a
feat: string 값 이넘 변환 converter 생성
eugene225 Dec 16, 2023
5165c18
refactor: 인코딩 함수 로직 변경
eugene225 Dec 16, 2023
8eb7746
refactor: encodingType 파라미터 추가
eugene225 Dec 16, 2023
651e09e
feat: html encodingType 라디오 버튼 추가
eugene225 Dec 16, 2023
42f7595
feat: url 요청 수 count 필드 추가 및 서비스 코드 수정
eugene225 Dec 16, 2023
9315f8e
refactor: 진수 Converter 클래스명 수정
eugene225 Dec 16, 2023
c1642c9
refactor: HttpStatus 활용 수정
eugene225 Dec 16, 2023
59686bf
feat: UrlRequestDto 생성 및 적용
eugene225 Dec 17, 2023
34df475
feat: base62 encoding 길이 추가
eugene225 Dec 17, 2023
0fcdb18
feat: originUrl 유효성 검사 코드 추가
eugene225 Dec 17, 2023
d1f77c0
docs: servlet 설정 제거
eugene225 Dec 18, 2023
7e5f03d
feat: createdAt, updatedAt 컬럼 추가
eugene225 Dec 19, 2023
5dc7ac6
feat: ID 값 타입수정
eugene225 Dec 19, 2023
48df906
Create maven.yml
eugene225 Feb 4, 2024
f2808c5
refactor: 이미 존재하는 url 처리
eugene225 Feb 4, 2024
786e478
Merge branch 'main' of https://github.com/eugene225/springboot-url-sh…
eugene225 Feb 4, 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: UrlController 기본구현
eugene225 committed Dec 10, 2023
commit 1be563c7d2704af0ee0a00d687c0885e3f50aca0
38 changes: 38 additions & 0 deletions src/main/java/com/prgrms/shortenurl/url/UrlRestController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.prgrms.shortenurl.url;

import com.prgrms.shortenurl.url.domain.Url;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.net.URI;
import java.net.URISyntaxException;

@RestController

Choose a reason for hiding this comment

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

RestController를 사용했을때 ResponseBody가 필요할까요?

@RequestMapping("/shortenUrl")

Choose a reason for hiding this comment

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

path의 경우 여러개의 단어 조합일때 kebab case를 고려해봐주세요.

public class UrlRestController {
private final UrlService urlService;

public UrlRestController(UrlService urlService) {
this.urlService = urlService;
}

@PostMapping(value = "/{url}")
@ResponseBody
public ResponseEntity<String> shortenUrl(@PathVariable String url) {
Url shortenUrl = urlService.addLink(url);
return ResponseEntity.ok(shortenUrl.getOriginUrl());
}

@GetMapping(value = "/{key}")
@ResponseBody
public ResponseEntity<String> getUrl(@PathVariable String key) {
String url = urlService.getUrlByKey(key);
return ResponseEntity.ok(url);
}

@GetMapping("/redirect/{key}")
public String redirect(@PathVariable String key) throws URISyntaxException {
URI redirectUrl = new URI(urlService.getUrlByKey(key));
return "redirect:" + redirectUrl;
}

Choose a reason for hiding this comment

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

두 개가 분리되어야하는 이유가 어떤건가요?

}