use of wooteco.prolog.ability.domain.DefaultAbility in project prolog by woowacourse.
the class AbilityService method createDefaultAbility.
@Transactional
public Long createDefaultAbility(DefaultAbilityCreateRequest request) {
if (request.hasParent()) {
DefaultAbility parentDefaultAbility = findDefaultAbilityById(request.getParentId());
DefaultAbility childDefaultAbility = createChildDefaultAbility(request, parentDefaultAbility);
return childDefaultAbility.getId();
}
DefaultAbility defaultAbility = createParentDefaultAbility(request);
return defaultAbility.getId();
}
use of wooteco.prolog.ability.domain.DefaultAbility in project prolog by woowacourse.
the class AbilityServiceTest method createTemplateAbilities.
@DisplayName("멤버ID와 과정 선택을 통해 기본 역량을 등록한다.")
@Test
void createTemplateAbilities() {
// given
defaultAbilityRepository.save(new DefaultAbility("프로그래밍", "프로그래밍 입니다.", "#111111", "be"));
assertThat(abilityService.findAbilitiesByMemberId(member.getId())).isEmpty();
// when
abilityService.applyDefaultAbilities(member.getId(), "be");
// then
assertThat(abilityService.findAbilitiesByMemberId(member.getId())).isNotEmpty();
}
use of wooteco.prolog.ability.domain.DefaultAbility in project prolog by woowacourse.
the class DefaultAbilityRepositoryTest method findByTemplateOrTemplate.
@DisplayName("Template 타입이 common 또는 be인 역량 목록을 조회한다.")
@Test
void findByTemplateOrTemplate() {
// given
DefaultAbility defaultAbility = defaultAbilityRepository.save(new DefaultAbility("프로그래밍", "프로그래밍 역량", "#111111", "be", null));
// when
List<DefaultAbility> defaultAbilities = defaultAbilityRepository.findByTemplateOrTemplate("common", "be");
// then
assertThat(defaultAbilities).containsExactly(defaultAbility);
}
use of wooteco.prolog.ability.domain.DefaultAbility 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);
}
}
}
Aggregations