source: src/main/java/edu/gjoko/schedlr/controllers/rest/CustomerApi.java

Last change on this file was 1413ee2, checked in by gjoko kostadinov <gjokokostadinov@…>, 11 months ago

Add all bug fixes.

  • Property mode set to 100644
File size: 1.0 KB
Line 
1package edu.gjoko.schedlr.controllers.rest;
2
3import edu.gjoko.schedlr.entity.Business;
4import edu.gjoko.schedlr.entity.Stakeholder;
5import edu.gjoko.schedlr.services.StakeholderService;
6import lombok.AllArgsConstructor;
7import org.springframework.web.bind.annotation.*;
8
9import javax.servlet.http.HttpServletRequest;
10import java.util.List;
11
12@RestController
13@RequestMapping("api/customer")
14@AllArgsConstructor
15public class CustomerApi {
16
17 private final StakeholderService stakeholderService;
18
19 @GetMapping(path = "/me")
20 public Stakeholder getCustomerInfo(HttpServletRequest request) {
21 Long customerId = (long) request.getSession(true).getAttribute("stakeholderId");
22 return stakeholderService.findById(customerId);
23 }
24
25 @PatchMapping
26 public void updateCustomer(@RequestBody Stakeholder stakeholder, HttpServletRequest request) {
27 Long customerId = (long) request.getSession(true).getAttribute("stakeholderId");
28 stakeholderService.saveOrUpdateStakeholder(stakeholder, customerId);
29 }
30}
Note: See TracBrowser for help on using the repository browser.