Changeset 33d4f5d for src/main/java
- Timestamp:
- 01/12/21 02:42:18 (4 years ago)
- Branches:
- master
- Children:
- a70db1a
- Parents:
- 8f1f460
- Location:
- src/main/java/it/finki/tinki
- Files:
-
- 1 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/it/finki/tinki/bootstrap/DataHolder.java
r8f1f460 r33d4f5d 11 11 12 12 import javax.annotation.PostConstruct; 13 import java.text.DateFormat; 13 14 import java.util.ArrayList; 15 import java.util.Date; 14 16 import java.util.List; 15 17 … … 61 63 lista = this.skillRepository.findAll(); 62 64 63 List<Skill> l 2 = new ArrayList<>();64 l 2.add(this.skillRepository.findById(3L).get());65 l 2.add(this.skillRepository.findById(2L).get());66 l 2.add(this.skillRepository.findById(4L).get());67 l 2.add(this.skillRepository.findById(7L).get());68 l 2.add(this.skillRepository.findById(1L).get());69 l 2.add(this.skillRepository.findById(5L).get());70 l 2.add(this.skillRepository.findById(9L).get());71 l 2.add(this.skillRepository.findById(6L).get());65 List<Skill> lista2 = new ArrayList<>(); 66 lista2.add(this.skillRepository.findById(3L).get()); 67 lista2.add(this.skillRepository.findById(2L).get()); 68 lista2.add(this.skillRepository.findById(4L).get()); 69 lista2.add(this.skillRepository.findById(7L).get()); 70 lista2.add(this.skillRepository.findById(1L).get()); 71 lista2.add(this.skillRepository.findById(5L).get()); 72 lista2.add(this.skillRepository.findById(9L).get()); 73 lista2.add(this.skillRepository.findById(6L).get()); 72 74 73 75 74 List<Skill> l 3 = new ArrayList<>();75 l 3.add(this.skillRepository.findById(3L).get());76 l 3.add(this.skillRepository.findById(2L).get());77 l 3.add(this.skillRepository.findById(4L).get());78 l 3.add(this.skillRepository.findById(7L).get());76 List<Skill> lista3 = new ArrayList<>(); 77 lista3.add(this.skillRepository.findById(3L).get()); 78 lista3.add(this.skillRepository.findById(2L).get()); 79 lista3.add(this.skillRepository.findById(4L).get()); 80 lista3.add(this.skillRepository.findById(7L).get()); 79 81 80 List<Long> ids = new ArrayList<>();82 List<Long> allSkills = new ArrayList<>(); 81 83 lista.forEach(item -> { 82 ids.add(item.getId());84 allSkills.add(item.getId()); 83 85 }); 84 86 85 List<Long> s malls= new ArrayList<>();86 l 2.forEach(item -> {87 s malls.add(item.getId());87 List<Long> skills8 = new ArrayList<>(); 88 lista2.forEach(item -> { 89 skills8.add(item.getId()); 88 90 }); 89 91 90 List<Long> s m2= new ArrayList<>();91 l 3.forEach(item -> {92 s m2.add(item.getId());92 List<Long> skills4 = new ArrayList<>(); 93 lista3.forEach(item -> { 94 skills4.add(item.getId()); 93 95 }); 94 96 95 Account c = this.accountService.registerCompany("company@company", "company", "Co.co", "Macedonia", "Skopje", "Pero Nakov"); 97 Account c = this.accountService.registerCompany("company@company", "company", "Co.Co", "Macedonia", "Skopje", "Pero Nakov"); 98 Account ct = this.accountService.registerCompany("company@co", "company", "Co.Co", "Macedonia", "Skopje", "Pero Nakov"); 96 99 Account m = this.accountService.registerTeam("team@team", "team", "TeamRocket", 3); 97 100 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); 101 this.workService.insertJob("Team Job 1", "Team job 1 requires 3 members!", m.getId() ,1515, allSkills, AccountType.TEAM); 102 this.workService.insertJob("Team Job 2", "Team job 2 requires 2 members!", m.getId() ,5511, skills4, AccountType.TEAM); 103 this.workService.insertJob("Company Job 1", "Company job 1 requires 3 members!", c.getId() ,12345, allSkills, AccountType.COMPANY); 104 this.workService.insertJob("Company Job 2", "Company job 2 requires 3 members!", ct.getId() ,8901, skills8, AccountType.COMPANY); 105 this.workService.insertInternship("Internship 1", "Opportunity to learn new things!", c.getId() ,5000, skills4, 6, AccountType.COMPANY); 106 this.workService.insertInternship("Internship 2", "Opportunity to learn new things!", c.getId() ,5000, allSkills, 3, AccountType.COMPANY); 107 this.workService.insertProject("Project 1", "Project that lasts few days!", m.getId() ,5000, skills8, new Date(), AccountType.TEAM); 108 this.workService.insertProject("Project 2", "Project that ends soon!", m.getId() ,5000, skills4, new Date(), AccountType.TEAM); 102 109 103 this.accountService.registerUser("user@user", "user", "Zoki", "Poki", l 3, lista);110 this.accountService.registerUser("user@user", "user", "Zoki", "Poki", lista3, lista); 104 111 105 112 } -
src/main/java/it/finki/tinki/model/dto/response/work/InternshipResponseDTO.java
r8f1f460 r33d4f5d 2 2 3 3 import it.finki.tinki.model.Address; 4 import it.finki.tinki.model.Skill; 4 5 import it.finki.tinki.model.Work.Internship; 5 6 import it.finki.tinki.model.Users.Company; 6 7 import lombok.Data; 8 9 import java.util.List; 7 10 8 11 @Data … … 11 14 int openSpots; 12 15 Address accountAddress; 16 List<Skill> skillsTrained; 17 18 public InternshipResponseDTO(){ 19 super(); 20 } 13 21 14 22 public InternshipResponseDTO(Internship internship){ … … 17 25 this.openSpots = internship.getOpenSpots(); 18 26 this.accountAddress = ((Company) internship.getAccount()).getAddress(); 27 this.skillsTrained = internship.getSkillsTrained(); 19 28 } 20 29 } -
src/main/java/it/finki/tinki/model/dto/response/work/JobResponseDTO.java
r8f1f460 r33d4f5d 2 2 3 3 import it.finki.tinki.model.Address; 4 import it.finki.tinki.model.Skill; 4 5 import it.finki.tinki.model.Work.Job; 5 6 import it.finki.tinki.model.Users.Company; … … 8 9 import lombok.Data; 9 10 11 import java.util.List; 12 10 13 @Data 11 14 public class JobResponseDTO extends WorkResponseDTO { 12 15 Address accountAddress; 13 16 int members; 17 List<Skill> skillsRequired; 18 19 public JobResponseDTO(){ 20 super(); 21 } 14 22 15 23 public JobResponseDTO(Job job){ 16 24 super(job.getId(), job.getTitle(), job.getDescription(), job.getSalary(), job.getAccount()); 25 this.skillsRequired = job.getSkillsRequired(); 17 26 if(job.getAccount().getAccountType()==AccountType.COMPANY){ 18 27 this.accountAddress = ((Company) job.getAccount()).getAddress(); -
src/main/java/it/finki/tinki/model/dto/response/work/ProjectResponseDTO.java
r8f1f460 r33d4f5d 1 1 package it.finki.tinki.model.dto.response.work; 2 2 3 import it.finki.tinki.model.Skill; 3 4 import it.finki.tinki.model.Work.Project; 4 5 import it.finki.tinki.model.Users.Team; 5 6 import lombok.Data; 6 7 8 import java.util.Date; 9 import java.util.List; 10 7 11 @Data 8 12 public class ProjectResponseDTO extends WorkResponseDTO { 9 13 int members; 14 Date validUntil; 15 List<Skill> skillsRequired; 16 17 public ProjectResponseDTO(){ 18 super(); 19 } 10 20 11 21 public ProjectResponseDTO(Project project){ 12 22 super(project.getId(), project.getTitle(), project.getDescription(), project.getSalary(), project.getAccount()); 13 23 this.members = ((Team) project.getAccount()).getMembers(); 24 this.validUntil = project.getValidUntil(); 25 this.skillsRequired = project.getSkillsRequired(); 14 26 } 15 27 } -
src/main/java/it/finki/tinki/model/dto/response/work/WorkResponseDTO.java
r8f1f460 r33d4f5d 14 14 String accountName; 15 15 AccountType accountType; 16 String error; 16 17 17 WorkResponseDTO(){} 18 WorkResponseDTO(){ 19 this.error = "Error registering job!"; 20 } 18 21 19 22 WorkResponseDTO(Long id, String title, String description, int salary, Account account){ 23 this.error = null; 20 24 this.id = id; 21 25 this.title = title; -
src/main/java/it/finki/tinki/repository/MatchRepository.java
r8f1f460 r33d4f5d 13 13 public interface MatchRepository extends JpaRepository<Match, EmbeddedMatchId> { 14 14 List<Match> findAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(User user, WorkType type); 15 List<Match> deleteAllByEmbeddedMatchId_User_Id(Long userId); 15 16 } -
src/main/java/it/finki/tinki/service/MatchmakerService.java
r8f1f460 r33d4f5d 1 1 package it.finki.tinki.service; 2 2 3 import it.finki.tinki.model.Match; 3 4 import it.finki.tinki.model.Work.Internship; 4 5 import it.finki.tinki.model.Work.Job; … … 15 16 void setUpUserProjectMatches(Project project, User user); 16 17 void setUpUserInternshipMatches(Internship internship, User user); 18 List<Match> removeByUserId(Long userId); 17 19 } -
src/main/java/it/finki/tinki/service/impl/AccountServiceImpl.java
r8f1f460 r33d4f5d 214 214 215 215 private void setUpUser(User u){ 216 217 this.matchmakerService.removeByUserId(u.getId()); 218 216 219 List<Job> jobs = this.jobRepository.findAll(); 217 220 List<Project> projects = this.projectRepository.findAll(); -
src/main/java/it/finki/tinki/service/impl/MatchmakerServiceImpl.java
r8f1f460 r33d4f5d 17 17 import org.springframework.stereotype.Service; 18 18 19 import javax.transaction.Transactional; 19 20 import java.util.ArrayList; 20 21 import java.util.List; … … 118 119 if(coef!=0){ 119 120 EmbeddedMatchId embeddedMatchId = new EmbeddedMatchId(internship, user); 120 Match m = new Match(embeddedMatchId, coef, WorkType. PROJECT);121 Match m = new Match(embeddedMatchId, coef, WorkType.INTERNSHIP); 121 122 this.matchRepository.save(m); 122 123 } 123 124 } 124 125 126 @Transactional 127 @Override 128 public List<Match> removeByUserId(Long userId) { 129 return this.matchRepository.deleteAllByEmbeddedMatchId_User_Id(userId); 130 } 125 131 126 132 } -
src/main/java/it/finki/tinki/web/controller/AccountEditController.java
r8f1f460 r33d4f5d 35 35 } 36 36 37 @PostMapping(path = "/user/{id} ")37 @PostMapping(path = "/user/{id}/{email}") 38 38 public UserResponseDTO editUser(@PathVariable(name = "id") Long id, 39 @PathVariable(name = "email") String email, 39 40 @RequestBody UserRegisterDTO body){ 40 41 41 Optional<?> a = this.accountService.findByIdAndEmail(id, body.getEmail(), AccountType.USER);42 Optional<?> a = this.accountService.findByIdAndEmail(id, email, AccountType.USER); 42 43 43 44 if(a.isPresent()){ … … 51 52 } 52 53 53 @PostMapping(path = "/company/{id} ")54 @PostMapping(path = "/company/{id}/{email}") 54 55 public CompanyResponseDTO editCompany(@PathVariable(name = "id") Long id, 56 @PathVariable(name = "email") String email, 55 57 @RequestBody CompanyRegisterDTO body){ 56 58 57 Optional<?> a = this.accountService.findByIdAndEmail(id, body.getEmail(), AccountType.COMPANY);59 Optional<?> a = this.accountService.findByIdAndEmail(id, email, AccountType.COMPANY); 58 60 59 61 if(a.isPresent()){ … … 65 67 } 66 68 67 @PostMapping(path = "/team/{id} ")69 @PostMapping(path = "/team/{id}/{email}") 68 70 public TeamResponseDTO editTeam(@PathVariable(name = "id") Long id, 71 @PathVariable(name = "email") String email, 69 72 @RequestBody TeamRegisterDTO body){ 70 73 71 Optional<?> a = this.accountService.findByIdAndEmail(id, body.getEmail(), AccountType.TEAM);74 Optional<?> a = this.accountService.findByIdAndEmail(id, email, AccountType.TEAM); 72 75 73 76 if(a.isPresent()){ -
src/main/java/it/finki/tinki/web/controller/AccountRegisterController.java
r8f1f460 r33d4f5d 7 7 import it.finki.tinki.model.dto.register.account.UserRegisterDTO; 8 8 import it.finki.tinki.service.AccountService; 9 import it.finki.tinki.service.MatchmakerService;10 9 import it.finki.tinki.service.SkillService; 11 import it.finki.tinki.service.WorkService;12 10 import org.springframework.web.bind.annotation.*; 13 11 … … 23 21 AccountService accountService; 24 22 SkillService skillService; 25 WorkService workService;26 MatchmakerService matchmakerService;27 23 28 public AccountRegisterController(AccountService accountService, SkillService skillService , WorkService workService, MatchmakerService matchmakerService) {24 public AccountRegisterController(AccountService accountService, SkillService skillService) { 29 25 this.accountService = accountService; 30 26 this.skillService = skillService; 31 this.workService = workService;32 this.matchmakerService = matchmakerService;33 27 } 34 28 -
src/main/java/it/finki/tinki/web/controller/LoginController.java
r8f1f460 r33d4f5d 1 1 package it.finki.tinki.web.controller; 2 2 3 import it.finki.tinki.model.Work.Internship;4 import it.finki.tinki.model.Work.Job;5 import it.finki.tinki.model.Work.Project;6 3 import it.finki.tinki.model.Users.Account; 7 import it.finki.tinki.model.Users.Company;8 4 import it.finki.tinki.model.Users.Team; 9 5 import it.finki.tinki.model.Users.User; 10 6 import it.finki.tinki.model.dto.*; 11 7 import it.finki.tinki.model.dto.response.account.LoginResponseDTO; 12 import it.finki.tinki.model.dto.response.account.CompanyResponseDTO;13 import it.finki.tinki.model.dto.response.account.TeamResponseDTO;14 import it.finki.tinki.model.dto.response.account.UserResponseDTO;15 import it.finki.tinki.model.dto.response.work.InternshipResponseDTO;16 import it.finki.tinki.model.dto.response.work.JobResponseDTO;17 import it.finki.tinki.model.dto.response.work.ProjectResponseDTO;18 import it.finki.tinki.model.enumerator.AccountType;19 8 import it.finki.tinki.service.AccountService; 20 9 import it.finki.tinki.service.BuilderService; 21 import it.finki.tinki.service.MatchmakerService;22 10 import it.finki.tinki.service.WorkService; 23 11 import org.springframework.web.bind.annotation.*; … … 32 20 33 21 AccountService accountService; 34 WorkService workService;35 22 BuilderService builderService; 36 23 37 public LoginController(AccountService accountService, WorkService workService,BuilderService builderService) {24 public LoginController(AccountService accountService, BuilderService builderService) { 38 25 this.accountService = accountService; 39 this.workService = workService;40 26 this.builderService = builderService; 41 27 } … … 58 44 return new LoginResponseDTO(); 59 45 } 60 61 @GetMapping(path = "/job/search")62 public List<JobResponseDTO> jobRes(@RequestParam(name = "text") String text){63 return this.workService.fullTextJobSearch(text);64 }65 66 @GetMapping(path = "/internship/search")67 public List<InternshipResponseDTO> internshipRes(@RequestParam(name = "text") String text){68 return this.workService.fullTextInternshipSearch(text);69 }70 71 @GetMapping(path = "/project/search")72 public List<ProjectResponseDTO> projectRes(@RequestParam(name = "text") String text){73 return this.workService.fullTextProjectSearch(text);74 }75 46 } -
src/main/java/it/finki/tinki/web/controller/WorkEditController.java
r8f1f460 r33d4f5d 14 14 import org.springframework.web.bind.annotation.*; 15 15 16 import java.util.HashMap; 17 import java.util.Map; 18 16 19 @RestController 17 20 @CrossOrigin(origins = "http://localhost:3000") … … 26 29 27 30 @PostMapping("/job/{id}") 28 public JobResponseDTO editJob(@PathVariable Long id, 29 @RequestBody JobRegisterDTO body){ 31 public Map<String, String> editJob(@PathVariable Long id, 32 @RequestBody JobRegisterDTO body){ 33 34 Map<String, String> response = new HashMap<>(); 30 35 31 36 if(body.getAccountId().equals(this.workService.getJobById(id).getAccount().getId())) { 32 37 Job k = this.workService.editJob(id, body.getTitle(), body.getDescription(), body.getSalary()); 33 return new JobResponseDTO(k); 38 if(k!=null){ 39 response.put("success", "Job edited successfully!"); 40 return response; 41 } 34 42 } 35 return null; 43 44 response.put("error", "Internship edit failed!"); 45 return response; 36 46 } 37 47 38 48 @PostMapping("/internship/{id}") 39 public InternshipResponseDTOeditInternship(@PathVariable Long id,49 public Map<String, String> editInternship(@PathVariable Long id, 40 50 @RequestBody InternshipRegisterDTO body){ 51 52 Map<String, String> response = new HashMap<>(); 41 53 42 54 if(body.getAccountId().equals(this.workService.getInternshipById(id).getAccount().getId())){ 43 55 Internship k = this.workService.editInternship(id, body.getTitle(), body.getDescription(), body.getSalary(), body.getOpenSpots()); 44 return new InternshipResponseDTO(k); 56 if(k!=null){ 57 response.put("success", "Internship edited successfully!"); 58 return response; 59 } 45 60 } 46 return null; 61 62 response.put("error", "Internship edit failed!"); 63 return response; 47 64 } 48 65 49 66 @PostMapping("/project/{id}") 50 public ProjectResponseDTOeditProject(@PathVariable Long id,67 public Map<String, String> editProject(@PathVariable Long id, 51 68 @RequestBody ProjectRegisterDTO body){ 69 70 Map<String, String> response = new HashMap<>(); 52 71 53 72 if(body.getAccountId().equals(this.workService.getProjectById(id).getAccount().getId())) { 54 73 Project k = this.workService.editProject(id, body.getTitle(), body.getDescription(), body.getSalary()); 55 return new ProjectResponseDTO(k); 74 if(k!=null){ 75 response.put("success", "Project edited successfully!"); 76 return response; 77 } 56 78 } 57 return null; 79 80 response.put("error", "Project edit failed!"); 81 return response; 58 82 } 59 83 } -
src/main/java/it/finki/tinki/web/controller/WorkRegisterController.java
r8f1f460 r33d4f5d 1 1 package it.finki.tinki.web.controller; 2 2 3 import it.finki.tinki.model.Users.Account; 3 4 import it.finki.tinki.model.Work.Internship; 4 5 import it.finki.tinki.model.Work.Job; … … 10 11 import it.finki.tinki.model.dto.response.work.JobResponseDTO; 11 12 import it.finki.tinki.model.dto.response.work.ProjectResponseDTO; 13 import it.finki.tinki.model.enumerator.AccountType; 12 14 import it.finki.tinki.service.WorkService; 13 15 import org.springframework.web.bind.annotation.*; … … 26 28 @PostMapping("/job") 27 29 public JobResponseDTO registerJob(@RequestBody JobRegisterDTO body){ 28 Job j = this.workService.insertJob(body.getTitle(), 29 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsRequired(), body.getType()); 30 return new JobResponseDTO(j); 30 31 if(body.getType() != AccountType.USER){ 32 Job j = this.workService.insertJob(body.getTitle(), 33 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsRequired(), body.getType()); 34 return new JobResponseDTO(j); 35 } 36 37 return new JobResponseDTO(); 31 38 } 32 39 33 40 @PostMapping("/internship") 34 41 public InternshipResponseDTO registerInternship(@RequestBody InternshipRegisterDTO body){ 35 Internship j = this.workService.insertInternship(body.getTitle(), 36 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsTrained(), body.getOpenSpots(), body.getType()); 37 return new InternshipResponseDTO(j); 42 if(body.getType() == AccountType.COMPANY){ 43 Internship j = this.workService.insertInternship(body.getTitle(), 44 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsTrained(), body.getOpenSpots(), body.getType()); 45 return new InternshipResponseDTO(j); 46 } 47 48 return new InternshipResponseDTO(); 38 49 } 39 50 40 51 @PostMapping("/project") 41 52 public ProjectResponseDTO registerProject(@RequestBody ProjectRegisterDTO body){ 42 Project j = this.workService.insertProject(body.getTitle(), 43 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsRequired(), body.getValidUntil(), body.getType()); 44 return new ProjectResponseDTO(j); 53 54 if(body.getType() == AccountType.TEAM){ 55 Project j = this.workService.insertProject(body.getTitle(), 56 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsRequired(), body.getValidUntil(), body.getType()); 57 return new ProjectResponseDTO(j); 58 } 59 60 return new ProjectResponseDTO(); 45 61 } 46 62 }
Note:
See TracChangeset
for help on using the changeset viewer.