source: src/main/java/it/finki/tinki/web/controller/WorkRegisterController.java@ 33d4f5d

Last change on this file since 33d4f5d was 33d4f5d, checked in by Vzdra <vladko.zdravkovski@…>, 3 years ago

bugfixes and refactoring

  • Property mode set to 100644
File size: 2.4 KB
Line 
1package it.finki.tinki.web.controller;
2
3import it.finki.tinki.model.Users.Account;
4import it.finki.tinki.model.Work.Internship;
5import it.finki.tinki.model.Work.Job;
6import it.finki.tinki.model.Work.Project;
7import it.finki.tinki.model.dto.register.work.InternshipRegisterDTO;
8import it.finki.tinki.model.dto.register.work.JobRegisterDTO;
9import it.finki.tinki.model.dto.register.work.ProjectRegisterDTO;
10import it.finki.tinki.model.dto.response.work.InternshipResponseDTO;
11import it.finki.tinki.model.dto.response.work.JobResponseDTO;
12import it.finki.tinki.model.dto.response.work.ProjectResponseDTO;
13import it.finki.tinki.model.enumerator.AccountType;
14import it.finki.tinki.service.WorkService;
15import org.springframework.web.bind.annotation.*;
16
17@RestController
18@CrossOrigin(origins = "http://localhost:3000")
19@RequestMapping(path = "/api/register/work")
20public 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}
Note: See TracBrowser for help on using the repository browser.