[509cb95] | 1 | package it.finki.tinki.service.impl;
|
---|
| 2 |
|
---|
| 3 | import it.finki.tinki.model.Jobs.Internship;
|
---|
| 4 | import it.finki.tinki.model.Jobs.Job;
|
---|
| 5 | import it.finki.tinki.model.Jobs.Project;
|
---|
| 6 | import it.finki.tinki.model.Match;
|
---|
| 7 | import it.finki.tinki.model.Skill;
|
---|
| 8 | import it.finki.tinki.model.Users.Account;
|
---|
| 9 | import it.finki.tinki.model.enumerator.AccountType;
|
---|
| 10 | import it.finki.tinki.model.enumerator.WorkType;
|
---|
| 11 | import it.finki.tinki.repository.InternshipRepository;
|
---|
| 12 | import it.finki.tinki.repository.JobRepository;
|
---|
| 13 | import it.finki.tinki.repository.MatchRepository;
|
---|
| 14 | import it.finki.tinki.repository.ProjectRepository;
|
---|
| 15 | import it.finki.tinki.service.AccountService;
|
---|
| 16 | import it.finki.tinki.service.MatchmakerService;
|
---|
| 17 | import it.finki.tinki.service.SkillService;
|
---|
| 18 | import it.finki.tinki.service.WorkService;
|
---|
| 19 | import org.springframework.stereotype.Service;
|
---|
| 20 |
|
---|
| 21 | import java.util.Date;
|
---|
| 22 | import java.util.List;
|
---|
| 23 |
|
---|
| 24 | @Service
|
---|
| 25 | public class WorkServiceImpl implements WorkService {
|
---|
| 26 |
|
---|
| 27 | JobRepository jobRepository;
|
---|
| 28 | InternshipRepository internshipRepository;
|
---|
| 29 | ProjectRepository projectRepository;
|
---|
| 30 | MatchRepository matchRepository;
|
---|
| 31 | SkillService skillService;
|
---|
| 32 | AccountService accountService;
|
---|
| 33 |
|
---|
| 34 | public WorkServiceImpl(JobRepository jobRepository,
|
---|
| 35 | InternshipRepository internshipRepository,
|
---|
| 36 | ProjectRepository projectRepository,
|
---|
| 37 | MatchRepository matchRepository,
|
---|
| 38 | SkillService skillService,
|
---|
| 39 | AccountService accountService) {
|
---|
| 40 | this.jobRepository = jobRepository;
|
---|
| 41 | this.internshipRepository = internshipRepository;
|
---|
| 42 | this.projectRepository = projectRepository;
|
---|
| 43 | this.matchRepository = matchRepository;
|
---|
| 44 | this.skillService = skillService;
|
---|
| 45 | this.accountService = accountService;
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | @Override
|
---|
| 49 | public List<Job> getAllJobsByAccount(Long accId) {
|
---|
| 50 | return this.jobRepository.findAllByAccount_Id(accId);
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | @Override
|
---|
| 54 | public List<Internship> getAllInternshipsByAccount(Long accId) {
|
---|
| 55 | return this.internshipRepository.findAllByAccount_Id(accId);
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | @Override
|
---|
| 59 | public List<Project> getAllProjectsByAccount(Long accId) {
|
---|
| 60 | return this.projectRepository.findAllByAccount_Id(accId);
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | @Override
|
---|
| 64 | public List<Job> getAllJobs() {
|
---|
| 65 | return this.jobRepository.findAll();
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | @Override
|
---|
| 69 | public List<Internship> getAllInternships() {
|
---|
| 70 | return this.internshipRepository.findAll();
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | @Override
|
---|
| 74 | public List<Project> getAllProjects() {
|
---|
| 75 | return this.projectRepository.findAll();
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | @Override
|
---|
[a8e8545] | 79 | public Job insertJob(String title, String description, Long adccId, int salary, List<Long> skillsRequired, AccountType type) {
|
---|
[509cb95] | 80 | List<Skill> skills = this.skillService.returnSkillsBasedOnId(skillsRequired);
|
---|
| 81 | Account account = this.accountService.findByIdAndType(adccId, type);
|
---|
| 82 | Job j = new Job(title, description, account, salary, skills);
|
---|
| 83 | return this.jobRepository.save(j);
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | @Override
|
---|
[a8e8545] | 87 | public Internship insertInternship(String title, String description, Long adccId, int salary, List<Long> skillsTrained, int openSpots, AccountType type) {
|
---|
[509cb95] | 88 | List<Skill> skills = this.skillService.returnSkillsBasedOnId(skillsTrained);
|
---|
| 89 | Account account = this.accountService.findByIdAndType(adccId, type);
|
---|
| 90 | Internship j = new Internship(title, description, account, salary, skills, openSpots);
|
---|
| 91 | return this.internshipRepository.save(j);
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | @Override
|
---|
[a8e8545] | 95 | public Project insertProject(String title, String description, Long adccId, int salary, List<Long> skillsRequired, Date validUntil, AccountType type) {
|
---|
[509cb95] | 96 | List<Skill> skills = this.skillService.returnSkillsBasedOnId(skillsRequired);
|
---|
| 97 | Account account = this.accountService.findByIdAndType(adccId, type);
|
---|
| 98 | Project j = new Project(title, description, account, salary, skills, validUntil);
|
---|
| 99 | return this.projectRepository.save(j);
|
---|
| 100 | }
|
---|
| 101 | }
|
---|