- Timestamp:
- 01/12/21 02:42:18 (4 years ago)
- Branches:
- master
- Children:
- a70db1a
- Parents:
- 8f1f460
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/it/finki/tinki/web/controller/WorkEditController.java
r8f1f460 r33d4f5d 14 14 import org.springframework.web.bind.annotation.*; 15 15 16 import java.util.HashMap; 17 import java.util.Map; 18 16 19 @RestController 17 20 @CrossOrigin(origins = "http://localhost:3000") … … 26 29 27 30 @PostMapping("/job/{id}") 28 public JobResponseDTO editJob(@PathVariable Long id, 29 @RequestBody JobRegisterDTO body){ 31 public Map<String, String> editJob(@PathVariable Long id, 32 @RequestBody JobRegisterDTO body){ 33 34 Map<String, String> response = new HashMap<>(); 30 35 31 36 if(body.getAccountId().equals(this.workService.getJobById(id).getAccount().getId())) { 32 37 Job k = this.workService.editJob(id, body.getTitle(), body.getDescription(), body.getSalary()); 33 return new JobResponseDTO(k); 38 if(k!=null){ 39 response.put("success", "Job edited successfully!"); 40 return response; 41 } 34 42 } 35 return null; 43 44 response.put("error", "Internship edit failed!"); 45 return response; 36 46 } 37 47 38 48 @PostMapping("/internship/{id}") 39 public InternshipResponseDTOeditInternship(@PathVariable Long id,49 public Map<String, String> editInternship(@PathVariable Long id, 40 50 @RequestBody InternshipRegisterDTO body){ 51 52 Map<String, String> response = new HashMap<>(); 41 53 42 54 if(body.getAccountId().equals(this.workService.getInternshipById(id).getAccount().getId())){ 43 55 Internship k = this.workService.editInternship(id, body.getTitle(), body.getDescription(), body.getSalary(), body.getOpenSpots()); 44 return new InternshipResponseDTO(k); 56 if(k!=null){ 57 response.put("success", "Internship edited successfully!"); 58 return response; 59 } 45 60 } 46 return null; 61 62 response.put("error", "Internship edit failed!"); 63 return response; 47 64 } 48 65 49 66 @PostMapping("/project/{id}") 50 public ProjectResponseDTOeditProject(@PathVariable Long id,67 public Map<String, String> editProject(@PathVariable Long id, 51 68 @RequestBody ProjectRegisterDTO body){ 69 70 Map<String, String> response = new HashMap<>(); 52 71 53 72 if(body.getAccountId().equals(this.workService.getProjectById(id).getAccount().getId())) { 54 73 Project k = this.workService.editProject(id, body.getTitle(), body.getDescription(), body.getSalary()); 55 return new ProjectResponseDTO(k); 74 if(k!=null){ 75 response.put("success", "Project edited successfully!"); 76 return response; 77 } 56 78 } 57 return null; 79 80 response.put("error", "Project edit failed!"); 81 return response; 58 82 } 59 83 }
Note:
See TracChangeset
for help on using the changeset viewer.