1 | package it.finki.tinki.web.controller;
|
---|
2 |
|
---|
3 | import it.finki.tinki.model.Users.Account;
|
---|
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;
|
---|
11 | import it.finki.tinki.model.dto.response.work.JobResponseDTO;
|
---|
12 | import it.finki.tinki.model.dto.response.work.ProjectResponseDTO;
|
---|
13 | import it.finki.tinki.model.enumerator.AccountType;
|
---|
14 | import it.finki.tinki.service.WorkService;
|
---|
15 | import org.springframework.web.bind.annotation.*;
|
---|
16 |
|
---|
17 | @RestController
|
---|
18 | @CrossOrigin(origins = "http://localhost:3000")
|
---|
19 | @RequestMapping(path = "/api/register/work")
|
---|
20 | public class WorkRegisterController {
|
---|
21 |
|
---|
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){
|
---|
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();
|
---|
38 | }
|
---|
39 |
|
---|
40 | @PostMapping("/internship")
|
---|
41 | public InternshipResponseDTO registerInternship(@RequestBody InternshipRegisterDTO body){
|
---|
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();
|
---|
49 | }
|
---|
50 |
|
---|
51 | @PostMapping("/project")
|
---|
52 | public ProjectResponseDTO registerProject(@RequestBody ProjectRegisterDTO body){
|
---|
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();
|
---|
61 | }
|
---|
62 | }
|
---|