[bd46dbb] | 1 | package it.finki.tinki.web.controller;
|
---|
| 2 |
|
---|
[33d4f5d] | 3 | import it.finki.tinki.model.Users.Account;
|
---|
[297bd16] | 4 | import it.finki.tinki.model.Work.Internship;
|
---|
| 5 | import it.finki.tinki.model.Work.Job;
|
---|
| 6 | import it.finki.tinki.model.Work.Project;
|
---|
| 7 | import it.finki.tinki.model.dto.register.work.InternshipRegisterDTO;
|
---|
| 8 | import it.finki.tinki.model.dto.register.work.JobRegisterDTO;
|
---|
| 9 | import it.finki.tinki.model.dto.register.work.ProjectRegisterDTO;
|
---|
| 10 | import it.finki.tinki.model.dto.response.work.InternshipResponseDTO;
|
---|
[bd46dbb] | 11 | import it.finki.tinki.model.dto.response.work.JobResponseDTO;
|
---|
[297bd16] | 12 | import it.finki.tinki.model.dto.response.work.ProjectResponseDTO;
|
---|
[33d4f5d] | 13 | import it.finki.tinki.model.enumerator.AccountType;
|
---|
[297bd16] | 14 | import it.finki.tinki.service.WorkService;
|
---|
[f067338] | 15 | import org.springframework.web.bind.annotation.*;
|
---|
| 16 |
|
---|
[bd46dbb] | 17 | @RestController
|
---|
[17abe5e] | 18 | @CrossOrigin(origins = "http://localhost:3000")
|
---|
[bd46dbb] | 19 | @RequestMapping(path = "/api/register/work")
|
---|
| 20 | public class WorkRegisterController {
|
---|
| 21 |
|
---|
[297bd16] | 22 | WorkService workService;
|
---|
| 23 |
|
---|
| 24 | public WorkRegisterController(WorkService workService) {
|
---|
| 25 | this.workService = workService;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | @PostMapping("/job")
|
---|
| 29 | public JobResponseDTO registerJob(@RequestBody JobRegisterDTO body){
|
---|
[33d4f5d] | 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();
|
---|
[297bd16] | 38 | }
|
---|
| 39 |
|
---|
| 40 | @PostMapping("/internship")
|
---|
| 41 | public InternshipResponseDTO registerInternship(@RequestBody InternshipRegisterDTO body){
|
---|
[33d4f5d] | 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();
|
---|
[297bd16] | 49 | }
|
---|
| 50 |
|
---|
| 51 | @PostMapping("/project")
|
---|
| 52 | public ProjectResponseDTO registerProject(@RequestBody ProjectRegisterDTO body){
|
---|
[33d4f5d] | 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();
|
---|
[297bd16] | 61 | }
|
---|
[bd46dbb] | 62 | }
|
---|