source: sources/app/src/main/java/parkup/controllers/VrabotenController.java@ 9ff45d6

Last change on this file since 9ff45d6 was 9ff45d6, checked in by andrejTavchioski <andrej.tavchioski@…>, 2 years ago

Fixed some functionalities related to parkingSessions and parkingZones

  • Property mode set to 100644
File size: 3.2 KB
Line 
1package parkup.controllers;
2
3import java.util.List;
4import java.util.Optional;
5import java.util.stream.Collectors;
6
7import org.springframework.beans.factory.annotation.Autowired;
8import org.springframework.web.bind.annotation.*;
9import parkup.configs.RegistrationRequest;
10//import parkup.configs.RegistrationServiceW;
11import parkup.data.AddUpdateVraboten;
12import parkup.data.enumarations.EmployeeStatus;
13import parkup.entities.Vraboten;
14import parkup.services.VrabotenService;
15import parkup.data.VrabotenDemo;
16
17@RestController
18public class VrabotenController {
19 private final VrabotenService vrabotenService;
20// private final RegistrationServiceW registrationServiceW;
21
22 @Autowired
23 public VrabotenController(VrabotenService vrabotenService) {
24 this.vrabotenService = vrabotenService;
25 }
26
27 @GetMapping({"/vraboten"})
28 public List<Vraboten> getAllVraboten() {
29 return this.vrabotenService.getVraboteni();
30 }
31
32 @GetMapping({"/vraboten/{vrabotenId}"})
33 public Vraboten getVraboten(@PathVariable int vrabotenId) {
34 Vraboten vraboten = this.vrabotenService.findById(vrabotenId);
35 if (vraboten != null) {
36 return vraboten;
37 } else {
38 throw new RuntimeException("Vraboten not found");
39 }
40 }
41
42 @GetMapping({"/vraboten/vrabotenDemo"})
43 public List<VrabotenDemo> getVraboteniDemos(){
44 return this.vrabotenService.getAllVraboteniDemos();
45 }
46
47 @PostMapping({"/vraboten"})
48 public Optional<Vraboten> addVraboten(@RequestBody AddUpdateVraboten vraboten) {
49 return this.vrabotenService.addVraboten(vraboten.getPassword(), vraboten.getConfirmPass(), vraboten.isLocked(),vraboten.getFirstName(), vraboten.getLastName(),
50 vraboten.getMobileNumber(), vraboten.getEmail(), vraboten.getStatus(),vraboten.getParkingZones());
51 }
52
53 @PutMapping({"/vraboten/lock/{vrabotenId}"})
54 public void lockVraboten(@PathVariable int vrabotenId) {
55 this.vrabotenService.lockVrabotenAcc(vrabotenId);
56 }
57
58// @PostMapping({"/vraboten/setStatus/{vrabotenId}"})
59// public void setVrabotenStatus(@PathVariable int vrabotenId,@RequestParam String vrabotenStatus){
60// this.vrabotenService.setVrabotenStatus(vrabotenId,vrabotenStatus);
61// }
62
63 @PutMapping({"/vraboten/{vrabotenId}"})
64 public Vraboten updateVraboten(@PathVariable int vrabotenId, @RequestBody AddUpdateVraboten vraboten) {
65 return this.vrabotenService.updateVraboten(vrabotenId,vraboten.getPassword(), vraboten.getConfirmPass(), vraboten.isLocked(),vraboten.getFirstName(), vraboten.getLastName(),
66 vraboten.getMobileNumber(), vraboten.getEmail(), vraboten.getStatus(),vraboten.getParkingZones());
67 }
68
69 @DeleteMapping({"/vraboten/{vrabotenId}"})
70 public Optional<Vraboten> deleteVraboten(@PathVariable int vrabotenId) {
71 return this.vrabotenService.deleteVraboten(vrabotenId);
72 }
73
74// @PostMapping({"/vraboten/registration"})
75// public String register(@RequestBody RegistrationRequest request){
76// return registrationServiceW.register(request);
77// }
78//
79// @GetMapping(path = "/vraboten/registration/confirm")
80// public String confirm(@RequestParam("token") String token) {
81// return registrationServiceW.confirmToken(token);
82// }
83}
Note: See TracBrowser for help on using the repository browser.