Sécurité indépendante avec une classe abstract
Salut,
j'utilise spring boot 2 et spring security
Je dois modifier le design
Actuellement j'ai plusieurs controller rest qui hérite d'une classe qui a des méthodes généric getById, deleteById...
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| publi CarRestController extends AbstractController<Car, CarDto, CarSearch>{
private final CarServiceImpl carService;
...
}
public abstract class AbstractController<T, R , S > {
@GetMapping(value = "/{id}"
public ResponseEntity<R> getById(@PathVariable("id") Integer id) {
R r = baseService.getById(id);
....
}
...
}
public class CarServiceImpl extends AbstractService<Car, CarDto, CarSearch> {
}
public abstract class AbstractService<T, R , S > {
protected abstract R convertToDto(T t);
protected abstract void convertToBeans(R r, T t);
public R save(R r) {
...
}
} |
Ca fonctionne bien.
Le hic c'est que je ne peux actuellement spécifier pour chaque controller quel role est alloué d'appeler getById, deleteById...
Avez-vous des suggestions pour réutiliser le plus possible l'existant