source: src/main/java/it/finki/tinki/service/impl/WorkServiceImpl.java@ 336d09e

Last change on this file since 336d09e was 336d09e, checked in by Vzdra <vladko.zdravkovski@…>, 3 years ago

cleanup

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