【发布时间】:2020-02-17 13:58:32
【问题描述】:
我正在开发一个使用 Spring Boot 作为框架的应用程序。我有两种方法,第一种是从数据库中删除数据,另一种是从磁盘中删除文件夹,所以如果我从数据库中删除并且我无法从磁盘中删除,那么所有操作都会失败。那么我怎么能用springboot做到这一点?
@Override
public ResponseEntity<?> delete(Long id) {
return libelleRepository.findById(id).map(libelle -> {
libelleRepository.delete(libelle);
return ResponseEntity.ok().build();
}).orElseThrow(() -> new GeneralResourceNotFoundException("Libelle not found with id " + id));
}
【问题讨论】:
标签: java spring-boot