diff --git a/src/main/java/com/econovation/third_project/controller/Test.java b/src/main/java/com/econovation/third_project/controller/Test.java new file mode 100644 index 0000000..8c4e973 --- /dev/null +++ b/src/main/java/com/econovation/third_project/controller/Test.java @@ -0,0 +1,86 @@ +package com.econovation.third_project.controller; + +import com.econovation.third_project.database.DesiredTime; +import com.econovation.third_project.database.Path; +import com.econovation.third_project.database.PersonalInformation; +import com.econovation.third_project.database.Registration; +import com.econovation.third_project.service.RegistrationService; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.Map; + +@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 getHopeFieldsTotalRegisterCount(){ + return registrationService.getHopeFieldsTotalCount(); + } + + // 희망 분야별 지원자 수 + @GetMapping("/registrations/first-hope-field") + public Map getFirstHopeFieldCount() { + return registrationService.getHopeFieldsFirstPriorityCount(); + } + @GetMapping("/registrations/second-hope-field") + public Map getSecondHopeFieldCount() { + return registrationService.getHopeFieldsSecondPriorityCount(); + } + + // 지원자 학과별 수 + @GetMapping("/registrations/department-count") + public Map getDepartmentCount(){ + return registrationService.getDepartmentCount(); + } + + // 지원 경로별 수 + @GetMapping("/registrations/path-count") + public Map getPathCount(){ + return registrationService.getPathCount(); + } + +} diff --git a/src/main/java/com/econovation/third_project/database/Database.java b/src/main/java/com/econovation/third_project/database/Database.java index 33b8710..80ccccf 100644 --- a/src/main/java/com/econovation/third_project/database/Database.java +++ b/src/main/java/com/econovation/third_project/database/Database.java @@ -1,8 +1,7 @@ package com.econovation.third_project.database; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; +import java.util.*; + import org.springframework.stereotype.Component; /** @@ -22,7 +21,77 @@ public void register(Registration registrationRequest) { registration.put(UUID.randomUUID().toString(), registrationRequest); } + // PersonalInformation 생성 + public void savePersonalInformation(PersonalInformation personalInformationRequest){ + personalInformation.put(UUID.randomUUID().toString(), personalInformationRequest); + } + + // 지원 경로 생성 + public void savePath(Path pathRequest){ + path.put(UUID.randomUUID().toString(), pathRequest); + } + + // 가능 시간 생성 + public void saveDesiredTime(DesiredTime desiredTimeRequest){ + desiredTime.put(UUID.randomUUID().toString(),desiredTimeRequest); + } + public Registration getRegistration(String userId) { return registration.get(userId); } + + // 전체 등록 데이터 + public Map getAllRegistrations(){ + return registration; + } + + // 전체 소속 데이터 + public Map getAllPersionalInformation(){ + return personalInformation; + } + + // 전체 경로 데이터 + public Map getAllPath(){ + return path; + } + + // 전체 시간 데이터 + public Map getAllDesiredTime(){ + return desiredTime; + } + + // 서비스 파일에 작성해야 하는 로직인지 확인하기 + public int getRegistrationCount(){ + return registration.size(); + } + + // 개발자, 기획자, 디자이너 각각 Count // 서비스 파일에 작성해야 하는 로직인지 확인하기 + public ArrayList getHopeFieldsTotalCount(){ + ArrayList hopeFields = new ArrayList(3); + // 초기화 방식도 뭔가 이상하다 + hopeFields.add(0); + hopeFields.add(0); + hopeFields.add(0); + Integer count = 0; + // 할 수 있는 조회 방법, 너무 하드 코딩 같다 + for(Map.Entry 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; + } + } \ No newline at end of file diff --git a/src/main/java/com/econovation/third_project/database/Path.java b/src/main/java/com/econovation/third_project/database/Path.java index 727433c..1bd9b6a 100644 --- a/src/main/java/com/econovation/third_project/database/Path.java +++ b/src/main/java/com/econovation/third_project/database/Path.java @@ -8,5 +8,5 @@ public class Path { String registrationId; // 지원 경로 - private String supportPath; + private PathType supportPath; } diff --git a/src/main/java/com/econovation/third_project/database/PathType.java b/src/main/java/com/econovation/third_project/database/PathType.java new file mode 100644 index 0000000..41334ac --- /dev/null +++ b/src/main/java/com/econovation/third_project/database/PathType.java @@ -0,0 +1,18 @@ +package com.econovation.third_project.database; + +public enum PathType { + POSTER("홍보 포스터"), + ANNOUNCEMENT("학과 공지사항"), + INTRODUCTION("지인 소개"), + INSTAGRAM("인스타그램"), + EVERYTIME("에브리타임"), + ETIC("기타"); + + final private String type; + public String getType(){ + return type; + } + private PathType(String type){ + this.type = type; + } +} diff --git a/src/main/java/com/econovation/third_project/service/RegistrationService.java b/src/main/java/com/econovation/third_project/service/RegistrationService.java new file mode 100644 index 0000000..ec3aa12 --- /dev/null +++ b/src/main/java/com/econovation/third_project/service/RegistrationService.java @@ -0,0 +1,88 @@ +package com.econovation.third_project.service; + +import com.econovation.third_project.database.*; +import lombok.AllArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +@AllArgsConstructor +public class RegistrationService { + private final Database database; + + // 지원자 등록 + public void register(Registration registration){ + database.register(registration); + } + + // 개인 정보 등록 + public void registerPersonalInform(PersonalInformation personalInformation){database.savePersonalInformation(personalInformation);} + + // 지원 경로 정보 등록 + public void registerPath(Path path){database.savePath(path);} + + // 면접 가능 시간 등록 + public void registerDesiredTime(DesiredTime desiredTime){database.saveDesiredTime(desiredTime);} + + // 전체 지원자 수 누적 합 + public int getRegistrationCount(){ + return database.getRegistrationCount(); + } + + // 각 분야별 합 + // database의 registration을 조회, 조회하면서 getRegistration을 통해 Registration을 가져옴 + // 들어있는 분야 별로 Count하기 (개발자, 기획자, 디자이너) + public ArrayList getHopeFieldsTotalCount(){ + return database.getHopeFieldsTotalCount(); + } + + // 희망 분야별 합 + // 등록시 1지망 2지망을 나눠서 토탈 카운트 + // 희망 분야별 합은 service 파일에서 작성 + public Map getHopeFieldsFirstPriorityCount() { + Map firstHopeFieldCount = new HashMap<>(); + for (Registration registration : database.getAllRegistrations().values()) { + String firstHopeField = registration.getFirstPriority(); + firstHopeFieldCount.put(firstHopeField, firstHopeFieldCount.getOrDefault(firstHopeField, 0) + 1); // getOrDefault + } + return firstHopeFieldCount; + } + + public Map getHopeFieldsSecondPriorityCount() { + Map secondHopeFieldCount = new HashMap<>(); + for (Registration registration : database.getAllRegistrations().values()) { + String secondHopeField = registration.getSecondPriority(); + secondHopeFieldCount.put(secondHopeField, secondHopeFieldCount.getOrDefault(secondHopeField, 0) + 1); + } + return secondHopeFieldCount; + } + + // 소속 학과 합 + public Map getDepartmentCount(){ + Map departmentCount = new HashMap<>(); + for(PersonalInformation personalInformation : database.getAllPersionalInformation().values()){ + String major = personalInformation.getMajor(); + departmentCount.put(major, departmentCount.getOrDefault(major,0)+1); + } + return departmentCount; + } + + // 지원 경로 통계 + public Map getPathCount(){ + Map pathCount = new HashMap<>(); + for(Path path : database.getAllPath().values()){ + String p = path.getSupportPath().getType(); + pathCount.put(p,pathCount.getOrDefault(p,0)+1); + } + return pathCount; + } + + // 면접 희망 시간 통계 + + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 1993f05..b19a37d 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1 +1,2 @@ spring.application.name=HellStudy +