Changeset 297bd16


Ignore:
Timestamp:
01/09/21 01:07:09 (3 years ago)
Author:
Vzdra <vladko.zdravkovski@…>
Branches:
master
Children:
f067338
Parents:
bd46dbb
Message:

added job/internship/project inserts

Location:
src/main/java/it/finki/tinki
Files:
8 edited
1 moved

Legend:

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

    rbd46dbb r297bd16  
    1111        SpringApplication.run(TinkiApplication.class, args);
    1212    }
     13
    1314}
  • src/main/java/it/finki/tinki/model/EmbeddedMatchId.java

    rbd46dbb r297bd16  
    1919    private User user;
    2020
    21     public EmbeddedMatchId(){ }
     21    public EmbeddedMatchId(){}
    2222
    2323    public EmbeddedMatchId(Work work, User user){
  • src/main/java/it/finki/tinki/model/dto/register/work/InternshipRegisterDTO.java

    rbd46dbb r297bd16  
    66
    77@Data
    8 public class InternshipRegisterDTO {
     8public class InternshipRegisterDTO extends WorkRegisterDTO {
    99    int openSpots;
    1010    List<Long> skillsTrained;
  • src/main/java/it/finki/tinki/model/dto/register/work/ProjectRegisterDTO.java

    rbd46dbb r297bd16  
    77
    88@Data
    9 public class ProjectRegisterDTO {
     9public class ProjectRegisterDTO extends WorkRegisterDTO {
    1010    Date validUntil;
    1111    List<Long> skillsRequired;
  • src/main/java/it/finki/tinki/model/dto/register/work/WorkRegisterDTO.java

    rbd46dbb r297bd16  
    11package it.finki.tinki.model.dto.register.work;
    22
     3import it.finki.tinki.model.enumerator.AccountType;
    34import lombok.Data;
    45
     
    910    Long accountId;
    1011    int salary;
     12    AccountType type;
    1113}
  • src/main/java/it/finki/tinki/service/AccountService.java

    rbd46dbb r297bd16  
    1919    User editUser(Long id, String email, String name, String surname, List<Skill> retainedSkills, List<Skill> skillsToLearn);
    2020    Company editCompany(Long id, String email, String name, String country, String city, String street);
     21    Team editTeam(Long id, String email, String name, int members);
    2122    Optional<?> findByIdAndEmail(Long id, String email, AccountType type);
    22     Team editTeam(Long id, String email, String name, int members);
    2323}
  • src/main/java/it/finki/tinki/service/impl/WorkServiceImpl.java

    rbd46dbb r297bd16  
    11package it.finki.tinki.service.impl;
    22
     3import it.finki.tinki.model.Users.User;
    34import it.finki.tinki.model.Work.Internship;
    45import it.finki.tinki.model.Work.Job;
     
    78import it.finki.tinki.model.Users.Account;
    89import it.finki.tinki.model.enumerator.AccountType;
    9 import it.finki.tinki.repository.InternshipRepository;
    10 import it.finki.tinki.repository.JobRepository;
    11 import it.finki.tinki.repository.MatchRepository;
    12 import it.finki.tinki.repository.ProjectRepository;
     10import it.finki.tinki.repository.*;
    1311import it.finki.tinki.service.AccountService;
     12import it.finki.tinki.service.MatchmakerService;
    1413import it.finki.tinki.service.SkillService;
    1514import it.finki.tinki.service.WorkService;
     
    2625    ProjectRepository projectRepository;
    2726    MatchRepository matchRepository;
     27    MatchmakerService matchmakerService;
    2828    SkillService skillService;
    2929    AccountService accountService;
     30    UserRepository userRepository;
    3031
    3132    public WorkServiceImpl(JobRepository jobRepository,
     
    3435                           MatchRepository matchRepository,
    3536                           SkillService skillService,
    36                            AccountService accountService) {
     37                           AccountService accountService,
     38                           UserRepository userRepository,
     39                           MatchmakerService matchmakerService) {
    3740        this.jobRepository = jobRepository;
    3841        this.internshipRepository = internshipRepository;
     
    4144        this.skillService = skillService;
    4245        this.accountService = accountService;
     46        this.userRepository = userRepository;
     47        this.matchmakerService = matchmakerService;
    4348    }
    4449
     
    7883        Account account = this.accountService.findByIdAndType(adccId, type);
    7984        Job j = new Job(title, description, account, salary, skills);
    80         return this.jobRepository.save(j);
     85        Job jb = this.jobRepository.save(j);
     86
     87        List<User> users = this.userRepository.findAll();
     88
     89        users.forEach(user -> {
     90            this.matchmakerService.setUpUserJobMatches(jb, user);
     91        });
     92
     93        return jb;
    8194    }
    8295
     
    8699        Account account = this.accountService.findByIdAndType(adccId, type);
    87100        Internship j = new Internship(title, description, account, salary, skills, openSpots);
    88         return this.internshipRepository.save(j);
     101        Internship jb = this.internshipRepository.save(j);
     102
     103        List<User> users = this.userRepository.findAll();
     104
     105        users.forEach(user -> {
     106            this.matchmakerService.setUpUserInternshipMatches(jb, user);
     107        });
     108
     109        return jb;
    89110    }
    90111
     
    94115        Account account = this.accountService.findByIdAndType(adccId, type);
    95116        Project j = new Project(title, description, account, salary, skills, validUntil);
    96         return this.projectRepository.save(j);
     117        Project jb = this.projectRepository.save(j);
     118
     119        List<User> users = this.userRepository.findAll();
     120
     121        users.forEach(user -> {
     122            this.matchmakerService.setUpUserProjectMatches(jb, user);
     123        });
     124
     125        return jb;
    97126    }
    98127}
  • src/main/java/it/finki/tinki/web/controller/AccountRegisterController.java

    rbd46dbb r297bd16  
    1919@CrossOrigin(origins = "http://localhost:3000")
    2020@RequestMapping("/api/register")
    21 public class RegisterController {
     21public class AccountRegisterController {
    2222
    2323    AccountService accountService;
     
    2626    MatchmakerService matchmakerService;
    2727
    28     public RegisterController(AccountService accountService, SkillService skillService, WorkService workService, MatchmakerService matchmakerService) {
     28    public AccountRegisterController(AccountService accountService, SkillService skillService, WorkService workService, MatchmakerService matchmakerService) {
    2929        this.accountService = accountService;
    3030        this.skillService = skillService;
  • src/main/java/it/finki/tinki/web/controller/WorkRegisterController.java

    rbd46dbb r297bd16  
    11package it.finki.tinki.web.controller;
    22
     3import it.finki.tinki.model.Work.Internship;
     4import it.finki.tinki.model.Work.Job;
     5import it.finki.tinki.model.Work.Project;
     6import it.finki.tinki.model.dto.register.work.InternshipRegisterDTO;
     7import it.finki.tinki.model.dto.register.work.JobRegisterDTO;
     8import it.finki.tinki.model.dto.register.work.ProjectRegisterDTO;
     9import it.finki.tinki.model.dto.response.work.InternshipResponseDTO;
    310import it.finki.tinki.model.dto.response.work.JobResponseDTO;
     11import it.finki.tinki.model.dto.response.work.ProjectResponseDTO;
     12import it.finki.tinki.service.WorkService;
    413import org.springframework.web.bind.annotation.PostMapping;
    514import org.springframework.web.bind.annotation.RequestBody;
     
    1120public class WorkRegisterController {
    1221
    13 //    @PostMapping("/job")
    14 //    public JobResponseDTO registerJob(@RequestBody JobRegisterDTO body){
    15 //
    16 //    }
     22    WorkService workService;
     23
     24    public WorkRegisterController(WorkService workService) {
     25        this.workService = workService;
     26    }
     27
     28    @PostMapping("/job")
     29    public JobResponseDTO registerJob(@RequestBody JobRegisterDTO body){
     30
     31        Job j = this.workService.insertJob(body.getTitle(),
     32                body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsRequired(), body.getType());
     33
     34        return new JobResponseDTO(j);
     35    }
     36
     37    @PostMapping("/internship")
     38    public InternshipResponseDTO registerInternship(@RequestBody InternshipRegisterDTO body){
     39
     40        Internship j = this.workService.insertInternship(body.getTitle(),
     41                body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsTrained(), body.getOpenSpots(), body.getType());
     42
     43        return new InternshipResponseDTO(j);
     44    }
     45
     46    @PostMapping("/project")
     47    public ProjectResponseDTO registerProject(@RequestBody ProjectRegisterDTO body){
     48
     49        Project j = this.workService.insertProject(body.getTitle(),
     50                body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsRequired(), body.getValidUntil(), body.getType());
     51
     52        return new ProjectResponseDTO(j);
     53    }
    1754}
Note: See TracChangeset for help on using the changeset viewer.