Skip to content

Instantly share code, notes, and snippets.

@baso53
Created November 14, 2021 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baso53/35ecb750077c19a50617e829d9497f46 to your computer and use it in GitHub Desktop.
Save baso53/35ecb750077c19a50617e829d9497f46 to your computer and use it in GitHub Desktop.
@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