Changeset 33d4f5d for src/main/java/it/finki/tinki/web
- Timestamp:
- 01/12/21 02:42:18 (4 years ago)
- Branches:
- master
- Children:
- a70db1a
- Parents:
- 8f1f460
- Location:
- src/main/java/it/finki/tinki/web/controller
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/it/finki/tinki/web/controller/AccountEditController.java
r8f1f460 r33d4f5d 35 35 } 36 36 37 @PostMapping(path = "/user/{id} ")37 @PostMapping(path = "/user/{id}/{email}") 38 38 public UserResponseDTO editUser(@PathVariable(name = "id") Long id, 39 @PathVariable(name = "email") String email, 39 40 @RequestBody UserRegisterDTO body){ 40 41 41 Optional<?> a = this.accountService.findByIdAndEmail(id, body.getEmail(), AccountType.USER);42 Optional<?> a = this.accountService.findByIdAndEmail(id, email, AccountType.USER); 42 43 43 44 if(a.isPresent()){ … … 51 52 } 52 53 53 @PostMapping(path = "/company/{id} ")54 @PostMapping(path = "/company/{id}/{email}") 54 55 public CompanyResponseDTO editCompany(@PathVariable(name = "id") Long id, 56 @PathVariable(name = "email") String email, 55 57 @RequestBody CompanyRegisterDTO body){ 56 58 57 Optional<?> a = this.accountService.findByIdAndEmail(id, body.getEmail(), AccountType.COMPANY);59 Optional<?> a = this.accountService.findByIdAndEmail(id, email, AccountType.COMPANY); 58 60 59 61 if(a.isPresent()){ … … 65 67 } 66 68 67 @PostMapping(path = "/team/{id} ")69 @PostMapping(path = "/team/{id}/{email}") 68 70 public TeamResponseDTO editTeam(@PathVariable(name = "id") Long id, 71 @PathVariable(name = "email") String email, 69 72 @RequestBody TeamRegisterDTO body){ 70 73 71 Optional<?> a = this.accountService.findByIdAndEmail(id, body.getEmail(), AccountType.TEAM);74 Optional<?> a = this.accountService.findByIdAndEmail(id, email, AccountType.TEAM); 72 75 73 76 if(a.isPresent()){ -
src/main/java/it/finki/tinki/web/controller/AccountRegisterController.java
r8f1f460 r33d4f5d 7 7 import it.finki.tinki.model.dto.register.account.UserRegisterDTO; 8 8 import it.finki.tinki.service.AccountService; 9 import it.finki.tinki.service.MatchmakerService;10 9 import it.finki.tinki.service.SkillService; 11 import it.finki.tinki.service.WorkService;12 10 import org.springframework.web.bind.annotation.*; 13 11 … … 23 21 AccountService accountService; 24 22 SkillService skillService; 25 WorkService workService;26 MatchmakerService matchmakerService;27 23 28 public AccountRegisterController(AccountService accountService, SkillService skillService , WorkService workService, MatchmakerService matchmakerService) {24 public AccountRegisterController(AccountService accountService, SkillService skillService) { 29 25 this.accountService = accountService; 30 26 this.skillService = skillService; 31 this.workService = workService;32 this.matchmakerService = matchmakerService;33 27 } 34 28 -
src/main/java/it/finki/tinki/web/controller/LoginController.java
r8f1f460 r33d4f5d 1 1 package it.finki.tinki.web.controller; 2 2 3 import it.finki.tinki.model.Work.Internship;4 import it.finki.tinki.model.Work.Job;5 import it.finki.tinki.model.Work.Project;6 3 import it.finki.tinki.model.Users.Account; 7 import it.finki.tinki.model.Users.Company;8 4 import it.finki.tinki.model.Users.Team; 9 5 import it.finki.tinki.model.Users.User; 10 6 import it.finki.tinki.model.dto.*; 11 7 import it.finki.tinki.model.dto.response.account.LoginResponseDTO; 12 import it.finki.tinki.model.dto.response.account.CompanyResponseDTO;13 import it.finki.tinki.model.dto.response.account.TeamResponseDTO;14 import it.finki.tinki.model.dto.response.account.UserResponseDTO;15 import it.finki.tinki.model.dto.response.work.InternshipResponseDTO;16 import it.finki.tinki.model.dto.response.work.JobResponseDTO;17 import it.finki.tinki.model.dto.response.work.ProjectResponseDTO;18 import it.finki.tinki.model.enumerator.AccountType;19 8 import it.finki.tinki.service.AccountService; 20 9 import it.finki.tinki.service.BuilderService; 21 import it.finki.tinki.service.MatchmakerService;22 10 import it.finki.tinki.service.WorkService; 23 11 import org.springframework.web.bind.annotation.*; … … 32 20 33 21 AccountService accountService; 34 WorkService workService;35 22 BuilderService builderService; 36 23 37 public LoginController(AccountService accountService, WorkService workService,BuilderService builderService) {24 public LoginController(AccountService accountService, BuilderService builderService) { 38 25 this.accountService = accountService; 39 this.workService = workService;40 26 this.builderService = builderService; 41 27 } … … 58 44 return new LoginResponseDTO(); 59 45 } 60 61 @GetMapping(path = "/job/search")62 public List<JobResponseDTO> jobRes(@RequestParam(name = "text") String text){63 return this.workService.fullTextJobSearch(text);64 }65 66 @GetMapping(path = "/internship/search")67 public List<InternshipResponseDTO> internshipRes(@RequestParam(name = "text") String text){68 return this.workService.fullTextInternshipSearch(text);69 }70 71 @GetMapping(path = "/project/search")72 public List<ProjectResponseDTO> projectRes(@RequestParam(name = "text") String text){73 return this.workService.fullTextProjectSearch(text);74 }75 46 } -
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 } -
src/main/java/it/finki/tinki/web/controller/WorkRegisterController.java
r8f1f460 r33d4f5d 1 1 package it.finki.tinki.web.controller; 2 2 3 import it.finki.tinki.model.Users.Account; 3 4 import it.finki.tinki.model.Work.Internship; 4 5 import it.finki.tinki.model.Work.Job; … … 10 11 import it.finki.tinki.model.dto.response.work.JobResponseDTO; 11 12 import it.finki.tinki.model.dto.response.work.ProjectResponseDTO; 13 import it.finki.tinki.model.enumerator.AccountType; 12 14 import it.finki.tinki.service.WorkService; 13 15 import org.springframework.web.bind.annotation.*; … … 26 28 @PostMapping("/job") 27 29 public JobResponseDTO registerJob(@RequestBody JobRegisterDTO body){ 28 Job j = this.workService.insertJob(body.getTitle(), 29 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsRequired(), body.getType()); 30 return new JobResponseDTO(j); 30 31 if(body.getType() != AccountType.USER){ 32 Job j = this.workService.insertJob(body.getTitle(), 33 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsRequired(), body.getType()); 34 return new JobResponseDTO(j); 35 } 36 37 return new JobResponseDTO(); 31 38 } 32 39 33 40 @PostMapping("/internship") 34 41 public InternshipResponseDTO registerInternship(@RequestBody InternshipRegisterDTO body){ 35 Internship j = this.workService.insertInternship(body.getTitle(), 36 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsTrained(), body.getOpenSpots(), body.getType()); 37 return new InternshipResponseDTO(j); 42 if(body.getType() == AccountType.COMPANY){ 43 Internship j = this.workService.insertInternship(body.getTitle(), 44 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsTrained(), body.getOpenSpots(), body.getType()); 45 return new InternshipResponseDTO(j); 46 } 47 48 return new InternshipResponseDTO(); 38 49 } 39 50 40 51 @PostMapping("/project") 41 52 public ProjectResponseDTO registerProject(@RequestBody ProjectRegisterDTO body){ 42 Project j = this.workService.insertProject(body.getTitle(), 43 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsRequired(), body.getValidUntil(), body.getType()); 44 return new ProjectResponseDTO(j); 53 54 if(body.getType() == AccountType.TEAM){ 55 Project j = this.workService.insertProject(body.getTitle(), 56 body.getDescription(), body.getAccountId(), body.getSalary(), body.getSkillsRequired(), body.getValidUntil(), body.getType()); 57 return new ProjectResponseDTO(j); 58 } 59 60 return new ProjectResponseDTO(); 45 61 } 46 62 }
Note:
See TracChangeset
for help on using the changeset viewer.