use of wooteco.prolog.ability.domain.Ability in project prolog by woowacourse.
the class AbilityService method deleteAbility.
@Transactional
public void deleteAbility(Long memberId, Long abilityId) {
Ability ability = findAbilityByIdAndMemberId(abilityId, memberId);
if (ability.isParent() && !ability.getChildren().isEmpty()) {
throw new AbilityHasChildrenException();
}
abilityRepository.delete(ability);
}
use of wooteco.prolog.ability.domain.Ability in project prolog by woowacourse.
the class AbilityService method findParentAbilitiesByUsername.
public List<HierarchyAbilityResponse> findParentAbilitiesByUsername(String username) {
Member member = memberService.findByUsername(username);
List<Ability> parentAbilities = abilityRepository.findByMemberIdAndParentIsNull(member.getId());
return HierarchyAbilityResponse.listOf(parentAbilities);
}
use of wooteco.prolog.ability.domain.Ability in project prolog by woowacourse.
the class AbilityService method applyDefaultAbilities.
@Transactional
public void applyDefaultAbilities(Long memberId, String template) {
Member member = memberService.findById(memberId);
List<DefaultAbility> defaultAbilities = findDefaultAbilitiesByTemplate(template);
Map<DefaultAbility, Ability> parentAbilities = new HashMap<>();
for (DefaultAbility defaultAbility : defaultAbilities) {
if (defaultAbility.isParent()) {
Ability parentAbility = mapToParentAbility(member, defaultAbility);
parentAbilities.put(defaultAbility, parentAbility);
} else {
Ability parentAbility = parentAbilities.get(defaultAbility.getParent());
mapToChildAbility(member, defaultAbility, parentAbility);
}
}
}
use of wooteco.prolog.ability.domain.Ability in project prolog by woowacourse.
the class AbilityService method findFlatAbilitiesByMember.
public List<AbilityResponse> findFlatAbilitiesByMember(String username) {
Member member = memberService.findByUsername(username);
List<Ability> abilities = abilityRepository.findByMemberId(member.getId());
return AbilityResponse.listOf(abilities);
}
use of wooteco.prolog.ability.domain.Ability in project prolog by woowacourse.
the class AbilityService method extractParentAbility.
private Ability extractParentAbility(Member member, List<Ability> abilities, String name, String description, String color) {
Ability parentAbility = Ability.parent(name, description, color, member);
parentAbility.validateDuplicateName(abilities);
parentAbility.validateDuplicateColor(abilities);
return parentAbility;
}
Aggregations