- Timestamp:
- 01/11/21 18:57:03 (4 years ago)
- Branches:
- master
- Children:
- 8f1f460
- Parents:
- fc8421e
- Location:
- src/main/java/it/finki/tinki
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/it/finki/tinki/bootstrap/DataHolder.java
rfc8421e r5f9d25a 34 34 @PostConstruct 35 35 public void init(){ 36 if( skillRepository.findAll().size()==0){36 if(this.skillRepository.findAll().size()==0){ 37 37 Skill s1 = new Skill("C++"); 38 38 Skill s2 = new Skill("Java"); … … 46 46 Skill s0 = new Skill("Go"); 47 47 48 skillRepository.save(s1);49 skillRepository.save(s2);50 skillRepository.save(s3);51 skillRepository.save(s4);52 skillRepository.save(s5);53 skillRepository.save(s6);54 skillRepository.save(s7);55 skillRepository.save(s8);56 skillRepository.save(s9);57 skillRepository.save(s0);48 this.skillRepository.save(s1); 49 this.skillRepository.save(s2); 50 this.skillRepository.save(s3); 51 this.skillRepository.save(s4); 52 this.skillRepository.save(s5); 53 this.skillRepository.save(s6); 54 this.skillRepository.save(s7); 55 this.skillRepository.save(s8); 56 this.skillRepository.save(s9); 57 this.skillRepository.save(s0); 58 58 } 59 59 60 60 List<Skill> lista; 61 lista = skillRepository.findAll();61 lista = this.skillRepository.findAll(); 62 62 63 63 List<Skill> l2 = new ArrayList<>(); 64 l2.add( skillRepository.getOne(3L));65 l2.add( skillRepository.getOne(10L));66 l2.add( skillRepository.getOne(1L));67 l2.add( skillRepository.getOne(2L));68 l2.add( skillRepository.getOne(4L));69 l2.add( skillRepository.getOne(5L));70 l2.add( skillRepository.getOne(6L));71 l2.add( skillRepository.getOne(7L));64 l2.add(this.skillRepository.findById(3L).get()); 65 l2.add(this.skillRepository.findById(2L).get()); 66 l2.add(this.skillRepository.findById(4L).get()); 67 l2.add(this.skillRepository.findById(7L).get()); 68 l2.add(this.skillRepository.findById(1L).get()); 69 l2.add(this.skillRepository.findById(5L).get()); 70 l2.add(this.skillRepository.findById(9L).get()); 71 l2.add(this.skillRepository.findById(6L).get()); 72 72 73 73 74 74 List<Skill> l3 = new ArrayList<>(); 75 l3.add(skillRepository.getOne(3L)); 76 l3.add(skillRepository.getOne(10L)); 77 l3.add(skillRepository.getOne(5L)); 78 l3.add(skillRepository.getOne(6L)); 79 l3.add(skillRepository.getOne(7L)); 75 l3.add(this.skillRepository.findById(3L).get()); 76 l3.add(this.skillRepository.findById(2L).get()); 77 l3.add(this.skillRepository.findById(4L).get()); 78 l3.add(this.skillRepository.findById(7L).get()); 80 79 81 80 List<Long> ids = new ArrayList<>(); … … 94 93 }); 95 94 96 Account c = this.accountService.registerCompany(" asdf@asdf", "pass", "Co.co", "Macedonia", "Skopje", "Pero Nakov");97 Account m = this.accountService.registerTeam(" asdf", "asd", "TeamRocket", 3);95 Account c = this.accountService.registerCompany("company@company", "company", "Co.co", "Macedonia", "Skopje", "Pero Nakov"); 96 Account m = this.accountService.registerTeam("team@team", "team", "TeamRocket", 3); 98 97 99 Job z =this.workService.insertJob("asdfq", "asdfqw", m.getId() ,5000, smalls, AccountType.TEAM);100 Job n =this.workService.insertJob("asdfq", "asdfqw", c.getId() ,5000, sm2, AccountType.COMPANY);101 Job j =this.workService.insertJob("Asdf", "Asdfa", c.getId() ,5000, ids, AccountType.COMPANY);102 Job k =this.workService.insertJob("Asdf", "Asdfa", m.getId() ,5000, ids, AccountType.TEAM);98 this.workService.insertJob("asdfq", "asdfqw", m.getId() ,5000, smalls, AccountType.TEAM); 99 this.workService.insertJob("asdfq", "asdfqw", c.getId() ,5000, sm2, AccountType.COMPANY); 100 this.workService.insertJob("Asdf", "Asdfa", c.getId() ,5000, ids, AccountType.COMPANY); 101 this.workService.insertJob("Asdf", "Asdfa", m.getId() ,5000, ids, AccountType.TEAM); 103 102 104 Account u = this.accountService.registerUser("asdf", "asdfq", "Zoki", "Poki", lista, lista);103 this.accountService.registerUser("user@user", "user", "Zoki", "Poki", l3, lista); 105 104 106 105 } -
src/main/java/it/finki/tinki/model/dto/response/account/CompanyResponseDTO.java
rfc8421e r5f9d25a 16 16 17 17 public CompanyResponseDTO(){ 18 super(); 18 19 this.jobs = new ArrayList<>(); 19 20 this.internships = new ArrayList<>(); -
src/main/java/it/finki/tinki/model/dto/response/account/TeamResponseDTO.java
rfc8421e r5f9d25a 15 15 16 16 public TeamResponseDTO(){ 17 super(); 17 18 this.jobs = new ArrayList<>(); 18 19 this.projects = new ArrayList<>(); -
src/main/java/it/finki/tinki/service/impl/WorkServiceImpl.java
rfc8421e r5f9d25a 7 7 import it.finki.tinki.model.Skill; 8 8 import it.finki.tinki.model.Users.Account; 9 import it.finki.tinki.model.Work.Work;10 9 import it.finki.tinki.model.dto.response.work.InternshipResponseDTO; 11 10 import it.finki.tinki.model.dto.response.work.JobResponseDTO; 12 11 import it.finki.tinki.model.dto.response.work.ProjectResponseDTO; 13 import it.finki.tinki.model.dto.response.work.WorkResponseDTO;14 12 import it.finki.tinki.model.enumerator.AccountType; 15 13 import it.finki.tinki.repository.*; -
src/main/java/it/finki/tinki/web/controller/AccountEditController.java
rfc8421e r5f9d25a 13 13 import it.finki.tinki.model.enumerator.AccountType; 14 14 import it.finki.tinki.service.AccountService; 15 import it.finki.tinki.service.BuilderService; 15 16 import it.finki.tinki.service.SkillService; 16 17 import org.springframework.web.bind.annotation.*; … … 26 27 AccountService accountService; 27 28 SkillService skillService; 29 BuilderService builderService; 28 30 29 public AccountEditController(AccountService accountService, SkillService skillService ) {31 public AccountEditController(AccountService accountService, SkillService skillService, BuilderService builderService) { 30 32 this.accountService = accountService; 31 33 this.skillService = skillService; 34 this.builderService = builderService; 32 35 } 33 36 34 @PostMapping(path = "/user/{id} /{email}")37 @PostMapping(path = "/user/{id}") 35 38 public UserResponseDTO editUser(@PathVariable(name = "id") Long id, 36 @PathVariable(name = "email") String email,37 39 @RequestBody UserRegisterDTO body){ 38 40 39 Optional<?> a = this.accountService.findByIdAndEmail(id, email, AccountType.USER);41 Optional<?> a = this.accountService.findByIdAndEmail(id, body.getEmail(), AccountType.USER); 40 42 41 43 if(a.isPresent()){ 42 44 List<Skill> retained = this.skillService.returnSkillsBasedOnId(body.getRetainedSkills()); 43 45 List<Skill> toLearn = this.skillService.returnSkillsBasedOnId(body.getSkillsToLearn()); 44 45 46 User u = this.accountService.editUser(id, body.getEmail(), body.getName(), body.getSurname(), retained, toLearn); 46 47 UserResponseDTO userResponseDTO = new UserResponseDTO(); 48 49 userResponseDTO.setId(u.getId()); 50 userResponseDTO.setEmail(u.getEmail()); 51 userResponseDTO.setType(AccountType.USER); 52 userResponseDTO.setError(null); 53 userResponseDTO.setName(u.getName()); 54 userResponseDTO.setSurname(u.getSurname()); 55 userResponseDTO.setRetained(u.getRetainedSkills()); 56 userResponseDTO.setToLearn(u.getSkillsToLearn()); 57 58 return userResponseDTO; 47 return this.builderService.buildUserResponseDTO(u); 59 48 } 60 49 61 return n ull;50 return new UserResponseDTO(); 62 51 } 63 52 64 @PostMapping(path = "/company/{id} /{email}")53 @PostMapping(path = "/company/{id}") 65 54 public CompanyResponseDTO editCompany(@PathVariable(name = "id") Long id, 66 @PathVariable(name = "email") String email,67 55 @RequestBody CompanyRegisterDTO body){ 68 56 69 Optional<?> a = this.accountService.findByIdAndEmail(id, email, AccountType.COMPANY);57 Optional<?> a = this.accountService.findByIdAndEmail(id, body.getEmail(), AccountType.COMPANY); 70 58 71 59 if(a.isPresent()){ 72 60 Company c = this.accountService.editCompany(id, body.getEmail(), body.getName(), body.getCountry(), body.getCity(), body.getStreet()); 73 74 CompanyResponseDTO companyResponseDTO = new CompanyResponseDTO(); 75 76 companyResponseDTO.setId(c.getId()); 77 companyResponseDTO.setEmail(c.getEmail()); 78 companyResponseDTO.setError(null); 79 companyResponseDTO.setType(AccountType.COMPANY); 80 companyResponseDTO.setName(c.getName()); 81 companyResponseDTO.setAddress(c.getAddress()); 82 83 return companyResponseDTO; 61 return this.builderService.buildCompanyResponseDTO(c); 84 62 } 85 63 86 return n ull;64 return new CompanyResponseDTO(); 87 65 } 88 66 89 @PostMapping(path = "/team/{id} /{email}")67 @PostMapping(path = "/team/{id}") 90 68 public TeamResponseDTO editTeam(@PathVariable(name = "id") Long id, 91 @PathVariable(name = "email") String email,92 69 @RequestBody TeamRegisterDTO body){ 93 70 94 Optional<?> a = this.accountService.findByIdAndEmail(id, email, AccountType.TEAM);71 Optional<?> a = this.accountService.findByIdAndEmail(id, body.getEmail(), AccountType.TEAM); 95 72 96 73 if(a.isPresent()){ 97 74 Team t = this.accountService.editTeam(id, body.getEmail(), body.getName(), body.getMembers()); 98 99 TeamResponseDTO teamResponseDTO = new TeamResponseDTO(); 100 101 teamResponseDTO.setId(t.getId()); 102 teamResponseDTO.setEmail(t.getEmail()); 103 teamResponseDTO.setError(null); 104 teamResponseDTO.setType(AccountType.TEAM); 105 teamResponseDTO.setName(t.getName()); 106 teamResponseDTO.setMembers(t.getMembers()); 107 108 return teamResponseDTO; 75 return this.builderService.buildTeamResponseDTO(t); 109 76 } 110 77 111 return n ull;78 return new TeamResponseDTO(); 112 79 } 113 80 } -
src/main/java/it/finki/tinki/web/controller/AccountRegisterController.java
rfc8421e r5f9d25a 38 38 List<Skill> retained = this.skillService.returnSkillsBasedOnId(body.getRetainedSkills()); 39 39 List<Skill> toLearn = this.skillService.returnSkillsBasedOnId(body.getSkillsToLearn()); 40 41 40 Account k = this.accountService.registerUser(body.getEmail(), body.getPassword(), body.getName(), body.getSurname(), retained, toLearn); 42 43 41 Map<String, String> response = new HashMap<>(); 44 42 … … 56 54 57 55 Account k = this.accountService.registerTeam(body.getEmail(), body.getPassword(), body.getName(), body.getMembers()); 58 59 56 Map<String, String> response = new HashMap<>(); 60 57 … … 73 70 Account k = this.accountService.registerCompany(body.getEmail(), 74 71 body.getPassword(), body.getName(), body.getCountry(), body.getCity(), body.getStreet()); 75 76 72 Map<String, String> response = new HashMap<>(); 77 73 -
src/main/java/it/finki/tinki/web/controller/LoginController.java
rfc8421e r5f9d25a 18 18 import it.finki.tinki.model.enumerator.AccountType; 19 19 import it.finki.tinki.service.AccountService; 20 import it.finki.tinki.service.BuilderService; 20 21 import it.finki.tinki.service.MatchmakerService; 21 22 import it.finki.tinki.service.WorkService; … … 31 32 32 33 AccountService accountService; 33 MatchmakerService matchmakerService;34 34 WorkService workService; 35 BuilderService builderService; 35 36 36 public LoginController(AccountService accountService, MatchmakerService matchmakerService, WorkService workService) {37 public LoginController(AccountService accountService, WorkService workService, BuilderService builderService) { 37 38 this.accountService = accountService; 38 this.matchmakerService = matchmakerService;39 39 this.workService = workService; 40 this.builderService = builderService; 40 41 } 41 42 … … 43 44 public LoginResponseDTO loginProcess(@RequestBody AccountLoginDTO body) throws ResponseStatusException { 44 45 45 System.out.println(body);46 46 Account a1 = accountService.findUser(body.getEmail(), body.getPassword(), body.getType()); 47 47 48 48 if(a1!=null){ 49 49 if(a1.getClass().equals(User.class)){ 50 return processUser(a1);50 return this.builderService.buildUserResponseDTO(a1); 51 51 }else if(a1.getClass().equals(Team.class)){ 52 return processTeam(a1);52 return this.builderService.buildTeamResponseDTO(a1); 53 53 }else{ 54 return processCompany(a1);54 return this.builderService.buildCompanyResponseDTO(a1); 55 55 } 56 56 } 57 57 58 58 return new LoginResponseDTO(); 59 }60 61 private UserResponseDTO processUser(Account a1){62 UserResponseDTO uDto = new UserResponseDTO();63 64 uDto.setError(null);65 66 uDto.setId(a1.getId());67 uDto.setEmail(a1.getEmail());68 uDto.setName(a1.getName());69 uDto.setType(AccountType.USER);70 uDto.setSurname(((User) a1).getSurname());71 72 uDto.setRetained(((User) a1).getRetainedSkills());73 uDto.setToLearn(((User) a1).getSkillsToLearn());74 75 List<Job> matchedJobs = this.matchmakerService.getMatchingJobsForUser((User) a1);76 List<Project> matchedProjects = this.matchmakerService.getMatchingProjectsForUser((User) a1);77 List<Internship> matchedInternships = this.matchmakerService.getMatchingInternshipsForUser((User) a1);78 79 matchedJobs.forEach(job -> {80 JobResponseDTO dto = new JobResponseDTO(job);81 uDto.getJobs().add(dto);82 });83 84 matchedProjects.forEach(project -> {85 ProjectResponseDTO dto = new ProjectResponseDTO(project);86 uDto.getProjects().add(dto);87 });88 89 matchedInternships.forEach(internship -> {90 InternshipResponseDTO dto = new InternshipResponseDTO(internship);91 uDto.getInternships().add(dto);92 });93 94 95 return uDto;96 }97 98 private TeamResponseDTO processTeam(Account a1){99 TeamResponseDTO tDto = new TeamResponseDTO();100 101 tDto.setError(null);102 103 tDto.setId(a1.getId());104 tDto.setEmail(a1.getEmail());105 tDto.setName(a1.getName());106 tDto.setType(AccountType.TEAM);107 tDto.setMembers(((Team) a1).getMembers());108 109 List<Job> jobs = this.workService.getAllJobsByAccount(a1.getId());110 List<Project> projects = this.workService.getAllProjectsByAccount(a1.getId());111 112 jobs.forEach(job -> {113 JobResponseDTO dto = new JobResponseDTO(job);114 tDto.getJobs().add(dto);115 });116 117 projects.forEach(project -> {118 ProjectResponseDTO dto = new ProjectResponseDTO(project);119 tDto.getProjects().add(dto);120 });121 122 return tDto;123 }124 125 private CompanyResponseDTO processCompany(Account a1){126 CompanyResponseDTO cDto = new CompanyResponseDTO();127 128 cDto.setError(null);129 130 cDto.setId(a1.getId());131 cDto.setEmail(a1.getEmail());132 cDto.setName(a1.getName());133 cDto.setType(AccountType.COMPANY);134 cDto.setAddress(((Company) a1).getAddress());135 136 List<Job> jobs = this.workService.getAllJobsByAccount(a1.getId());137 List<Internship> internships = this.workService.getAllInternshipsByAccount(a1.getId());138 139 jobs.forEach(job -> {140 JobResponseDTO dto = new JobResponseDTO(job);141 cDto.getJobs().add(dto);142 });143 144 internships.forEach(internship -> {145 InternshipResponseDTO dto = new InternshipResponseDTO(internship);146 cDto.getInternships().add(dto);147 });148 149 return cDto;150 59 } 151 60 … … 164 73 return this.workService.fullTextProjectSearch(text); 165 74 } 166 167 75 } -
src/main/java/it/finki/tinki/web/controller/WorkEditController.java
rfc8421e r5f9d25a 25 25 } 26 26 27 @PostMapping("/job/{userId}/{id}") 28 public JobResponseDTO editJob(@PathVariable Long userId, 29 @PathVariable Long id, 27 @PostMapping("/job/{id}") 28 public JobResponseDTO editJob(@PathVariable Long id, 30 29 @RequestBody JobRegisterDTO body){ 31 30 32 if( userId.equals(this.workService.getJobById(id).getAccount().getId())) {31 if(body.getAccountId().equals(this.workService.getJobById(id).getAccount().getId())) { 33 32 Job k = this.workService.editJob(id, body.getTitle(), body.getDescription(), body.getSalary()); 34 35 33 return new JobResponseDTO(k); 36 34 } 37 38 35 return null; 39 36 } 40 37 41 @PostMapping("/internship/{userId}/{id}") 42 public InternshipResponseDTO editInternship(@PathVariable Long userId, 43 @PathVariable Long id, 38 @PostMapping("/internship/{id}") 39 public InternshipResponseDTO editInternship(@PathVariable Long id, 44 40 @RequestBody InternshipRegisterDTO body){ 45 41 46 if( userId.equals(this.workService.getJobById(id).getAccount().getId())){42 if(body.getAccountId().equals(this.workService.getJobById(id).getAccount().getId())){ 47 43 Internship k = this.workService.editInternship(id, body.getTitle(), body.getDescription(), body.getSalary(), body.getOpenSpots()); 48 49 44 return new InternshipResponseDTO(k); 50 45 } 51 52 46 return null; 53 47 } 54 48 55 @PostMapping("/project/{userId}/{id}") 56 public ProjectResponseDTO editProject(@PathVariable Long userId, 57 @PathVariable Long id, 49 @PostMapping("/project/{id}") 50 public ProjectResponseDTO editProject(@PathVariable Long id, 58 51 @RequestBody ProjectRegisterDTO body){ 59 52 60 if( userId.equals(this.workService.getJobById(id).getAccount().getId())) {53 if(body.getAccountId().equals(this.workService.getJobById(id).getAccount().getId())) { 61 54 Project k = this.workService.editProject(id, body.getTitle(), body.getDescription(), body.getSalary()); 62 63 55 return new ProjectResponseDTO(k); 64 56 } 65 66 57 return null; 67 58 } -
src/main/java/it/finki/tinki/web/controller/WorkRegisterController.java
rfc8421e r5f9d25a 26 26 @PostMapping("/job") 27 27 public JobResponseDTO registerJob(@RequestBody JobRegisterDTO body){ 28 29 28 Job j = this.workService.insertJob(body.getTitle(), 30 29 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsRequired(), body.getType()); 31 32 30 return new JobResponseDTO(j); 33 31 } … … 35 33 @PostMapping("/internship") 36 34 public InternshipResponseDTO registerInternship(@RequestBody InternshipRegisterDTO body){ 37 38 35 Internship j = this.workService.insertInternship(body.getTitle(), 39 36 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsTrained(), body.getOpenSpots(), body.getType()); 40 41 37 return new InternshipResponseDTO(j); 42 38 } … … 44 40 @PostMapping("/project") 45 41 public ProjectResponseDTO registerProject(@RequestBody ProjectRegisterDTO body){ 46 47 42 Project j = this.workService.insertProject(body.getTitle(), 48 43 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsRequired(), body.getValidUntil(), body.getType()); 49 50 44 return new ProjectResponseDTO(j); 51 45 }
Note:
See TracChangeset
for help on using the changeset viewer.