-
Notifications
You must be signed in to change notification settings - Fork 5
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
[BE] 행사 생성 기능 구현 #41
[BE] 행사 생성 기능 구현 #41
Conversation
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.
커밋 단위는 괜찮은 것 같아요.
return ResponseEntity.ok() | ||
.location(URI.create("events/" + eventAppResponse.token())) | ||
.build(); |
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.
[R] create()를 사용해서 status code를 201로 하는 것은 어떨까요?
201이 아니면 location 헤더가 있는지 예측하기 어려울것 같습니다.
@Component | ||
public class EventTokenProvider { | ||
|
||
public String createToken() { | ||
return UUID.randomUUID().toString(); | ||
} | ||
} |
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.
[R] EventTokenProvider 생성 정책이 바뀔 가능성이 있을 것 같은데 인터페이스로 하는 것은 어떨까요?
test에서도 모킹을 하지 않고 함수형 인터페이스를 활용할 수 있을 것 같아요.
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.
👍
private final EventTokenProvider eventTokenProvider; | ||
|
||
public EventAppResponse saveEvent(EventAppRequest request) { | ||
String token = eventTokenProvider.createToken(); |
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.
[R] 중복된 토큰이 생성될 수 있으니 저장 전에 검증을 한 번 해 주면 좋을 것 같습니다.
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.
매 초 100만개의 UUID를 100년동안 생성할때 0.00009% 확률로 중복이 발생합니다.
라고 하는데 굳이 검증을 해야할까요?
DB에서 unique 조건을 한 번 걸어주는 것만으로 충분하다고 생각합니다.
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 Event(String name, String token) { | ||
this.name = name; | ||
this.token = token; | ||
} |
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.
[R] : name 검증이 없는 것 같아요.
private final EventService eventService; | ||
|
||
@PostMapping("/api/events") | ||
public ResponseEntity<Void> saveEvent(EventSaveRequest request) { |
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.
[R] : @RequestBody
를 안붙여도 잘 동작하나요?
명시적으로 붙이는 것이 어떨까요?
issue
구현 사항
행사 생성 API 구현
중점적으로 리뷰받고 싶은 부분(선택)
리뷰 시에 커밋의 규모가 적당했는지 궁금합니다.
논의하고 싶은 부분(선택)
행사 token 생성 전략에 대하여, 임의로 UUID를 선택했습니다. 이후, 변경을 고려하여 EventTokenProvider.class로 분리했습니다. 추후 논의가 필요할 것 같습니다.