добавлен метод копирования бара
This commit is contained in:
@@ -92,6 +92,19 @@ public class BarService {
|
||||
return BarResponseDto.mapToDto(bar);
|
||||
}
|
||||
|
||||
public BarResponseDto copyBar(Long id, String name) {
|
||||
BarEntity barEntity = barEntityRepository.findById(id).orElseThrow();
|
||||
Long oldId = barEntity.getId();
|
||||
String oldName = barEntity.getName();
|
||||
barEntity.setName(name);
|
||||
barEntity.setActive(false);
|
||||
barEntity.setId(null);
|
||||
BarEntity newBar = barEntityRepository.save(barEntity);
|
||||
log.info("Бар {} - {} скопирован как {} - {}", oldId, oldName, newBar.getId(), name);
|
||||
|
||||
return BarResponseDto.mapToDto(newBar);
|
||||
}
|
||||
|
||||
private List<CocktailEntity> findAllowedCocktails(List<IngredientEntity> ingredients) {
|
||||
List<CocktailEntity> result = new ArrayList<>();
|
||||
for (IngredientEntity ingredient : ingredients) {
|
||||
|
||||
Reference in New Issue
Block a user