feature/army-specific-points #3

Merged
mitch merged 2 commits from feature/army-specific-points into master 2021-08-11 11:31:29 +00:00
Showing only changes of commit 04235ad967 - Show all commits

View File

@ -1,24 +1,20 @@
package com.warhammer.service.impl;
import com.warhammer.domain.UnitArmy;
import com.warhammer.service.ArmyService;
import com.warhammer.domain.Army;
import com.warhammer.domain.UnitArmy;
import com.warhammer.repository.ArmyRepository;
import com.warhammer.service.ArmyService;
import com.warhammer.service.dto.ArmyDTO;
import com.warhammer.service.mapper.ArmyMapper;
import liquibase.pro.packaged.S;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* Service Implementation for managing {@link Army}.
@ -86,6 +82,12 @@ public class ArmyServiceImpl implements ArmyService {
@Override
public void delete(Long id) {
log.debug("Request to delete Army : {}", id);
List<UnitArmy> units = this.findUnits(id);
if (!units.isEmpty()) {
units.forEach(unit ->
unitArmyService.delete(unit.getId())
);
}
armyRepository.deleteById(id);
}
}