-
Notifications
You must be signed in to change notification settings - Fork 3
[DDING-125-1] 섹션 여러 개일 경우 폼지 생성 수정 #295
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -41,6 +41,7 @@ | |||||||||||
| import java.util.Objects; | ||||||||||||
| import java.util.concurrent.CompletableFuture; | ||||||||||||
| import java.util.concurrent.TimeUnit; | ||||||||||||
| import java.util.stream.Stream; | ||||||||||||
| import lombok.RequiredArgsConstructor; | ||||||||||||
| import lombok.extern.slf4j.Slf4j; | ||||||||||||
| import org.springframework.stereotype.Service; | ||||||||||||
|
|
@@ -68,9 +69,12 @@ public void createForm(CreateFormCommand createFormCommand) { | |||||||||||
|
|
||||||||||||
| Form form = createFormCommand.toEntity(club); | ||||||||||||
| Form savedForm = formService.create(form); | ||||||||||||
|
|
||||||||||||
| List<FormField> formFields = toCreateFormFields(savedForm, | ||||||||||||
| createFormCommand.formFieldCommands()); | ||||||||||||
| List<FormField> formFields; | ||||||||||||
| if (savedForm.getSections().size() > 1) { | ||||||||||||
| formFields = toCreateFormFieldsForMultipleSections(savedForm, createFormCommand.formFieldCommands()); | ||||||||||||
| } else { | ||||||||||||
| formFields = toCreateFormFieldsForSingleSection(savedForm, createFormCommand.formFieldCommands()); | ||||||||||||
| } | ||||||||||||
Seooooo24 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||
| formFieldService.createAll(formFields); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
|
@@ -257,9 +261,23 @@ private List<FormField> toUpdateFormFields(Form originform, | |||||||||||
| .map(formFieldCommand -> formFieldCommand.toEntity(originform)).toList(); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| private List<FormField> toCreateFormFields(Form savedForm, | ||||||||||||
| List<CreateFormFieldCommand> createFormFieldCommands) { | ||||||||||||
| private List<FormField> toCreateFormFieldsForSingleSection(Form savedForm, | ||||||||||||
| List<CreateFormFieldCommand> createFormFieldCommands) { | ||||||||||||
| return createFormFieldCommands.stream() | ||||||||||||
| .map(formFieldCommand -> formFieldCommand.toEntity(savedForm)).toList(); | ||||||||||||
Seooooo24 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||
| } | ||||||||||||
| private List<FormField> toCreateFormFieldsForMultipleSections(Form savedForm, | ||||||||||||
| List<CreateFormFieldCommand> createFormFieldCommands) { | ||||||||||||
| return createFormFieldCommands.stream() | ||||||||||||
| .flatMap(formFieldCommand -> { | ||||||||||||
| if (formFieldCommand.section().equals("공통")) { | ||||||||||||
| return savedForm.getSections().stream() | ||||||||||||
| .filter(section -> !section.equals("공통")) | ||||||||||||
| .map(section -> formFieldCommand.toEntityWithSection(savedForm, section)); | ||||||||||||
| } else { | ||||||||||||
| return Stream.of(formFieldCommand.toEntityWithSection(savedForm, formFieldCommand.section())); | ||||||||||||
| } | ||||||||||||
| }) | ||||||||||||
| .toList(); | ||||||||||||
|
Comment on lines
+271
to
+260
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p3) 그리고 "공통"도 상수처리 하면 좋을 것 같네요
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. private 메서드 두 개로 나누어보았습니다. 한 번 더 나눌까 생각했지만 그러면 너무 많은 메서드 때문에 오히려 가독성이 떨어질 것 같기도 해서... 어떻게 생각하시는지 말씀해주실 수 있을까요? 상수처리 완료했습니다!
Comment on lines
+264
to
+260
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p4)
Suggested change
createForm() 메서드의 스트림과 합쳐도 괜찮을거 같습니다!
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 헙 그러네요 수정하였습니다! |
||||||||||||
| } | ||||||||||||
Seooooo24 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||
| } | ||||||||||||
Uh oh!
There was an error while loading. Please reload this page.