feature/army-specific-points #3
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user