source: src/main/java/edu/gjoko/schedlr/controllers/rest/BusinessApi.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 100755
File size: 1.4 KB
Line 
1package edu.gjoko.schedlr.controllers.rest;
2
3import edu.gjoko.schedlr.entity.Business;
4import edu.gjoko.schedlr.services.BusinessService;
5import lombok.AllArgsConstructor;
6import org.springframework.web.bind.annotation.*;
7
8import javax.servlet.http.HttpServletRequest;
9import java.util.List;
10
11@RestController
12@RequestMapping("api/business")
13@AllArgsConstructor
14public class BusinessApi {
15
16 private final BusinessService businessService;
17
18 @PostMapping
19 public void saveBusiness(@RequestBody Business business) {
20 businessService.saveBusiness(business);
21 }
22
23 @GetMapping
24 public List<Business> findAll() {
25 return businessService.findAll();
26 }
27
28 @PatchMapping
29 public void updateBusinesses(@RequestBody List<Business> businessList, HttpServletRequest request) {
30 Long businessOwnerId = (long) request.getSession(true).getAttribute("stakeholderId");
31 businessService.updateBusinesses(businessList, businessOwnerId);
32 }
33
34 @GetMapping(path = "/me")
35 public Business getPersonalInfo(HttpServletRequest request) {
36 Long businessOwnerId = (long) request.getSession(true).getAttribute("stakeholderId");
37 return businessService.findByOwner(businessOwnerId);
38 }
39
40 @GetMapping(path = "/{businessTypeId}")
41 public List<Business> getBusinessesByBusinessType(@PathVariable("businessTypeId") Long id) {
42 return businessService.findByBusinessTypeAndActiveStatus(id);
43 }
44}
Note: See TracBrowser for help on using the repository browser.