Changeset f067338 for src/main/java/it/finki/tinki
- Timestamp:
- 01/09/21 03:04:38 (4 years ago)
- Branches:
- master
- Children:
- a3d2b0d
- Parents:
- 297bd16
- Location:
- src/main/java/it/finki/tinki
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/it/finki/tinki/repository/InternshipRepository.java
r297bd16 rf067338 1 1 package it.finki.tinki.repository; 2 2 3 import it.finki.tinki.model.Skill; 3 4 import it.finki.tinki.model.Work.Internship; 5 import it.finki.tinki.model.Work.Job; 4 6 import org.springframework.data.jpa.repository.JpaRepository; 5 7 import org.springframework.stereotype.Repository; … … 10 12 public interface InternshipRepository extends JpaRepository<Internship, Long> { 11 13 List<Internship> findAllByAccount_Id(Long accountId); 14 List<Internship> findAllByTitleContainsOrDescriptionContains(String title, String description); 15 List<Internship> findAllBySkillsTrainedContaining(Skill skill); 12 16 } -
src/main/java/it/finki/tinki/repository/JobRepository.java
r297bd16 rf067338 1 1 package it.finki.tinki.repository; 2 2 3 import it.finki.tinki.model.Skill; 3 4 import it.finki.tinki.model.Work.Job; 4 5 import org.springframework.data.jpa.repository.JpaRepository; … … 6 7 7 8 import java.util.List; 9 import java.util.Set; 8 10 9 11 @Repository 10 12 public interface JobRepository extends JpaRepository<Job, Long>{ 11 13 List<Job> findAllByAccount_Id(Long accountId); 14 List<Job> findAllByTitleContainsOrDescriptionContains(String title, String description); 15 List<Job> findAllBySkillsRequiredContaining(Skill skill); 12 16 } -
src/main/java/it/finki/tinki/repository/ProjectRepository.java
r297bd16 rf067338 1 1 package it.finki.tinki.repository; 2 2 3 import it.finki.tinki.model.Skill; 4 import it.finki.tinki.model.Work.Job; 3 5 import it.finki.tinki.model.Work.Project; 4 6 import org.springframework.data.jpa.repository.JpaRepository; … … 10 12 public interface ProjectRepository extends JpaRepository<Project, Long> { 11 13 List<Project> findAllByAccount_Id(Long accountId); 14 List<Project> findAllByTitleContainsOrDescriptionContains(String title, String description); 15 List<Project> findAllBySkillsRequiredContaining(Skill skill); 12 16 } -
src/main/java/it/finki/tinki/repository/SkillRepository.java
r297bd16 rf067338 5 5 import org.springframework.stereotype.Repository; 6 6 7 import java.util.List; 7 8 import java.util.Optional; 8 9 … … 10 11 public interface SkillRepository extends JpaRepository<Skill, Long> { 11 12 Optional<Skill> findById(Long id); 13 List<Skill> findAllByNameContaining(String text); 12 14 } -
src/main/java/it/finki/tinki/service/SkillService.java
r297bd16 rf067338 7 7 public interface SkillService { 8 8 List<Skill> returnSkillsBasedOnId(List<Long> skillIds); 9 List<Skill> returnBasedOnText(String text); 9 10 } -
src/main/java/it/finki/tinki/service/WorkService.java
r297bd16 rf067338 4 4 import it.finki.tinki.model.Work.Job; 5 5 import it.finki.tinki.model.Work.Project; 6 import it.finki.tinki.model.dto.response.work.InternshipResponseDTO; 7 import it.finki.tinki.model.dto.response.work.JobResponseDTO; 8 import it.finki.tinki.model.dto.response.work.ProjectResponseDTO; 9 import it.finki.tinki.model.dto.response.work.WorkResponseDTO; 6 10 import it.finki.tinki.model.enumerator.AccountType; 7 11 … … 19 23 Internship insertInternship(String title, String description, Long adccId, int salary, List<Long> skillsTrained, int openSpots, AccountType type); 20 24 Project insertProject(String title, String description, Long adccId, int salary, List<Long> skillsRequired, Date validUntil, AccountType type); 25 List<JobResponseDTO> fullTextJobSearch(String text); 26 List<InternshipResponseDTO> fullTextInternshipSearch(String text); 27 List<ProjectResponseDTO> fullTextProjectSearch(String text); 21 28 } -
src/main/java/it/finki/tinki/service/impl/SkillServiceImpl.java
r297bd16 rf067338 29 29 return list; 30 30 } 31 32 public List<Skill> returnBasedOnText(String text){ 33 return this.skillRepository.findAllByNameContaining(text); 34 } 31 35 } -
src/main/java/it/finki/tinki/service/impl/WorkServiceImpl.java
r297bd16 rf067338 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 import it.finki.tinki.model.dto.response.work.InternshipResponseDTO; 11 import it.finki.tinki.model.dto.response.work.JobResponseDTO; 12 import it.finki.tinki.model.dto.response.work.ProjectResponseDTO; 13 import it.finki.tinki.model.dto.response.work.WorkResponseDTO; 9 14 import it.finki.tinki.model.enumerator.AccountType; 10 15 import it.finki.tinki.repository.*; … … 15 20 import org.springframework.stereotype.Service; 16 21 17 import java.util.Date; 18 import java.util.List; 22 import java.util.*; 19 23 20 24 @Service … … 125 129 return jb; 126 130 } 131 132 @Override 133 public List<JobResponseDTO> fullTextJobSearch(String text) { 134 List<Skill> skills = this.skillService.returnBasedOnText(text); 135 136 List<Job> jobs = this.jobRepository.findAllByTitleContainsOrDescriptionContains(text,text); 137 List<Job> sjob = new ArrayList<>(); 138 139 skills.forEach(skill -> { 140 sjob.addAll(this.jobRepository.findAllBySkillsRequiredContaining(skill)); 141 }); 142 143 sjob.forEach(job -> { 144 if(!jobs.contains(job)){ 145 jobs.add(job); 146 } 147 }); 148 149 List<JobResponseDTO> jobs2 = new ArrayList<>(); 150 151 jobs.forEach(job -> { 152 jobs2.add(new JobResponseDTO(job)); 153 }); 154 155 return jobs2; 156 } 157 158 @Override 159 public List<InternshipResponseDTO> fullTextInternshipSearch(String text) { 160 List<Skill> skills = this.skillService.returnBasedOnText(text); 161 162 List<Internship> jobs = this.internshipRepository.findAllByTitleContainsOrDescriptionContains(text,text); 163 List<Internship> sjob = new ArrayList<>(); 164 165 skills.forEach(skill -> { 166 sjob.addAll(this.internshipRepository.findAllBySkillsTrainedContaining(skill)); 167 }); 168 169 sjob.forEach(job -> { 170 if(!jobs.contains(job)){ 171 jobs.add(job); 172 } 173 }); 174 175 List<InternshipResponseDTO> jobs2 = new ArrayList<>(); 176 177 jobs.forEach(job -> { 178 jobs2.add(new InternshipResponseDTO(job)); 179 }); 180 181 return jobs2; 182 } 183 184 @Override 185 public List<ProjectResponseDTO> fullTextProjectSearch(String text) { 186 List<Skill> skills = this.skillService.returnBasedOnText(text); 187 188 List<Project> jobs = this.projectRepository.findAllByTitleContainsOrDescriptionContains(text,text); 189 List<Project> sjob = new ArrayList<>(); 190 191 skills.forEach(skill -> { 192 sjob.addAll(this.projectRepository.findAllBySkillsRequiredContaining(skill)); 193 }); 194 195 sjob.forEach(job -> { 196 if(!jobs.contains(job)){ 197 jobs.add(job); 198 } 199 }); 200 201 List<ProjectResponseDTO> jobs2 = new ArrayList<>(); 202 203 jobs.forEach(job -> { 204 jobs2.add(new ProjectResponseDTO(job)); 205 }); 206 207 return jobs2; 208 } 127 209 } -
src/main/java/it/finki/tinki/web/controller/LoginController.java
r297bd16 rf067338 149 149 } 150 150 151 @GetMapping(path = "/job/search") 152 public List<JobResponseDTO> jobRes(@RequestParam(name = "text") String text){ 153 return this.workService.fullTextJobSearch(text); 154 } 155 156 @GetMapping(path = "/internship/search") 157 public List<InternshipResponseDTO> internshipRes(@RequestParam(name = "text") String text){ 158 return this.workService.fullTextInternshipSearch(text); 159 } 160 161 @GetMapping(path = "/project/search") 162 public List<ProjectResponseDTO> projectRes(@RequestParam(name = "text") String text){ 163 return this.workService.fullTextProjectSearch(text); 164 } 165 151 166 } -
src/main/java/it/finki/tinki/web/controller/WorkRegisterController.java
r297bd16 rf067338 11 11 import it.finki.tinki.model.dto.response.work.ProjectResponseDTO; 12 12 import it.finki.tinki.service.WorkService; 13 import org.springframework.web.bind.annotation.PostMapping; 14 import org.springframework.web.bind.annotation.RequestBody; 15 import org.springframework.web.bind.annotation.RequestMapping; 16 import org.springframework.web.bind.annotation.RestController; 13 import org.springframework.web.bind.annotation.*; 14 15 import java.util.List; 17 16 18 17 @RestController
Note:
See TracChangeset
for help on using the changeset viewer.