- Timestamp:
- 01/07/21 22:32:22 (3 years ago)
- Branches:
- master
- Children:
- a8e8545
- Parents:
- 723994f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/it/finki/tinki/web/controller/RegisterController.java
r723994f r509cb95 1 1 package it.finki.tinki.web.controller; 2 2 3 import it.finki.tinki.helper.Matchmaker; 4 import it.finki.tinki.model.Jobs.Internship; 5 import it.finki.tinki.model.Jobs.Job; 6 import it.finki.tinki.model.Jobs.Project; 3 7 import it.finki.tinki.model.Skill; 4 8 import it.finki.tinki.model.Users.Account; 9 import it.finki.tinki.model.Users.User; 5 10 import it.finki.tinki.service.AccountService; 11 import it.finki.tinki.service.MatchmakerService; 6 12 import it.finki.tinki.service.SkillService; 13 import it.finki.tinki.service.WorkService; 7 14 import org.springframework.web.bind.annotation.*; 8 15 … … 18 25 AccountService accountService; 19 26 SkillService skillService; 27 WorkService workService; 28 MatchmakerService matchmakerService; 20 29 21 public RegisterController(AccountService accountService, SkillService skillService ) {30 public RegisterController(AccountService accountService, SkillService skillService, WorkService workService, MatchmakerService matchmakerService) { 22 31 this.accountService = accountService; 23 32 this.skillService = skillService; 33 this.workService = workService; 34 this.matchmakerService = matchmakerService; 24 35 } 25 36 26 37 @RequestMapping(path = "/user", method = RequestMethod.POST) 27 38 private Map<String, String> registerUser(@RequestParam String email, 28 29 30 31 32 39 @RequestParam String password, 40 @RequestParam String name, 41 @RequestParam String surname, 42 @RequestParam List<Integer> retainedSkills, 43 @RequestParam List<Integer> skillsToLearn){ 33 44 34 45 List<Skill> retained = this.skillService.returnSkillsBasedOnId(retainedSkills); … … 39 50 Map<String, String> response = new HashMap<>(); 40 51 41 if(k !=null){52 if(k==null){ 42 53 response.put("error", "There was an error when trying to register user."); 43 54 }else{ 55 List<Job> jobs = this.workService.getAllJobs(); 56 List<Project> projects = this.workService.getAllProjects(); 57 List<Internship> internships = this.workService.getAllInternships(); 58 59 jobs.forEach(job -> { 60 this.matchmakerService.setUpUserJobMatches(job, (User) k); 61 }); 62 63 projects.forEach(project -> { 64 this.matchmakerService.setUpUserProjectMatches(project, (User) k); 65 }); 66 67 internships.forEach(internship -> { 68 this.matchmakerService.setUpUserInternshipMatches(internship, (User) k); 69 }); 70 44 71 response.put("success", "Registration completed successfully."); 45 72 } … … 58 85 Map<String, String> response = new HashMap<>(); 59 86 60 if(k !=null){87 if(k==null){ 61 88 response.put("error", "There was an error when trying to register team."); 62 89 }else{ … … 79 106 Map<String, String> response = new HashMap<>(); 80 107 81 if(k !=null){108 if(k==null){ 82 109 response.put("error", "There was an error when trying to register company."); 83 110 }else{
Note:
See TracChangeset
for help on using the changeset viewer.