добавлен метод копирования бара

This commit is contained in:
Kayashov.SM
2025-12-27 15:15:31 +04:00
parent da188a65a4
commit 0cb15aae70

View File

@@ -92,6 +92,19 @@ public class BarService {
return BarResponseDto.mapToDto(bar); 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) { private List<CocktailEntity> findAllowedCocktails(List<IngredientEntity> ingredients) {
List<CocktailEntity> result = new ArrayList<>(); List<CocktailEntity> result = new ArrayList<>();
for (IngredientEntity ingredient : ingredients) { for (IngredientEntity ingredient : ingredients) {