source: src/main/java/it/finki/tinki/web/controller/WorkRegisterController.java@ 5f9d25a

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

refactoring controllers

  • Property mode set to 100644
File size: 2.0 KB
Line 
1package it.finki.tinki.web.controller;
2
3import it.finki.tinki.model.Work.Internship;
4import it.finki.tinki.model.Work.Job;
5import it.finki.tinki.model.Work.Project;
6import it.finki.tinki.model.dto.register.work.InternshipRegisterDTO;
7import it.finki.tinki.model.dto.register.work.JobRegisterDTO;
8import it.finki.tinki.model.dto.register.work.ProjectRegisterDTO;
9import it.finki.tinki.model.dto.response.work.InternshipResponseDTO;
10import it.finki.tinki.model.dto.response.work.JobResponseDTO;
11import it.finki.tinki.model.dto.response.work.ProjectResponseDTO;
12import it.finki.tinki.service.WorkService;
13import org.springframework.web.bind.annotation.*;
14
15@RestController
16@CrossOrigin(origins = "http://localhost:3000")
17@RequestMapping(path = "/api/register/work")
18public class WorkRegisterController {
19
20 WorkService workService;
21
22 public WorkRegisterController(WorkService workService) {
23 this.workService = workService;
24 }
25
26 @PostMapping("/job")
27 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);
31 }
32
33 @PostMapping("/internship")
34 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);
38 }
39
40 @PostMapping("/project")
41 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);
45 }
46}
Note: See TracBrowser for help on using the repository browser.