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

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

added dummy data for user skills and fixed bugs

  • Property mode set to 100644
File size: 3.9 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.Match;
7import it.finki.tinki.model.Skill;
8import it.finki.tinki.model.Users.Account;
9import it.finki.tinki.model.enumerator.AccountType;
10import it.finki.tinki.model.enumerator.WorkType;
11import it.finki.tinki.repository.InternshipRepository;
12import it.finki.tinki.repository.JobRepository;
13import it.finki.tinki.repository.MatchRepository;
14import it.finki.tinki.repository.ProjectRepository;
15import it.finki.tinki.service.AccountService;
16import it.finki.tinki.service.MatchmakerService;
17import it.finki.tinki.service.SkillService;
18import it.finki.tinki.service.WorkService;
19import org.springframework.stereotype.Service;
20
21import java.util.Date;
22import java.util.List;
23
24@Service
25public 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
79 public Job insertJob(String title, String description, Long adccId, int salary, List<Long> skillsRequired, AccountType type) {
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
87 public Internship insertInternship(String title, String description, Long adccId, int salary, List<Long> skillsTrained, int openSpots, AccountType type) {
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
95 public Project insertProject(String title, String description, Long adccId, int salary, List<Long> skillsRequired, Date validUntil, AccountType type) {
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}
Note: See TracBrowser for help on using the repository browser.