Changeset 277b400 for src/main/java/it/finki
- Timestamp:
- 01/08/21 15:11:40 (4 years ago)
- Branches:
- master
- Children:
- 31fc5c8
- Parents:
- 4b1c93d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/it/finki/tinki/web/controller/LoginController.java
r4b1c93d r277b400 34 34 35 35 @PostMapping(path = "/login") 36 public LoginResponseDTO testPage(@RequestBody AccountLoginDTO body) throws ResponseStatusException {36 public LoginResponseDTO loginProcess(@RequestBody AccountLoginDTO body) throws ResponseStatusException { 37 37 38 38 Account a1 = accountService.findUser(body.getEmail(), body.getPassword(), body.getType()); … … 40 40 if(a1!=null){ 41 41 if(a1.getClass().equals(User.class)){ 42 43 UserResponseDTO uDto = new UserResponseDTO(); 44 45 uDto.setError(null); 46 47 uDto.setId(a1.getId()); 48 uDto.setEmail(a1.getEmail()); 49 uDto.setName(a1.getName()); 50 uDto.setType(AccountType.USER); 51 uDto.setSurname(((User) a1).getSurname()); 52 53 uDto.setRetained(((User) a1).getRetainedSkills()); 54 uDto.setToLearn(((User) a1).getSkillsToLearn()); 55 56 List<Job> matchedJobs = this.matchmakerService.getMatchingJobsForUser((User) a1); 57 List<Project> matchedProjects = this.matchmakerService.getMatchingProjectsForUser((User) a1); 58 List<Internship> matchedInternships = this.matchmakerService.getMatchingInternshipsForUser((User) a1); 59 60 matchedJobs.forEach(job -> { 61 JobResponseDTO dto = new JobResponseDTO(job); 62 uDto.getJobs().add(dto); 63 }); 64 65 matchedProjects.forEach(project -> { 66 ProjectResponseDTO dto = new ProjectResponseDTO(project); 67 uDto.getProjects().add(dto); 68 }); 69 70 matchedInternships.forEach(internship -> { 71 InternshipResponseDTO dto = new InternshipResponseDTO(internship); 72 uDto.getInternships().add(dto); 73 }); 74 75 76 return uDto; 77 42 return processUser(a1); 78 43 }else if(a1.getClass().equals(Team.class)){ 79 80 TeamResponseDTO tDto = new TeamResponseDTO(); 81 82 tDto.setError(null); 83 84 tDto.setId(a1.getId()); 85 tDto.setEmail(a1.getEmail()); 86 tDto.setName(a1.getName()); 87 tDto.setType(AccountType.TEAM); 88 tDto.setMembers(((Team) a1).getMembers()); 89 90 List<Job> jobs = this.workService.getAllJobsByAccount(a1.getId()); 91 List<Project> projects = this.workService.getAllProjectsByAccount(a1.getId()); 92 93 jobs.forEach(job -> { 94 JobResponseDTO dto = new JobResponseDTO(job); 95 tDto.getJobs().add(dto); 96 }); 97 98 projects.forEach(project -> { 99 ProjectResponseDTO dto = new ProjectResponseDTO(project); 100 tDto.getProjects().add(dto); 101 }); 102 103 return tDto; 104 44 return processTeam(a1); 105 45 }else{ 106 107 CompanyResponseDTO cDto = new CompanyResponseDTO(); 108 109 cDto.setError(null); 110 111 cDto.setId(a1.getId()); 112 cDto.setEmail(a1.getEmail()); 113 cDto.setName(a1.getName()); 114 cDto.setType(AccountType.COMPANY); 115 cDto.setAddress(((Company) a1).getAddress()); 116 117 List<Job> jobs = this.workService.getAllJobsByAccount(a1.getId()); 118 List<Internship> internships = this.workService.getAllInternshipsByAccount(a1.getId()); 119 120 jobs.forEach(job -> { 121 JobResponseDTO dto = new JobResponseDTO(job); 122 cDto.getJobs().add(dto); 123 }); 124 125 internships.forEach(internship -> { 126 InternshipResponseDTO dto = new InternshipResponseDTO(internship); 127 cDto.getInternships().add(dto); 128 }); 129 130 return cDto; 131 46 return processCompany(a1); 132 47 } 133 48 } … … 136 51 } 137 52 53 private UserResponseDTO processUser(Account a1){ 54 UserResponseDTO uDto = new UserResponseDTO(); 55 56 uDto.setError(null); 57 58 uDto.setId(a1.getId()); 59 uDto.setEmail(a1.getEmail()); 60 uDto.setName(a1.getName()); 61 uDto.setType(AccountType.USER); 62 uDto.setSurname(((User) a1).getSurname()); 63 64 uDto.setRetained(((User) a1).getRetainedSkills()); 65 uDto.setToLearn(((User) a1).getSkillsToLearn()); 66 67 List<Job> matchedJobs = this.matchmakerService.getMatchingJobsForUser((User) a1); 68 List<Project> matchedProjects = this.matchmakerService.getMatchingProjectsForUser((User) a1); 69 List<Internship> matchedInternships = this.matchmakerService.getMatchingInternshipsForUser((User) a1); 70 71 matchedJobs.forEach(job -> { 72 JobResponseDTO dto = new JobResponseDTO(job); 73 uDto.getJobs().add(dto); 74 }); 75 76 matchedProjects.forEach(project -> { 77 ProjectResponseDTO dto = new ProjectResponseDTO(project); 78 uDto.getProjects().add(dto); 79 }); 80 81 matchedInternships.forEach(internship -> { 82 InternshipResponseDTO dto = new InternshipResponseDTO(internship); 83 uDto.getInternships().add(dto); 84 }); 85 86 87 return uDto; 88 } 89 90 private TeamResponseDTO processTeam(Account a1){ 91 TeamResponseDTO tDto = new TeamResponseDTO(); 92 93 tDto.setError(null); 94 95 tDto.setId(a1.getId()); 96 tDto.setEmail(a1.getEmail()); 97 tDto.setName(a1.getName()); 98 tDto.setType(AccountType.TEAM); 99 tDto.setMembers(((Team) a1).getMembers()); 100 101 List<Job> jobs = this.workService.getAllJobsByAccount(a1.getId()); 102 List<Project> projects = this.workService.getAllProjectsByAccount(a1.getId()); 103 104 jobs.forEach(job -> { 105 JobResponseDTO dto = new JobResponseDTO(job); 106 tDto.getJobs().add(dto); 107 }); 108 109 projects.forEach(project -> { 110 ProjectResponseDTO dto = new ProjectResponseDTO(project); 111 tDto.getProjects().add(dto); 112 }); 113 114 return tDto; 115 } 116 117 private CompanyResponseDTO processCompany(Account a1){ 118 CompanyResponseDTO cDto = new CompanyResponseDTO(); 119 120 cDto.setError(null); 121 122 cDto.setId(a1.getId()); 123 cDto.setEmail(a1.getEmail()); 124 cDto.setName(a1.getName()); 125 cDto.setType(AccountType.COMPANY); 126 cDto.setAddress(((Company) a1).getAddress()); 127 128 List<Job> jobs = this.workService.getAllJobsByAccount(a1.getId()); 129 List<Internship> internships = this.workService.getAllInternshipsByAccount(a1.getId()); 130 131 jobs.forEach(job -> { 132 JobResponseDTO dto = new JobResponseDTO(job); 133 cDto.getJobs().add(dto); 134 }); 135 136 internships.forEach(internship -> { 137 InternshipResponseDTO dto = new InternshipResponseDTO(internship); 138 cDto.getInternships().add(dto); 139 }); 140 141 return cDto; 142 } 143 138 144 }
Note:
See TracChangeset
for help on using the changeset viewer.