-
Notifications
You must be signed in to change notification settings - Fork 6
3주차 과제(박민규) #18
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
base: main
Are you sure you want to change the base?
3주차 과제(박민규) #18
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.econovation.third_project.dto.response; | ||
|
|
||
| public class AdminPageResponse { | ||
| private HopeField hopeField; | ||
| private Priority priority; | ||
|
|
||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package com.econovation.third_project.dto.response; | ||
|
|
||
| public class HopeField { | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package com.econovation.third_project.dto.response; | ||
|
|
||
| public class Priority { | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.econovation.third_project.service; | ||
|
|
||
|
|
||
| import java.util.Map; | ||
|
|
||
| public class ApplicantMapper { | ||
| Map<String, Integer> applicantNum; | ||
| Map<String, int[]> applicantPriority; | ||
|
|
||
| public ApplicantMapper(Map<String, Integer> applicantNum, Map<String, int[]> applicantPriority) { | ||
| this.applicantNum = applicantNum; | ||
| this.applicantPriority = applicantPriority; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.econovation.third_project.service; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| public class DesiredTimeMapper { | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.econovation.third_project.service; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class GetAdminPage { | ||
| private final GetApplicant getApplicant; | ||
| private final GetDesiredTime getDesiredTime; | ||
| private final GetMajor getMajor; | ||
| private final GetPath getPath; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| package com.econovation.third_project.service; | ||
|
|
||
| import com.econovation.third_project.database.Database; | ||
| import com.econovation.third_project.database.Registration; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class GetApplicant { | ||
| private final Database db; | ||
|
|
||
| public ApplicantMapper getAllApplicant(){ | ||
| Map<String, Registration> allRegistration = db.getAllRegistration(); | ||
|
|
||
| // PG 개발자, PM 기획자, DE 디자이너 | ||
| // key = hopeField, value = 몇 명인지 | ||
| Map<String, Integer> allApplicantNum = new HashMap<>(); | ||
|
|
||
| allApplicantNum.put("PG", 0); | ||
| allApplicantNum.put("PM", 0); | ||
| allApplicantNum.put("DE", 0); | ||
|
|
||
| // value = Registration | ||
| for (String key : allRegistration.keySet()){ | ||
| Registration registration = allRegistration.get(key); | ||
| allApplicantNum.put(registration.getHopeField(), allApplicantNum.get(registration.getHopeField()) + 1); | ||
| } | ||
|
|
||
| // WEB, APP, AI, GAME | ||
| // key = firstPriority, secondPriority | ||
| Map<String, int[]> allApplicantPriority = new HashMap<>(); | ||
|
|
||
| allApplicantPriority.put("WEB", new int[2]); | ||
| allApplicantPriority.put("APP", new int[2]); | ||
| allApplicantPriority.put("AI", new int[2]); | ||
| allApplicantPriority.put("GAME", new int[2]); | ||
|
|
||
| // value = Registration | ||
| for (String key : allRegistration.keySet()){ | ||
| Registration registration = allRegistration.get(key); | ||
| int[] firstPriority = allApplicantPriority.get(registration.getFirstPriority()); | ||
| int[] secondPriority = allApplicantPriority.get(registration.getSecondPriority()); | ||
|
|
||
| firstPriority[0] += 1; | ||
| secondPriority[1] += 1; | ||
|
|
||
| } | ||
|
|
||
|
Comment on lines
+42
to
+51
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. 1씩 늘려가며 집계하는 코드는 좋지 않습니다. 나중에 100만건이 있으면 100만번 더하는 것이 좋을까요? 다시 고민! |
||
| return new ApplicantMapper(allApplicantNum, allApplicantPriority); | ||
| } | ||
|
|
||
| // public Map<String, int[]> getAllApplicantPriority(){ | ||
| // Map<String, Registration> allRegistration = db.getAllRegistration(); | ||
| // // WEB, APP, AI, GAME | ||
| // Map<String, int[]> allApplicantPriority = new HashMap<>(); | ||
| // | ||
| // allApplicantPriority.put("WEB", new int[2]); | ||
| // allApplicantPriority.put("APP", new int[2]); | ||
| // allApplicantPriority.put("AI", new int[2]); | ||
| // allApplicantPriority.put("GAME", new int[2]); | ||
| // | ||
| // // value = Registration | ||
| // for (String key : allRegistration.keySet()){ | ||
| // Registration registration = allRegistration.get(key); | ||
| // int[] firstPriority = allApplicantPriority.get(registration.getFirstPriority()); | ||
| // int[] secondPriority = allApplicantPriority.get(registration.getSecondPriority()); | ||
| // | ||
| // firstPriority[0] += 1; | ||
| // secondPriority[1] += 1; | ||
| // | ||
| // } | ||
| // return allApplicantPriority; | ||
| // } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package com.econovation.third_project.service; | ||
|
|
||
| import com.econovation.third_project.database.Database; | ||
| import com.econovation.third_project.database.DesiredTime; | ||
| import java.util.Map; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class GetDesiredTime { | ||
|
|
||
| private final Database db; | ||
|
|
||
| public DesiredTimeMapper getAllDesiredTime() { | ||
| Map<String, DesiredTime> allDesiredTime = db.getAllDesiredTime(); | ||
| for (String key : allDesiredTime.keySet()){ | ||
| DesiredTime desiredTime = allDesiredTime.get(key); | ||
| for (int[] times: desiredTime.getDesiredTime()){ | ||
| int startTime = times[0]; | ||
| int endTime = times[1]; | ||
|
|
||
|
|
||
| } | ||
|
Comment on lines
+15
to
+24
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. return이 없는데 덜 짜신건가요??
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. 네...덜 짰습니다 |
||
|
|
||
| } | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package com.econovation.third_project.service; | ||
|
|
||
| import com.econovation.third_project.database.Database; | ||
| import com.econovation.third_project.database.PersonalInformation; | ||
| import com.econovation.third_project.database.Registration; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class GetMajor { | ||
| private final Database db; | ||
|
|
||
| public Map<String, Integer> getAllMajor(){ | ||
| Map<String, PersonalInformation> allPersonalInformation = db.getAllPersonalInformation(); | ||
| // PG 개발자, PM 기획자, DE 디자이너 | ||
| // key = hopeField, value = 몇 명인지 | ||
| Map<String, Integer> allMajor = new HashMap<>(); | ||
|
|
||
|
|
||
| for (String key : allPersonalInformation.keySet()){ | ||
| PersonalInformation personalInformation = allPersonalInformation.get(key); | ||
|
|
||
| String major = personalInformation.getMajor(); | ||
| String doubleMajor = personalInformation.getDoubleMajor(); | ||
| String minor = personalInformation.getMinor(); | ||
|
|
||
| // 리팩토링 예정 | ||
| if(!allMajor.containsKey(major)){ | ||
| allMajor.put(major, 0); | ||
| } | ||
| if(!allMajor.containsKey(doubleMajor)){ | ||
| allMajor.put(doubleMajor, 0); | ||
| } | ||
| if(!allMajor.containsKey(minor)){ | ||
| allMajor.put(minor, 0); | ||
| } | ||
|
|
||
| allMajor.put(major, allMajor.get(major) + 1); | ||
| allMajor.put(doubleMajor, allMajor.get(doubleMajor) + 1); | ||
| allMajor.put(minor, allMajor.get(minor) + 1); | ||
|
Comment on lines
+31
to
+43
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. 르블랑의 법칙 |
||
| } | ||
| return allMajor; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package com.econovation.third_project.service; | ||
|
|
||
| import com.econovation.third_project.database.Database; | ||
| import com.econovation.third_project.database.Path; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class GetPath { | ||
| private final Database db; | ||
|
|
||
| public Map<String, Integer> getAllApplicantNum(){ | ||
| Map<String, Path> allPath = db.getAllPath(); | ||
| // 홍보 포스터, 학과 공지사항, 지인 소개, 인스타그램, 에브리타임 | ||
| // key = supportPath, value = 몇 명인지 | ||
| Map<String, Integer> allSupportPath = new HashMap<>(); | ||
| allSupportPath.put("홍보 포스터", 0); | ||
| allSupportPath.put("학과 공지사항", 0); | ||
| allSupportPath.put("지인 소개", 0); | ||
| allSupportPath.put("지인 인스타그램", 0); | ||
| allSupportPath.put("에브리타임", 0); | ||
|
|
||
| for (String key : allPath.keySet()){ | ||
| Path path = allPath.get(key); | ||
| allSupportPath.put(path.getSupportPath(), allSupportPath.get(path.getSupportPath()) + 1); | ||
| } | ||
| return allSupportPath; | ||
| } | ||
| } |
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.
put put put put 해서 메소드 하나에 별도로 인덱스를 접근해서 초기화 하는 코드 하나로 지금 거의 10줄이 넘게 소요되고 있죠? 차라리 init 함수를 따로 빼도 좋겠습니다.