Conversation
BlackBean99
approved these changes
May 23, 2024
Collaborator
BlackBean99
left a comment
There was a problem hiding this comment.
실력이 많이 늘었습니다. 하지만 지금 코드는 너무 딱딱해보입니다. 더 유연해보일 수 있게 코드를 작성해보세요. 기획과 딱 맞는 코드는 좋지 못합니다.
Comment on lines
+18
to
+86
| @RestController | ||
| @AllArgsConstructor | ||
| public class Test { | ||
| RegistrationService registrationService; | ||
|
|
||
| @PostMapping("/register") | ||
| public String register(@RequestBody Registration registration){ | ||
| // 예외처리 필요할듯하다. | ||
| registrationService.register(registration); | ||
| return "success"; | ||
| } | ||
|
|
||
| // 지원자 정보 생성 | ||
| @PostMapping("/register-personal-inform") | ||
| public String registerPersonInform(@RequestBody PersonalInformation personalInformation){ | ||
| registrationService.registerPersonalInform(personalInformation); | ||
| return "success"; | ||
| } | ||
|
|
||
| // 지원자 지원 경로 생성 | ||
| @PostMapping("/register-path") | ||
| public String registerPath(@RequestBody Path path){ | ||
| registrationService.registerPath(path); | ||
| return "success"; | ||
| } | ||
|
|
||
| // 지원자 면접 가능 시간 생성 | ||
| @PostMapping("/register-desired-time") | ||
| public String registerDesiredTime(@RequestBody DesiredTime desiredTime){ | ||
| registrationService.registerDesiredTime(desiredTime); | ||
| return "success"; | ||
| } | ||
|
|
||
|
|
||
| // 전체 지원자 수 | ||
| @GetMapping("/registrations-count") | ||
| public Integer getTotalRegisterCount(){ | ||
| return registrationService.getRegistrationCount(); | ||
| } | ||
|
|
||
| // 개발자, 기획자, 디자이너 별 지원자 수 | ||
| @GetMapping("/registrations-hope-count") | ||
| public ArrayList<Integer> getHopeFieldsTotalRegisterCount(){ | ||
| return registrationService.getHopeFieldsTotalCount(); | ||
| } | ||
|
|
||
| // 희망 분야별 지원자 수 | ||
| @GetMapping("/registrations/first-hope-field") | ||
| public Map<String, Integer> getFirstHopeFieldCount() { | ||
| return registrationService.getHopeFieldsFirstPriorityCount(); | ||
| } | ||
| @GetMapping("/registrations/second-hope-field") | ||
| public Map<String, Integer> getSecondHopeFieldCount() { | ||
| return registrationService.getHopeFieldsSecondPriorityCount(); | ||
| } | ||
|
|
||
| // 지원자 학과별 수 | ||
| @GetMapping("/registrations/department-count") | ||
| public Map<String, Integer> getDepartmentCount(){ | ||
| return registrationService.getDepartmentCount(); | ||
| } | ||
|
|
||
| // 지원 경로별 수 | ||
| @GetMapping("/registrations/path-count") | ||
| public Map<String, Integer> getPathCount(){ | ||
| return registrationService.getPathCount(); | ||
| } | ||
|
|
||
| } |
Collaborator
There was a problem hiding this comment.
인재님 앱 형태로 1개의 url로 합쳐보는 걸 과제로 드렸습니다. 이렇게 웹 요청으로 하게 되면 transmit delay가 엄청 발생할거에요.
최대한 요청 수를 줄일 수 있게 데이터를 구성해봅시다.
Comment on lines
+77
to
+95
| for(Map.Entry<String,Registration> entrySet : registration.entrySet()){ | ||
| if(entrySet.getValue().getHopeField().equals("개발자")){ // == 의 경우 비교 연산이 이뤄지지 않음 | ||
| count = hopeFields.get(0); | ||
| hopeFields.set(0,count+1); | ||
| } | ||
| else if(entrySet.getValue().getHopeField().equals("기획자")){ | ||
| count = hopeFields.get(1); | ||
| hopeFields.set(1,count+1); | ||
| } | ||
| else if(entrySet.getValue().getHopeField().equals("디자이너")){ | ||
| count = hopeFields.get(2); | ||
| hopeFields.set(2,count+1); | ||
| } | ||
| else{ | ||
| // 예외 처리 | ||
| } | ||
| } | ||
| return hopeFields; | ||
| } |
Collaborator
There was a problem hiding this comment.
조회를 index로 저렇게 숫자를 집어넣으시면 진짜 코드가 산으로갈겁니다. 가독성이 0거든요. 제가 분기처리하는 방법 많이 알려드렸으니 더 고민해보세요.
Comment on lines
+4
to
+9
| POSTER("홍보 포스터"), | ||
| ANNOUNCEMENT("학과 공지사항"), | ||
| INTRODUCTION("지인 소개"), | ||
| INSTAGRAM("인스타그램"), | ||
| EVERYTIME("에브리타임"), | ||
| ETIC("기타"); |
Collaborator
There was a problem hiding this comment.
지원경로는 string으로 받으면 될텐데 굳이 이넘까지 쓴 이유가 있을까요?
실제로 개발을 해보시면 프론트들이 셀렉트 박스로 인풋값을 제한해주기 때문에 이런건 오히려 확장에 불리합니다.
Comment on lines
+78
to
+81
| for(Path path : database.getAllPath().values()){ | ||
| String p = path.getSupportPath().getType(); | ||
| pathCount.put(p,pathCount.getOrDefault(p,0)+1); | ||
| } |
Collaborator
There was a problem hiding this comment.
집계를 for을 쓰는 순간부터 가독성은 현저히 떨어집니다. 이 코드는 해당 지원 경로를 순회하며 찾아서 1씩 추가해주는 것인데 그럽 map에 접근하는 횟수가 얼마나 될까요. map에 get하는 행위 없이 바로 집어넣어봅시다. stream을 쓰는 것도 방법일거구요.
This file contains hidden or 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
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.
No description provided.