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.4 KB
|
Rev | Line | |
---|
[46fd0c7] | 1 | package edu.gjoko.schedlr.controllers.rest;
|
---|
| 2 |
|
---|
| 3 | import edu.gjoko.schedlr.entity.Business;
|
---|
[950fa0d] | 4 | import edu.gjoko.schedlr.entity.BusinessType;
|
---|
[46fd0c7] | 5 | import edu.gjoko.schedlr.services.BusinessService;
|
---|
| 6 | import lombok.AllArgsConstructor;
|
---|
| 7 | import org.springframework.web.bind.annotation.*;
|
---|
| 8 |
|
---|
[8bcd64c] | 9 | import javax.servlet.http.HttpServletRequest;
|
---|
[46fd0c7] | 10 | import java.util.List;
|
---|
| 11 |
|
---|
| 12 | @RestController
|
---|
| 13 | @RequestMapping("api/business")
|
---|
| 14 | @AllArgsConstructor
|
---|
| 15 | public class BusinessController {
|
---|
| 16 |
|
---|
| 17 | final BusinessService businessService;
|
---|
| 18 |
|
---|
| 19 | @PostMapping
|
---|
| 20 | public void getBusinessTypes(@RequestBody Business business) {
|
---|
| 21 | businessService.saveBusiness(business);
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | @GetMapping
|
---|
[9050790] | 25 | public List<Business> findAll() {
|
---|
| 26 | return businessService.findAll();
|
---|
[46fd0c7] | 27 | }
|
---|
| 28 |
|
---|
| 29 | @PatchMapping
|
---|
[9050790] | 30 | public void updateBusinesses(@RequestBody List<Business> businessList) {
|
---|
| 31 | businessService.updateBusinesses(businessList);
|
---|
[46fd0c7] | 32 | }
|
---|
[8bcd64c] | 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 | }
|
---|
[950fa0d] | 39 |
|
---|
| 40 | @GetMapping(path = "/{businessTypeId}")
|
---|
| 41 | public List<Business> getBusinessesByBusinessType(@PathVariable("businessTypeId") Long id) {
|
---|
| 42 | BusinessType businessType = new BusinessType();
|
---|
| 43 | businessType.setId(id);
|
---|
| 44 | return businessService.findByBusinessTypeAndActiveStatus(businessType);
|
---|
| 45 | }
|
---|
[46fd0c7] | 46 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.