[d8b6c91] | 1 | package mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.controllers;
|
---|
| 2 |
|
---|
[19398ad] | 3 | import lombok.AllArgsConstructor;
|
---|
| 4 | import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterDetailsDTO;
|
---|
[befb988] | 5 | import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.models.users.DTO.RecruiterEditDetailsDTO;
|
---|
[19398ad] | 6 | import mk.ukim.finki.predmeti.internettehnologii.jobvistabackend.service.intef.RecruiterService;
|
---|
[befb988] | 7 | import org.springframework.core.io.Resource;
|
---|
| 8 | import org.springframework.http.HttpHeaders;
|
---|
[19398ad] | 9 | import org.springframework.http.HttpStatus;
|
---|
[befb988] | 10 | import org.springframework.http.MediaType;
|
---|
[d8b6c91] | 11 | import org.springframework.http.ResponseEntity;
|
---|
[19398ad] | 12 | import org.springframework.web.bind.annotation.*;
|
---|
[befb988] | 13 | import org.springframework.web.multipart.MultipartFile;
|
---|
[d8b6c91] | 14 |
|
---|
| 15 | @RestController
|
---|
| 16 | @RequestMapping("/api/recruiter")
|
---|
[19398ad] | 17 | @AllArgsConstructor
|
---|
| 18 | @CrossOrigin(origins = "*")
|
---|
[d8b6c91] | 19 | public class RecruiterController {
|
---|
| 20 |
|
---|
[19398ad] | 21 | private final RecruiterService recruiterService;
|
---|
| 22 |
|
---|
[befb988] | 23 | @GetMapping("/{id}/info")
|
---|
[19398ad] | 24 | public ResponseEntity<?> getRecruiterDetailsById(@PathVariable("id") Long id) {
|
---|
| 25 | RecruiterDetailsDTO recruiterDetailsDTO = recruiterService.getRecruiterDetailsById(id);
|
---|
| 26 | return new ResponseEntity<>(recruiterDetailsDTO, HttpStatus.OK);
|
---|
[d8b6c91] | 27 | }
|
---|
[befb988] | 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 | }
|
---|
[d8b6c91] | 57 | }
|
---|