source: src/main/java/project/educatum/service/impl/QualificationServiceImpl.java

Last change on this file was d3cf3a1, checked in by Marija Micevska <marija_micevska@…>, 2 years ago

Initial commit

  • Property mode set to 100644
File size: 1.6 KB
Line 
1package project.educatum.service.impl;
2
3import org.springframework.stereotype.Service;
4import project.educatum.model.Admin;
5import project.educatum.model.Qualification;
6import project.educatum.model.Teacher;
7import project.educatum.model.exceptions.AdminNotFoundException;
8import project.educatum.model.exceptions.TeacherNotFoundException;
9import project.educatum.repository.AdminRepository;
10import project.educatum.repository.QualificationRepository;
11import project.educatum.repository.TeacherRepository;
12import project.educatum.service.QualificationService;
13
14@Service
15public class QualificationServiceImpl implements QualificationService {
16
17 private final QualificationRepository qualificationRepository;
18 private final TeacherRepository teacherRepository;
19 private final AdminRepository adminRepository;
20
21 public QualificationServiceImpl(QualificationRepository qualificationRepository, TeacherRepository teacherRepository, AdminRepository adminRepository) {
22 this.qualificationRepository = qualificationRepository;
23 this.teacherRepository = teacherRepository;
24 this.adminRepository = adminRepository;
25 }
26
27 @Override
28 public void insert(String document, Integer teacherID) {
29 Teacher n = teacherRepository.findById(teacherID).orElseThrow(TeacherNotFoundException::new);
30 Admin a = adminRepository.findById(1).orElseThrow(AdminNotFoundException::new);
31 Qualification qualification = new Qualification();
32 qualification.setDocument(document);
33 qualification.setIdAdmin(a);
34 qualification.setIdTeacher(n);
35 qualificationRepository.save(qualification);
36 }
37
38}
Note: See TracBrowser for help on using the repository browser.