source: src/main/java/edu/gjoko/schedlr/controllers/rest/AppointmentController.java@ 950fa0d

Last change on this file since 950fa0d was 950fa0d, checked in by Gjoko Kostadinov <gjoko.kostadinov@…>, 14 months ago

Periodic update

  • Property mode set to 100644
File size: 1.3 KB
Line 
1package edu.gjoko.schedlr.controllers.rest;
2
3import edu.gjoko.schedlr.entity.Appointment;
4import edu.gjoko.schedlr.entity.Business;
5import edu.gjoko.schedlr.entity.Stakeholder;
6import edu.gjoko.schedlr.repositories.AppointmentRepository;
7import edu.gjoko.schedlr.services.AppointmentsService;
8import edu.gjoko.schedlr.services.StakeholderService;
9import lombok.AllArgsConstructor;
10import org.springframework.web.bind.annotation.*;
11
12import javax.servlet.http.HttpServletRequest;
13import java.util.List;
14
15@RestController
16@RequestMapping("api/appointment")
17@AllArgsConstructor
18public class AppointmentController {
19
20 private final AppointmentsService appointmentsService;
21
22 @PostMapping
23 public void getBusinessTypes(@RequestBody Appointment appointment, HttpServletRequest request) {
24 Long customerId = (long) request.getSession(true).getAttribute("stakeholderId");
25 Stakeholder customer = new Stakeholder();
26 customer.setId(customerId);
27 appointment.setCustomer(customer);
28 appointmentsService.saveAppointment(appointment);
29 }
30
31 @GetMapping(path = "/business/{businessId}")
32 public List<Appointment> getAppointmentsByBusiness(@PathVariable("businessId") Long businessId) {
33 var business = new Business();
34 business.setId(businessId);
35 return appointmentsService.getAppointmentsByBusiness(business);
36 }
37}
Note: See TracBrowser for help on using the repository browser.