-
Notifications
You must be signed in to change notification settings - Fork 0
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
[feat] 어드민 이벤트 수정 기능 구현(#28) #31
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set 자료구조를 활용, dto / entity의 키를 기준으로 크게 3개 구역으로 나눈다. 1. key == null: 서버에 없으므로 생성 2. key가 양측에 존재: 업데이트 3. key가 서버측에만 존재: 이벤트 삭제
- application-test.yml 파일 추가 필수!
win-luck
approved these changes
Aug 6, 2024
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.
어드민 특성상 다채로운 수정이 많아서 굉장히 번거로우셨을 텐데 고생 많으셨습니다!
Comment on lines
84
to
106
@Transactional | ||
public EventDto getEventInfo(String eventId) { | ||
Optional<EventMetadata> metadataOpt = emRepository.findFirstByEventId(eventId); | ||
EventMetadata metadata = metadataOpt | ||
.orElseThrow(() -> new EventException(ErrorCode.EVENT_NOT_FOUND)); | ||
|
||
EventFieldMapper mapper = mapperMatcher.getMapper(metadata.getEventType()); | ||
if(mapper == null) throw new EventException(ErrorCode.INVALID_EVENT_TYPE); | ||
|
||
EventDto eventDto = EventDto.builder() | ||
.id(metadata.getId()) | ||
.eventId(metadata.getEventId()) | ||
.name(metadata.getName()) | ||
.description(metadata.getDescription()) | ||
.url(metadata.getUrl()) | ||
.startTime(metadata.getStartTime()) | ||
.endTime(metadata.getEndTime()) | ||
.eventType(metadata.getEventType()) | ||
.build(); | ||
|
||
mapper.fetchToDto(metadata, eventDto); | ||
return eventDto; | ||
} |
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.
조회 메서드인 만큼 readOnly=true 옵션을 붙여주셔도 좋을 것 같아요!
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#️⃣ 연관 이슈
📝 작업 내용
이벤트 수정 로직 선택
프론트엔드 팀원과의 논의에 따라 이벤트 수정 기능을 "요청 - db 스냅샷 비교" 방식 기반으로 구현했습니다.
관리자 수정 기능을 구현하는 방법은 큰 그림에서는 2가지 방법 존재합니다.
1번의 경우 클라이언트 측에서 api를 여러 번 호출하는 것이 불편하다는 의견이 있어 2번 방식으로 구현하기로 했습니다.
단일 api를 이용하여 백엔드가 수정 기능을 만드는 법은 2가지를 생각했습니다.
프론트엔드 측에서는 1번 방안보다 2번 방안이 좀 더 편리하다고 하여 2번 방안을 구현해보기로 했습니다.
구현 논리: dto(클라이언트 측 데이터) 와 entity(서버 측 데이터, 스냅샷)에 대해 set 논리를 도입하여 create / update / delete 대상이 되는 데이터를 식별하여 처리합니다.
필요 이상으로 갱신 난이도가 복잡해질 경우, 이벤트 데이터를 완전 delete 후 다시 얻는 방식도 고려하고 있습니다.
EventFieldMapper 확장 기반으로 기능 구현
이전에 event 타입 확장에 대응하기 위해 구현한 EventTypeMapper의 인터페이스를 확장, 2개 기능을 구현했습니다. 선착순, 추첨 이벤트 모두 구현한 상태입니다.