Changeset 6729ba5 for src/main/java/it/finki/tinki/web/controller
- Timestamp:
- 01/15/21 16:39:45 (4 years ago)
- Branches:
- master
- Children:
- 81c9e25
- Parents:
- ed3f5c4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/it/finki/tinki/web/controller/WorkEditController.java
red3f5c4 r6729ba5 4 4 import it.finki.tinki.model.Work.Job; 5 5 import it.finki.tinki.model.Work.Project; 6 import it.finki.tinki.model.dto.edit.work.InternshipEditDTO; 7 import it.finki.tinki.model.dto.edit.work.WorkEditDTO; 6 8 import it.finki.tinki.model.dto.register.work.InternshipRegisterDTO; 7 9 import it.finki.tinki.model.dto.register.work.JobRegisterDTO; … … 29 31 30 32 @PostMapping("/job/{id}") 31 public Map<String, String>editJob(@PathVariable Long id,32 @RequestBody JobRegisterDTO body){33 public JobResponseDTO editJob(@PathVariable Long id, 34 @RequestBody WorkEditDTO body){ 33 35 34 Map<String, String> response = new HashMap<>();36 Job j = this.workService.getJobById(id); 35 37 36 if(body.getAccountId().equals( this.workService.getJobById(id).getAccount().getId())) {38 if(body.getAccountId().equals(j.getAccount().getId())) { 37 39 Job k = this.workService.editJob(id, body.getTitle(), body.getDescription(), body.getSalary()); 38 40 if(k!=null){ 39 response.put("success", "Job edited successfully!"); 40 return response; 41 return new JobResponseDTO(k); 41 42 } 42 43 } 43 44 44 response.put("error", "Internship edit failed!"); 45 return response; 45 return new JobResponseDTO(); 46 46 } 47 47 48 48 @PostMapping("/internship/{id}") 49 public Map<String, String>editInternship(@PathVariable Long id,50 @RequestBody Internship RegisterDTO body){49 public InternshipResponseDTO editInternship(@PathVariable Long id, 50 @RequestBody InternshipEditDTO body){ 51 51 52 Map<String, String> response = new HashMap<>();52 Internship i = this.workService.getInternshipById(id); 53 53 54 if(body.getAccountId().equals( this.workService.getInternshipById(id).getAccount().getId())){54 if(body.getAccountId().equals(i.getAccount().getId())){ 55 55 Internship k = this.workService.editInternship(id, body.getTitle(), body.getDescription(), body.getSalary(), body.getOpenSpots()); 56 56 if(k!=null){ 57 response.put("success", "Internship edited successfully!"); 58 return response; 57 return new InternshipResponseDTO(k); 59 58 } 60 59 } 61 60 62 response.put("error", "Internship edit failed!"); 63 return response; 61 return new InternshipResponseDTO(); 64 62 } 65 63 66 64 @PostMapping("/project/{id}") 67 public Map<String, String>editProject(@PathVariable Long id,68 @RequestBody ProjectRegisterDTO body){65 public ProjectResponseDTO editProject(@PathVariable Long id, 66 @RequestBody WorkEditDTO body){ 69 67 70 Map<String, String> response = new HashMap<>();68 Project p = this.workService.getProjectById(id); 71 69 72 if(body.getAccountId().equals( this.workService.getProjectById(id).getAccount().getId())) {70 if(body.getAccountId().equals(p.getAccount().getId())) { 73 71 Project k = this.workService.editProject(id, body.getTitle(), body.getDescription(), body.getSalary()); 74 72 if(k!=null){ 75 response.put("success", "Project edited successfully!"); 76 return response; 73 return new ProjectResponseDTO(k); 77 74 } 78 75 } 79 76 80 response.put("error", "Project edit failed!"); 81 return response; 77 return new ProjectResponseDTO(); 82 78 } 83 79 }
Note:
See TracChangeset
for help on using the changeset viewer.