Changeset 4cec0a3 for src/main


Ignore:
Timestamp:
01/08/21 02:08:22 (4 years ago)
Author:
Vzdra <vladko.zdravkovski@…>
Branches:
master
Children:
b24fe9b
Parents:
a8e8545
Message:

added response dto for job response

Location:
src/main
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/it/finki/tinki/bootstrap/DataHolder.java

    ra8e8545 r4cec0a3  
    6969        lista = skillRepository.findAll();
    7070
     71        List<Skill> l2 = new ArrayList<>();
     72        l2.add(skillRepository.getOne(3L));
     73        l2.add(skillRepository.getOne(0L));
     74        l2.add(skillRepository.getOne(1L));
     75        l2.add(skillRepository.getOne(2L));
     76        l2.add(skillRepository.getOne(4L));
     77        l2.add(skillRepository.getOne(5L));
     78        l2.add(skillRepository.getOne(6L));
     79        l2.add(skillRepository.getOne(7L));
     80
     81
     82        List<Skill> l3 = new ArrayList<>();
     83        l3.add(skillRepository.getOne(3L));
     84        l3.add(skillRepository.getOne(0L));
     85        l3.add(skillRepository.getOne(5L));
     86        l3.add(skillRepository.getOne(6L));
     87        l3.add(skillRepository.getOne(7L));
     88
    7189        List<Long> ids = new ArrayList<>();
    7290        lista.forEach(item -> {
     
    7492        });
    7593
     94        List<Long> smalls = new ArrayList<>();
     95        l2.forEach(item -> {
     96            smalls.add(item.getId());
     97        });
     98
     99        List<Long> sm2 = new ArrayList<>();
     100        l3.forEach(item -> {
     101            sm2.add(item.getId());
     102        });
     103
    76104        Account c = this.accountService.registerCompany("asdf@asdf", "pass", "Co.co", "Macedonia", "Skopje", "Pero Nakov");
     105        Account m = this.accountService.registerTeam("asdf", "asd", "TeamRocket", 3);
    77106
    78107        Job j = this.workService.insertJob("Asdf", "Asdfa", c.getId() ,5000, ids, AccountType.COMPANY);
     108        Job k = this.workService.insertJob("Asdf", "Asdfa", m.getId() ,5000, ids, AccountType.TEAM);
     109        Job z = this.workService.insertJob("asdfq", "asdfqw", m.getId() ,5000, smalls, AccountType.TEAM);
     110        Job n = this.workService.insertJob("asdfq", "asdfqw", c.getId() ,5000, sm2, AccountType.COMPANY);
    79111
    80112        Account u = this.accountService.registerUser("asdf", "asdf", "Zoki", "Poki", lista, lista);
  • src/main/java/it/finki/tinki/model/dto/UserResponseDTO.java

    ra8e8545 r4cec0a3  
    77import lombok.Data;
    88
     9import java.util.ArrayList;
    910import java.util.List;
    1011
     
    1415    private List<Skill> retained;
    1516    private List<Skill> toLearn;
    16     private List<Job> jobs;
     17    private List<JobResponseDTO> jobs;
    1718    private List<Internship> internships;
    1819    private List<Project> projects;
     20
     21    public UserResponseDTO(){
     22        retained = new ArrayList<>();
     23        toLearn = new ArrayList<>();
     24        jobs = new ArrayList<>();
     25        internships = new ArrayList<>();
     26        projects = new ArrayList<>();
     27    }
    1928}
  • src/main/java/it/finki/tinki/repository/MatchRepository.java

    ra8e8545 r4cec0a3  
    1212@Repository
    1313public interface MatchRepository extends JpaRepository<Match, EmbeddedMatchId> {
    14     List<Match> getAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(Long uId, WorkType type);
     14    List<Match> findAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(User user, WorkType type);
    1515//    List<Match> getAllByUserIdAndTypeOrderByCoefficientDesc(Long uId, WorkType type);
    1616}
  • src/main/java/it/finki/tinki/service/impl/MatchmakerServiceImpl.java

    ra8e8545 r4cec0a3  
    4242    @Override
    4343    public List<Internship> getMatchingInternshipsForUser(User user) {
    44         List<Match> matches = this.matchRepository.getAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(user.getId(), WorkType.INTERNSHIP);
    45 //        List<Match> matches = this.matchRepository.getAllByUserIdAndTypeOrderByCoefficientDesc(user.getId(), WorkType.INTERNSHIP);
     44        List<Match> matches = this.matchRepository.findAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(user, WorkType.INTERNSHIP);
    4645
    4746        List<Internship> internships = new ArrayList<>();
    48         matches.forEach(match -> {
    49             internships.add((Internship) match.getEmbeddedMatchId().getWork());
    50 //            internships.add(this.internshipRepository.findById(match.getWorkId()).get());
    51         });
     47        if(matches.size()!=0){
     48            matches.forEach(match -> {
     49                internships.add((Internship) match.getEmbeddedMatchId().getWork());
     50            });
     51        }
    5252
    5353        return internships;
     
    5656    @Override
    5757    public List<Job> getMatchingJobsForUser(User user) {
    58         List<Match> matches = this.matchRepository.getAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(user.getId(), WorkType.INTERNSHIP);
    59 //        List<Match> matches = this.matchRepository.getAllByUserIdAndTypeOrderByCoefficientDesc(user.getId(), WorkType.JOB);
     58        List<Match> matches = this.matchRepository.findAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(user, WorkType.JOB);
    6059
    6160        List<Job> jobs = new ArrayList<>();
    62         matches.forEach(match -> {
    63             jobs.add((Job) match.getEmbeddedMatchId().getWork());
    64 //            jobs.add(this.jobRepository.findById(match.getWorkId()).get());
    65         });
     61        if(matches.size()!=0) {
     62            matches.forEach(match -> {
     63                jobs.add((Job) match.getEmbeddedMatchId().getWork());
     64            });
     65        }
    6666
    6767        return jobs;
     
    7070    @Override
    7171    public List<Project> getMatchingProjectsForUser(User user) {
    72         List<Match> matches = this.matchRepository.getAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(user.getId(), WorkType.INTERNSHIP);
    73 //        List<Match> matches = this.matchRepository.getAllByUserIdAndTypeOrderByCoefficientDesc(user.getId(), WorkType.PROJECT);
     72        List<Match> matches = this.matchRepository.findAllByEmbeddedMatchIdUserAndTypeOrderByCoefficientDesc(user, WorkType.PROJECT);
    7473
    7574        List<Project> projects = new ArrayList<>();
    76         matches.forEach(match -> {
    77             projects.add((Project) match.getEmbeddedMatchId().getWork());
    78 //            projects.add(this.projectRepository.findById(match.getWorkId()).get());
    79         });
     75        if(matches.size()!=0) {
     76            matches.forEach(match -> {
     77                projects.add((Project) match.getEmbeddedMatchId().getWork());
     78            });
     79        }
    8080
    8181        return projects;
     
    9292            EmbeddedMatchId embeddedMatchId = new EmbeddedMatchId(job, user);
    9393            Match m = new Match(embeddedMatchId, coef, WorkType.JOB);
    94 //            Match m = new Match(job.getId(), user.getId(), coef, WorkType.JOB);
    9594            this.matchRepository.save(m);
    9695        }
     
    107106            EmbeddedMatchId embeddedMatchId = new EmbeddedMatchId(project, user);
    108107            Match m = new Match(embeddedMatchId, coef, WorkType.PROJECT);
    109 //            Match m = new Match(project.getId(), user.getId(), coef, WorkType.JOB);
    110108            this.matchRepository.save(m);
    111109        }
     
    122120            EmbeddedMatchId embeddedMatchId = new EmbeddedMatchId(internship, user);
    123121            Match m = new Match(embeddedMatchId, coef, WorkType.PROJECT);
    124 //            Match m = new Match(internship.getId(), user.getId(), coef, WorkType.JOB);
    125122            this.matchRepository.save(m);
    126123        }
  • src/main/java/it/finki/tinki/web/controller/LoginController.java

    ra8e8545 r4cec0a3  
    11package it.finki.tinki.web.controller;
    22
     3import it.finki.tinki.model.Jobs.Internship;
     4import it.finki.tinki.model.Jobs.Job;
    35import it.finki.tinki.model.Users.Account;
    46import it.finki.tinki.model.Users.Company;
     
    1416import org.springframework.web.server.ResponseStatusException;
    1517
     18import java.util.List;
    1619import java.util.Map;
    1720
     
    5457                uDto.setToLearn(((User) a1).getSkillsToLearn());
    5558
    56                 uDto.setInternships(this.matchmakerService.getMatchingInternshipsForUser((User) a1));
    57                 uDto.setJobs(this.matchmakerService.getMatchingJobsForUser((User) a1));
    58                 uDto.setProjects(this.matchmakerService.getMatchingProjectsForUser((User) a1));
     59                List<Job> matchedJobs = this.matchmakerService.getMatchingJobsForUser((User) a1);
     60
     61                matchedJobs.forEach(job -> {
     62                    JobResponseDTO dto = new JobResponseDTO(job);
     63                    uDto.getJobs().add(dto);
     64                });
     65
    5966
    6067                return uDto;
  • src/main/resources/application.properties

    ra8e8545 r4cec0a3  
    1212spring.h2.console.path=/h2
    1313
    14 spring.jpa.show-sql=true
     14spring.jpa.properties.hibernate.show_sql=true
     15spring.jpa.properties.hibernate.use_sql_comments=true
     16spring.jpa.properties.hibernate.format_sql=true
     17
     18logging.level.org.hibernate.type=trace
    1519spring.jpa.hibernate.ddl-auto=update
Note: See TracChangeset for help on using the changeset viewer.