Created
November 14, 2021 13:15
-
-
Save baso53/35ecb750077c19a50617e829d9497f46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
@RequestMapping("/app") | |
@RequiredArgsConstructor | |
public class AppController { | |
private final CompanyJpaRepository companyRepo; | |
private final SubsidiaryJpaRepository subsidiaryRepo; | |
@GetMapping(path = "/company/{id}") | |
@PreAuthorize("hasAuthority('COMPANY:' + #id + ':READ')") | |
public Company getCompany(@PathVariable Long id) { | |
return companyRepo.getById(id); | |
} | |
@GetMapping(path = "/subsidiary/{id}") | |
@PostAuthorize("hasAuthority('COMPANY:' + returnObject.getCompany().getId() + ':READ')") | |
public Subsidiary getSubsidiary(@PathVariable Long id) { | |
return subsidiaryRepo.getById(id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment