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) {
...
}
} |
Partager