Ignore:
Timestamp:
01/09/21 03:04:38 (4 years ago)
Author:
Vzdra <vladko.zdravkovski@…>
Branches:
master
Children:
a3d2b0d
Parents:
297bd16
Message:

added full text search on work

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  
    11package it.finki.tinki.repository;
    22
     3import it.finki.tinki.model.Skill;
    34import it.finki.tinki.model.Work.Internship;
     5import it.finki.tinki.model.Work.Job;
    46import org.springframework.data.jpa.repository.JpaRepository;
    57import org.springframework.stereotype.Repository;
     
    1012public interface InternshipRepository extends JpaRepository<Internship, Long> {
    1113    List<Internship> findAllByAccount_Id(Long accountId);
     14    List<Internship> findAllByTitleContainsOrDescriptionContains(String title, String description);
     15    List<Internship> findAllBySkillsTrainedContaining(Skill skill);
    1216}
  • src/main/java/it/finki/tinki/repository/JobRepository.java

    r297bd16 rf067338  
    11package it.finki.tinki.repository;
    22
     3import it.finki.tinki.model.Skill;
    34import it.finki.tinki.model.Work.Job;
    45import org.springframework.data.jpa.repository.JpaRepository;
     
    67
    78import java.util.List;
     9import java.util.Set;
    810
    911@Repository
    1012public interface JobRepository extends JpaRepository<Job, Long>{
    1113    List<Job> findAllByAccount_Id(Long accountId);
     14    List<Job> findAllByTitleContainsOrDescriptionContains(String title, String description);
     15    List<Job> findAllBySkillsRequiredContaining(Skill skill);
    1216}
  • src/main/java/it/finki/tinki/repository/ProjectRepository.java

    r297bd16 rf067338  
    11package it.finki.tinki.repository;
    22
     3import it.finki.tinki.model.Skill;
     4import it.finki.tinki.model.Work.Job;
    35import it.finki.tinki.model.Work.Project;
    46import org.springframework.data.jpa.repository.JpaRepository;
     
    1012public interface ProjectRepository extends JpaRepository<Project, Long> {
    1113    List<Project> findAllByAccount_Id(Long accountId);
     14    List<Project> findAllByTitleContainsOrDescriptionContains(String title, String description);
     15    List<Project> findAllBySkillsRequiredContaining(Skill skill);
    1216}
  • src/main/java/it/finki/tinki/repository/SkillRepository.java

    r297bd16 rf067338  
    55import org.springframework.stereotype.Repository;
    66
     7import java.util.List;
    78import java.util.Optional;
    89
     
    1011public interface SkillRepository extends JpaRepository<Skill, Long> {
    1112    Optional<Skill> findById(Long id);
     13    List<Skill> findAllByNameContaining(String text);
    1214}
  • src/main/java/it/finki/tinki/service/SkillService.java

    r297bd16 rf067338  
    77public interface SkillService {
    88    List<Skill> returnSkillsBasedOnId(List<Long> skillIds);
     9    List<Skill> returnBasedOnText(String text);
    910}
  • src/main/java/it/finki/tinki/service/WorkService.java

    r297bd16 rf067338  
    44import it.finki.tinki.model.Work.Job;
    55import it.finki.tinki.model.Work.Project;
     6import it.finki.tinki.model.dto.response.work.InternshipResponseDTO;
     7import it.finki.tinki.model.dto.response.work.JobResponseDTO;
     8import it.finki.tinki.model.dto.response.work.ProjectResponseDTO;
     9import it.finki.tinki.model.dto.response.work.WorkResponseDTO;
    610import it.finki.tinki.model.enumerator.AccountType;
    711
     
    1923    Internship insertInternship(String title, String description, Long adccId, int salary, List<Long> skillsTrained, int openSpots, AccountType type);
    2024    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);
    2128}
  • src/main/java/it/finki/tinki/service/impl/SkillServiceImpl.java

    r297bd16 rf067338  
    2929        return list;
    3030    }
     31
     32    public List<Skill> returnBasedOnText(String text){
     33        return this.skillRepository.findAllByNameContaining(text);
     34    }
    3135}
  • src/main/java/it/finki/tinki/service/impl/WorkServiceImpl.java

    r297bd16 rf067338  
    77import it.finki.tinki.model.Skill;
    88import it.finki.tinki.model.Users.Account;
     9import it.finki.tinki.model.Work.Work;
     10import it.finki.tinki.model.dto.response.work.InternshipResponseDTO;
     11import it.finki.tinki.model.dto.response.work.JobResponseDTO;
     12import it.finki.tinki.model.dto.response.work.ProjectResponseDTO;
     13import it.finki.tinki.model.dto.response.work.WorkResponseDTO;
    914import it.finki.tinki.model.enumerator.AccountType;
    1015import it.finki.tinki.repository.*;
     
    1520import org.springframework.stereotype.Service;
    1621
    17 import java.util.Date;
    18 import java.util.List;
     22import java.util.*;
    1923
    2024@Service
     
    125129        return jb;
    126130    }
     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    }
    127209}
  • src/main/java/it/finki/tinki/web/controller/LoginController.java

    r297bd16 rf067338  
    149149    }
    150150
     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
    151166}
  • src/main/java/it/finki/tinki/web/controller/WorkRegisterController.java

    r297bd16 rf067338  
    1111import it.finki.tinki.model.dto.response.work.ProjectResponseDTO;
    1212import 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;
     13import org.springframework.web.bind.annotation.*;
     14
     15import java.util.List;
    1716
    1817@RestController
Note: See TracChangeset for help on using the changeset viewer.