[723994f] | 1 | package it.finki.tinki.web.controller;
|
---|
| 2 |
|
---|
[bd46dbb] | 3 | import it.finki.tinki.model.Work.Internship;
|
---|
| 4 | import it.finki.tinki.model.Work.Job;
|
---|
| 5 | import it.finki.tinki.model.Work.Project;
|
---|
[723994f] | 6 | import it.finki.tinki.model.Users.Account;
|
---|
[509cb95] | 7 | import it.finki.tinki.model.Users.Company;
|
---|
[723994f] | 8 | import it.finki.tinki.model.Users.Team;
|
---|
| 9 | import it.finki.tinki.model.Users.User;
|
---|
[509cb95] | 10 | import it.finki.tinki.model.dto.*;
|
---|
[bd46dbb] | 11 | 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;
|
---|
[723994f] | 18 | import it.finki.tinki.model.enumerator.AccountType;
|
---|
| 19 | import it.finki.tinki.service.AccountService;
|
---|
[5f9d25a] | 20 | import it.finki.tinki.service.BuilderService;
|
---|
[723994f] | 21 | import it.finki.tinki.service.MatchmakerService;
|
---|
[509cb95] | 22 | import it.finki.tinki.service.WorkService;
|
---|
[723994f] | 23 | import org.springframework.web.bind.annotation.*;
|
---|
| 24 | import org.springframework.web.server.ResponseStatusException;
|
---|
| 25 |
|
---|
[4cec0a3] | 26 | import java.util.List;
|
---|
[723994f] | 27 |
|
---|
| 28 | @RestController
|
---|
| 29 | @CrossOrigin(origins = "http://localhost:3000")
|
---|
| 30 | @RequestMapping("/api")
|
---|
| 31 | public class LoginController {
|
---|
| 32 |
|
---|
| 33 | AccountService accountService;
|
---|
[509cb95] | 34 | WorkService workService;
|
---|
[5f9d25a] | 35 | BuilderService builderService;
|
---|
[723994f] | 36 |
|
---|
[5f9d25a] | 37 | public LoginController(AccountService accountService, WorkService workService, BuilderService builderService) {
|
---|
[723994f] | 38 | this.accountService = accountService;
|
---|
[509cb95] | 39 | this.workService = workService;
|
---|
[5f9d25a] | 40 | this.builderService = builderService;
|
---|
[723994f] | 41 | }
|
---|
| 42 |
|
---|
| 43 | @PostMapping(path = "/login")
|
---|
[277b400] | 44 | public LoginResponseDTO loginProcess(@RequestBody AccountLoginDTO body) throws ResponseStatusException {
|
---|
[723994f] | 45 |
|
---|
| 46 | Account a1 = accountService.findUser(body.getEmail(), body.getPassword(), body.getType());
|
---|
[509cb95] | 47 |
|
---|
[723994f] | 48 | if(a1!=null){
|
---|
| 49 | if(a1.getClass().equals(User.class)){
|
---|
[5f9d25a] | 50 | return this.builderService.buildUserResponseDTO(a1);
|
---|
[277b400] | 51 | }else if(a1.getClass().equals(Team.class)){
|
---|
[5f9d25a] | 52 | return this.builderService.buildTeamResponseDTO(a1);
|
---|
[277b400] | 53 | }else{
|
---|
[5f9d25a] | 54 | return this.builderService.buildCompanyResponseDTO(a1);
|
---|
[277b400] | 55 | }
|
---|
| 56 | }
|
---|
[723994f] | 57 |
|
---|
[277b400] | 58 | return new LoginResponseDTO();
|
---|
| 59 | }
|
---|
[723994f] | 60 |
|
---|
[f067338] | 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 | }
|
---|
[723994f] | 75 | }
|
---|