Changeset befb988 for jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend
- Timestamp:
- 06/17/24 21:59:14 (5 months ago)
- Branches:
- main
- Children:
- 08f82ec
- Parents:
- b248810
- Location:
- jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/config/SecurityConfiguration.java
rb248810 rbefb988 2 2 3 3 import lombok.RequiredArgsConstructor; 4 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.enumerations.Role; 4 5 import org.springframework.context.annotation.Bean; 5 6 import org.springframework.context.annotation.Configuration; … … 31 32 .authorizeHttpRequests(request -> request 32 33 // TO DO: FIX PERMISSIONS 33 .requestMatchers("/api/job-advertisements/**","/api/job-advertisements/view/**","/api/recruiter/info/**", 34 "/api/job-advertisements/apply/**","/api/auth/**", "/api/resume/**", "/api/my-applications/**", "/api/applications/{id}/update", "/api/admin/**").permitAll() 35 //.requestMatchers("/api/job-advertisements/**").hasAnyAuthority(Role.ROLE_RECRUITER.name()) 34 .requestMatchers("/api/job-advertisements/**", 35 "/api/job-advertisements/view/**", 36 "/api/recruiter/**", 37 "/api/job-seeker/**", 38 "/api/recruiter/{id}/info", 39 "/api/recruiter/{id}/edit-info", 40 "/api/job-advertisements/apply/**", 41 "/api/auth/**", 42 "/api/resume/**", 43 "/api/my-applications/**", 44 "/api/applications/{id}/update", 45 "/api/admin/**").permitAll() 46 // .requestMatchers("/api/recruiter").hasAnyAuthority(Role.ROLE_RECRUITER.name()) 36 47 .anyRequest().authenticated()) 37 48 .sessionManagement(manager -> manager.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) -
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/controllers/AdminController.java
rb248810 rbefb988 2 2 3 3 import lombok.RequiredArgsConstructor; 4 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterAdminDetailsDTO; 4 5 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterDetailsDTO; 5 6 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.service.intef.AdminService; … … 20 21 @PostMapping("/change-access/{recruiter_id}") 21 22 public ResponseEntity<?> changeAccess(@PathVariable("recruiter_id") Long recruiterId, @RequestBody boolean access) { 22 Recruiter DetailsDTO recruiterDetailsDTO = adminService.changeAccess(recruiterId, access);23 return new ResponseEntity<>(recruiter DetailsDTO, HttpStatus.OK);23 RecruiterAdminDetailsDTO recruiterAdminDetailsDTO = adminService.changeAccess(recruiterId, access); 24 return new ResponseEntity<>(recruiterAdminDetailsDTO, HttpStatus.OK); 24 25 } 25 26 26 27 @GetMapping("/recruiters") 27 28 public ResponseEntity<?> findAllRecruiters() { 28 List<Recruiter DetailsDTO> recruiterDetailsDTOList = adminService.findAllRecruiters();29 return new ResponseEntity<>(recruiter DetailsDTOList, HttpStatus.OK);29 List<RecruiterAdminDetailsDTO> recruiterAdminDetailsDTOList = adminService.findAllRecruiters(); 30 return new ResponseEntity<>(recruiterAdminDetailsDTOList, HttpStatus.OK); 30 31 } 31 32 } -
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/controllers/JobSeekerController.java
rb248810 rbefb988 3 3 4 4 import lombok.AllArgsConstructor; 5 import org.springframework.web.bind.annotation.CrossOrigin; 6 import org.springframework.web.bind.annotation.RequestMapping; 7 import org.springframework.web.bind.annotation.RestController; 5 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.JobSeekerEditDetailsDTO; 6 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterEditDetailsDTO; 7 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.service.intef.JobSeekerService; 8 import org.springframework.core.io.Resource; 9 import org.springframework.http.HttpHeaders; 10 import org.springframework.http.HttpStatus; 11 import org.springframework.http.MediaType; 12 import org.springframework.http.ResponseEntity; 13 import org.springframework.web.bind.annotation.*; 14 import org.springframework.web.multipart.MultipartFile; 8 15 9 16 @RestController … … 12 19 @CrossOrigin(origins = "*") 13 20 public class JobSeekerController { 21 private final JobSeekerService jobSeekerService; 22 23 @GetMapping("/{id}/edit-info") 24 public ResponseEntity<?> getJobSeekerEditDetailsById(@PathVariable("id") Long id) { 25 JobSeekerEditDetailsDTO jobSeekerEditDetailsDTO = jobSeekerService.getJobSeekerEditDetailsById(id); 26 return new ResponseEntity<>(jobSeekerEditDetailsDTO, HttpStatus.OK); 27 } 28 29 @PostMapping("/{id}/edit-info") 30 public ResponseEntity<?> editRecruiterDetailsById(@PathVariable("id") Long id, @RequestBody JobSeekerEditDetailsDTO jobSeekerEditDetailsDTO) { 31 JobSeekerEditDetailsDTO jobSeekerEditDetailsDTOresp = jobSeekerService.editJobSeekerDetailsById(id, jobSeekerEditDetailsDTO); 32 return new ResponseEntity<>(jobSeekerEditDetailsDTOresp, HttpStatus.OK); 33 } 34 35 @PostMapping("/submit-profile-pic") 36 public ResponseEntity<?> submitJobSeekerProfilePic( 37 @RequestParam("jobSeekerId") Long jobSeekerId, 38 @RequestParam("profilePicFile") MultipartFile profilePicFile) { 39 jobSeekerService.submitProfilePic(jobSeekerId, profilePicFile); 40 return new ResponseEntity<>(HttpStatus.OK); 41 } 42 43 @GetMapping("/{id}/download-profile-pic") 44 public ResponseEntity<?> downloadJobSeekerProfilePic(@PathVariable("id") Long id) { 45 Resource resource = jobSeekerService.loadProfilePicAsResource(id); 46 return ResponseEntity.ok() 47 .contentType(MediaType.IMAGE_JPEG) 48 .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + resource.getFilename() + "\"") 49 .body(resource); 50 } 14 51 } -
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/controllers/RecruiterController.java
rb248810 rbefb988 3 3 import lombok.AllArgsConstructor; 4 4 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterDetailsDTO; 5 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterEditDetailsDTO; 5 6 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.service.intef.RecruiterService; 7 import org.springframework.core.io.Resource; 8 import org.springframework.http.HttpHeaders; 6 9 import org.springframework.http.HttpStatus; 10 import org.springframework.http.MediaType; 7 11 import org.springframework.http.ResponseEntity; 8 12 import org.springframework.web.bind.annotation.*; 13 import org.springframework.web.multipart.MultipartFile; 9 14 10 15 @RestController … … 16 21 private final RecruiterService recruiterService; 17 22 18 @GetMapping("/ info/{id}")23 @GetMapping("/{id}/info") 19 24 public ResponseEntity<?> getRecruiterDetailsById(@PathVariable("id") Long id) { 20 25 RecruiterDetailsDTO recruiterDetailsDTO = recruiterService.getRecruiterDetailsById(id); 21 26 return new ResponseEntity<>(recruiterDetailsDTO, HttpStatus.OK); 22 27 } 28 29 @GetMapping("/{id}/edit-info") 30 public ResponseEntity<?> getRecruiterEditDetailsById(@PathVariable("id") Long id) { 31 RecruiterEditDetailsDTO recruiterEditDetailsDTO = recruiterService.getRecruiterEditDetailsById(id); 32 return new ResponseEntity<>(recruiterEditDetailsDTO, HttpStatus.OK); 33 } 34 35 @PostMapping("/{id}/edit-info") 36 public ResponseEntity<?> editRecruiterDetailsById(@PathVariable("id") Long id, @RequestBody RecruiterEditDetailsDTO recruiterEditDetailsDTO) { 37 RecruiterEditDetailsDTO recruiterEditDetailsDTOresp = recruiterService.editRecruiterDetailsById(id, recruiterEditDetailsDTO); 38 return new ResponseEntity<>(recruiterEditDetailsDTOresp, HttpStatus.OK); 39 } 40 41 @PostMapping("/submit-logo") 42 public ResponseEntity<?> submitRecruiterLogo( 43 @RequestParam("recruiterId") Long recruiterId, 44 @RequestParam("logoFile") MultipartFile logoFile) { 45 recruiterService.submitLogo(recruiterId, logoFile); 46 return new ResponseEntity<>(HttpStatus.OK); 47 } 48 49 @GetMapping("/{id}/download-logo") 50 public ResponseEntity<?> downloadRecruiterLogo(@PathVariable("id") Long id) { 51 Resource resource = recruiterService.loadLogoAsResource(id); 52 return ResponseEntity.ok() 53 .contentType(MediaType.IMAGE_JPEG) 54 .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + resource.getFilename() + "\"") 55 .body(resource); 56 } 23 57 } -
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/models/applications/Application.java
rb248810 rbefb988 62 62 application.getJobSeeker().getEmail(), 63 63 application.getJobSeeker().getPhoneNumber(), 64 application.getJobAdvertisement().getRecruiter().getId(), 64 65 application.getJobAdvertisement().getRecruiter().getName(), 65 application.getJobAdvertisement().getRecruiter().get Email(),66 application.getJobAdvertisement().getRecruiter().get PhoneNumber(),66 application.getJobAdvertisement().getRecruiter().getContactEmailAddress(), 67 application.getJobAdvertisement().getRecruiter().getContactPhoneNumber(), 67 68 application.getJobAdvertisement().getId(), 68 69 application.getJobAdvertisement().getTitle(), -
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/models/applications/DTO/ApplicationDetailsDTO.java
rb248810 rbefb988 18 18 private String jobSeekerEmail; 19 19 private String jobSeekerPhoneNumber; 20 private Long recruiterId; 20 21 private String recruiterName; 21 22 private String recruiterEmail; -
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/models/job_advertisements/DTO/JobAdvertisementDTO.java
rb248810 rbefb988 11 11 @NoArgsConstructor 12 12 public class JobAdvertisementDTO { 13 private String email;13 private Long id; 14 14 private String title; 15 15 private String description; -
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/models/users/DTO/RecruiterDetailsDTO.java
rb248810 rbefb988 11 11 @NoArgsConstructor 12 12 public class RecruiterDetailsDTO { 13 private Long id;14 private String email;15 13 private String companyName; 16 14 private String companyDescription; 17 private String phoneNumber;18 private boolean hasAccess;19 private LocalDateTime registeredOn;15 private String contactEmail; 16 private String contactPhoneNumber; 17 private String receptionist; 20 18 } -
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/models/users/JobSeeker.java
rb248810 rbefb988 8 8 import lombok.NoArgsConstructor; 9 9 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.enumerations.Role; 10 11 import java.nio.file.Paths; 10 12 11 13 @Entity … … 22 24 this.lastName = lastName; 23 25 this.phoneNumber = phoneNumber; 26 27 String relativeProfilePicFilePath = Paths.get("uploads", "job-seekers", "profile-pics", "default-profile-pic.png").toString(); 28 this.profilePicFilePath = relativeProfilePicFilePath; 29 24 30 this.role = Role.ROLE_JOBSEEKER; 25 31 } … … 34 40 private String phoneNumber; 35 41 42 private String profilePicFilePath; 43 36 44 @Override 37 45 public String getName() { -
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/models/users/Recruiter.java
rb248810 rbefb988 9 9 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.enumerations.Role; 10 10 11 import java.nio.file.Paths; 12 11 13 @Entity 12 14 @Data 13 15 @NoArgsConstructor 14 @AllArgsConstructor15 16 @Table(name = "recruiters") 16 17 public class Recruiter extends User { … … 21 22 this.companyName = companyName; 22 23 this.companyDescription = ""; 23 this.phoneNumber = phoneNumber; 24 this.contactEmailAddress = email; 25 this.contactPhoneNumber = phoneNumber; 26 this.receptionist = ""; 27 28 String relativeLogoFilePath = Paths.get("uploads", "logo", "default-company-logo.png").toString(); 29 this.logoFilePath = relativeLogoFilePath; 24 30 this.role = Role.ROLE_RECRUITER; 25 31 } … … 31 37 private String companyDescription; 32 38 33 @Column(name = "phone_number") 34 private String phoneNumber; 39 private String contactEmailAddress; 40 41 private String contactPhoneNumber; 42 43 private String receptionist; 44 45 private String logoFilePath; 35 46 36 47 @Override -
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/models/users/mappers/JobSeekerMapper.java
rb248810 rbefb988 2 2 3 3 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.JobSeekerDTO; 4 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.JobSeekerEditDetailsDTO; 5 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterEditDetailsDTO; 4 6 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.JobSeeker; 7 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.Recruiter; 5 8 6 9 public class JobSeekerMapper { … … 26 29 } 27 30 31 public static JobSeekerEditDetailsDTO mapToJobSeekerEditDetailsDTO(JobSeeker jobSeeker) { 32 return new JobSeekerEditDetailsDTO( 33 jobSeeker.getEmail(), 34 jobSeeker.getFirstName(), 35 jobSeeker.getLastName(), 36 jobSeeker.getPhoneNumber() 37 ); 38 } 39 28 40 } -
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/models/users/mappers/RecruiterMapper.java
rb248810 rbefb988 1 1 package mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.mappers; 2 2 3 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterAdminDetailsDTO; 3 4 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterDTO; 4 5 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterDetailsDTO; 6 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterEditDetailsDTO; 5 7 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.Recruiter; 6 8 … … 12 14 recruiter.getPassword(), 13 15 recruiter.getCompanyName(), 14 recruiter.get PhoneNumber()16 recruiter.getContactPhoneNumber() 15 17 ); 16 18 } … … 18 20 public static RecruiterDetailsDTO mapToRecruiterDetailsDTO(Recruiter recruiter) { 19 21 return new RecruiterDetailsDTO( 22 recruiter.getCompanyName(), 23 recruiter.getCompanyDescription(), 24 recruiter.getContactEmailAddress(), 25 recruiter.getContactPhoneNumber(), 26 recruiter.getReceptionist() 27 ); 28 } 29 public static RecruiterEditDetailsDTO mapToRecruiterEditDetailsDTO(Recruiter recruiter) { 30 return new RecruiterEditDetailsDTO( 31 recruiter.getEmail(), 32 recruiter.getCompanyName(), 33 recruiter.getCompanyDescription(), 34 recruiter.getContactEmailAddress(), 35 recruiter.getContactPhoneNumber(), 36 recruiter.getReceptionist() 37 ); 38 } 39 40 public static RecruiterAdminDetailsDTO mapToRecruiterAdminDetailsDTO(Recruiter recruiter) { 41 return new RecruiterAdminDetailsDTO( 20 42 recruiter.getId(), 21 43 recruiter.getEmail(), 22 44 recruiter.getCompanyName(), 23 45 recruiter.getCompanyDescription(), 24 recruiter.getPhoneNumber(), 46 recruiter.getContactEmailAddress(), 47 recruiter.getContactPhoneNumber(), 48 recruiter.getReceptionist(), 25 49 recruiter.isHasAccess(), 26 50 recruiter.getRegisteredOn() … … 36 60 ); 37 61 } 62 38 63 // Using MapStruct: 39 64 // RecruiterMapper INSTANCE = Mappers.getMapper(RecruiterMapper.class); -
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/service/impl/AdminServiceImpl.java
rb248810 rbefb988 3 3 import lombok.AllArgsConstructor; 4 4 import lombok.RequiredArgsConstructor; 5 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterAdminDetailsDTO; 5 6 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterDetailsDTO; 6 7 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.Recruiter; … … 20 21 21 22 @Override 22 public Recruiter DetailsDTO changeAccess(long recruiterId, boolean access) {23 public RecruiterAdminDetailsDTO changeAccess(long recruiterId, boolean access) { 23 24 Recruiter recruiter = recruiterRepository.findById(recruiterId).orElse(null); 24 25 if (recruiter != null) { 25 26 recruiter.setHasAccess(access); 26 27 recruiterRepository.save(recruiter); 27 return RecruiterMapper.mapToRecruiter DetailsDTO(recruiter);28 return RecruiterMapper.mapToRecruiterAdminDetailsDTO(recruiter); 28 29 } 29 30 return null; … … 32 33 33 34 @Override 34 public List<Recruiter DetailsDTO> findAllRecruiters() {35 public List<RecruiterAdminDetailsDTO> findAllRecruiters() { 35 36 List<Recruiter> recruiterList = recruiterRepository.findAll(); 36 return recruiterList.stream().map(RecruiterMapper::mapToRecruiter DetailsDTO).toList();37 return recruiterList.stream().map(RecruiterMapper::mapToRecruiterAdminDetailsDTO).toList(); 37 38 } 38 39 } -
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/service/impl/JobAdvertisementServiceImpl.java
rb248810 rbefb988 30 30 @Override 31 31 public JobAdDetailsDTO addJobAdvertisement(JobAdvertisementDTO jobAdvertisementDTO) { 32 Recruiter recruiter = recruiterRepository.find RecruiterByEmail(jobAdvertisementDTO.getEmail()).orElseThrow(() -> new IllegalArgumentException("User not found"));32 Recruiter recruiter = recruiterRepository.findById(jobAdvertisementDTO.getId()).orElseThrow(() -> new IllegalArgumentException("User not found")); 33 33 JobAdvertisement jobAdvertisement = new JobAdvertisement( 34 34 recruiter, -
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/service/impl/JwtServiceImpl.java
rb248810 rbefb988 25 25 .claim("role", user.getRole()) 26 26 .claim("access", user.isHasAccess()) 27 .claim("id", user.getId()) 27 28 .setIssuedAt(new Date()) 28 29 .setExpiration(new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 24)) -
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/service/impl/RecruiterServiceImpl.java
rb248810 rbefb988 3 3 import lombok.RequiredArgsConstructor; 4 4 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterDetailsDTO; 5 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterEditDetailsDTO; 5 6 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.Recruiter; 6 7 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.mappers.RecruiterMapper; 7 8 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.repositories.RecruiterRepository; 8 9 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.service.intef.RecruiterService; 10 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Value; 12 import org.springframework.core.io.Resource; 13 import org.springframework.core.io.UrlResource; 9 14 import org.springframework.stereotype.Service; 15 import org.springframework.web.multipart.MultipartFile; 16 17 import java.io.IOException; 18 import java.nio.file.Files; 19 import java.nio.file.Path; 20 import java.nio.file.Paths; 21 import java.nio.file.StandardCopyOption; 10 22 11 23 @Service … … 14 26 15 27 private final RecruiterRepository recruiterRepository; 28 private final Path logoStorageLocation; 29 30 @Autowired 31 RecruiterServiceImpl(@Value("./uploads") String uploadDir, RecruiterRepository recruiterRepository) { 32 this.recruiterRepository = recruiterRepository; 33 34 this.logoStorageLocation = Paths.get(uploadDir + "/logo").toAbsolutePath().normalize(); 35 try { 36 Files.createDirectories(this.logoStorageLocation); 37 } catch (IOException ex) { 38 throw new RuntimeException("Could not create the directory where the uploaded files will be stored.", ex); 39 } 40 } 41 42 43 @Override 44 public RecruiterEditDetailsDTO editRecruiterDetailsById(Long recruiterId, RecruiterEditDetailsDTO recruiterEditDetailsDTO) { 45 Recruiter recruiter = recruiterRepository.findById(recruiterId).orElse(null); 46 recruiter.setEmail(recruiterEditDetailsDTO.getEmail()); 47 recruiter.setCompanyName(recruiterEditDetailsDTO.getCompanyName()); 48 recruiter.setCompanyDescription(recruiterEditDetailsDTO.getCompanyDescription()); 49 recruiter.setContactEmailAddress(recruiterEditDetailsDTO.getContactEmail()); 50 recruiter.setContactPhoneNumber(recruiterEditDetailsDTO.getContactPhoneNumber()); 51 recruiter.setReceptionist(recruiterEditDetailsDTO.getReceptionist()); 52 recruiterRepository.save(recruiter); 53 return RecruiterMapper.mapToRecruiterEditDetailsDTO(recruiter); 54 } 55 56 @Override 57 public RecruiterEditDetailsDTO getRecruiterEditDetailsById(Long recruiterId) { 58 Recruiter recruiter = recruiterRepository.findById(recruiterId).orElse(null); 59 return RecruiterMapper.mapToRecruiterEditDetailsDTO(recruiter); 60 } 61 16 62 17 63 @Override … … 20 66 return RecruiterMapper.mapToRecruiterDetailsDTO(recruiter); 21 67 } 68 69 @Override 70 public void submitLogo(Long recruiterId, MultipartFile logoFile) { 71 72 Path recruiterLogoDir = this.logoStorageLocation.resolve(String.valueOf(recruiterId)); 73 try { 74 Files.createDirectories(recruiterLogoDir); 75 String originalFilename = logoFile.getOriginalFilename(); 76 77 if (originalFilename != null) { 78 Path targetLocation = recruiterLogoDir.resolve(originalFilename); 79 80 Files.copy(logoFile.getInputStream(), targetLocation, StandardCopyOption.REPLACE_EXISTING); 81 82 Recruiter recruiter = recruiterRepository.findById(recruiterId) 83 .orElseThrow(() -> new RuntimeException("Recruiter not found")); 84 String relativePath = Paths.get("uploads", "logo", String.valueOf(recruiterId), originalFilename).toString(); 85 recruiter.setLogoFilePath(relativePath); 86 recruiterRepository.save(recruiter); 87 } 88 89 } catch (IOException ex) { 90 throw new RuntimeException("Could not store file. Please try again!", ex); 91 } 92 93 94 } 95 96 public Resource loadLogoAsResource(Long recruiterId) { 97 Recruiter recruiter = recruiterRepository.findById(recruiterId) 98 .orElseThrow(() -> new RuntimeException("Recruiter not found")); 99 100 try { 101 String relativeLogoPath = recruiter.getLogoFilePath(); 102 Path logoPath = this.logoStorageLocation.getParent().getParent().resolve(relativeLogoPath); 103 Resource resource = new UrlResource(logoPath.toUri()); 104 if (resource.exists()) { 105 return resource; 106 } else { 107 throw new RuntimeException("File not found " + logoPath); 108 } 109 } catch (IOException ex) { 110 throw new RuntimeException("File not found " + ex); 111 } 112 113 } 114 22 115 } -
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/service/intef/AdminService.java
rb248810 rbefb988 1 1 package mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.service.intef; 2 2 3 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterAdminDetailsDTO; 3 4 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterDetailsDTO; 4 5 … … 6 7 7 8 public interface AdminService { 8 Recruiter DetailsDTO changeAccess(long recruiterId, boolean access);9 List<Recruiter DetailsDTO> findAllRecruiters();9 RecruiterAdminDetailsDTO changeAccess(long recruiterId, boolean access); 10 List<RecruiterAdminDetailsDTO> findAllRecruiters(); 10 11 } -
jobvista-backend/src/main/java/mk/ukim/finki/predmeti/internettehnologii/jobvistabackend/service/intef/RecruiterService.java
rb248810 rbefb988 2 2 3 3 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterDetailsDTO; 4 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.Recruiter; 4 import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterEditDetailsDTO; 5 import org.springframework.core.io.Resource; 6 import org.springframework.web.multipart.MultipartFile; 5 7 6 8 public interface RecruiterService { 7 9 RecruiterDetailsDTO getRecruiterDetailsById(Long recruiterId); 10 RecruiterEditDetailsDTO editRecruiterDetailsById(Long recruiterId, RecruiterEditDetailsDTO recruiterEditDetailsDTO); 11 RecruiterEditDetailsDTO getRecruiterEditDetailsById(Long recruiterId); 12 13 void submitLogo(Long recruiterId, MultipartFile logoFile); 14 Resource loadLogoAsResource(Long recruiterId); 8 15 }
Note:
See TracChangeset
for help on using the changeset viewer.