Ignore:
Timestamp:
01/07/21 22:32:22 (3 years ago)
Author:
Vzdra <vladko.zdravkovski@…>
Branches:
master
Children:
a8e8545
Parents:
723994f
Message:

finalized register and login and added insert options for jobs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/it/finki/tinki/web/controller/RegisterController.java

    r723994f r509cb95  
    11package it.finki.tinki.web.controller;
    22
     3import it.finki.tinki.helper.Matchmaker;
     4import it.finki.tinki.model.Jobs.Internship;
     5import it.finki.tinki.model.Jobs.Job;
     6import it.finki.tinki.model.Jobs.Project;
    37import it.finki.tinki.model.Skill;
    48import it.finki.tinki.model.Users.Account;
     9import it.finki.tinki.model.Users.User;
    510import it.finki.tinki.service.AccountService;
     11import it.finki.tinki.service.MatchmakerService;
    612import it.finki.tinki.service.SkillService;
     13import it.finki.tinki.service.WorkService;
    714import org.springframework.web.bind.annotation.*;
    815
     
    1825    AccountService accountService;
    1926    SkillService skillService;
     27    WorkService workService;
     28    MatchmakerService matchmakerService;
    2029
    21     public RegisterController(AccountService accountService, SkillService skillService) {
     30    public RegisterController(AccountService accountService, SkillService skillService, WorkService workService, MatchmakerService matchmakerService) {
    2231        this.accountService = accountService;
    2332        this.skillService = skillService;
     33        this.workService = workService;
     34        this.matchmakerService = matchmakerService;
    2435    }
    2536
    2637    @RequestMapping(path = "/user", method = RequestMethod.POST)
    2738    private Map<String, String> registerUser(@RequestParam String email,
    28                                                 @RequestParam String password,
    29                                                 @RequestParam String name,
    30                                                 @RequestParam String surname,
    31                                                 @RequestParam List<Integer> retainedSkills,
    32                                                 @RequestParam List<Integer> skillsToLearn){
     39                                             @RequestParam String password,
     40                                             @RequestParam String name,
     41                                             @RequestParam String surname,
     42                                             @RequestParam List<Integer> retainedSkills,
     43                                             @RequestParam List<Integer> skillsToLearn){
    3344
    3445        List<Skill> retained = this.skillService.returnSkillsBasedOnId(retainedSkills);
     
    3950        Map<String, String> response = new HashMap<>();
    4051
    41         if(k!=null){
     52        if(k==null){
    4253            response.put("error", "There was an error when trying to register user.");
    4354        }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
    4471            response.put("success", "Registration completed successfully.");
    4572        }
     
    5885        Map<String, String> response = new HashMap<>();
    5986
    60         if(k!=null){
     87        if(k==null){
    6188            response.put("error", "There was an error when trying to register team.");
    6289        }else{
     
    79106        Map<String, String> response = new HashMap<>();
    80107
    81         if(k!=null){
     108        if(k==null){
    82109            response.put("error", "There was an error when trying to register company.");
    83110        }else{
Note: See TracChangeset for help on using the changeset viewer.