Search in sources :

Example 1 with DefaultAbility

use of wooteco.prolog.report.domain.ablity.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);
}
Also used : DefaultAbility(wooteco.prolog.report.domain.ablity.DefaultAbility) Test(org.junit.jupiter.api.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with DefaultAbility

use of wooteco.prolog.report.domain.ablity.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();
}
Also used : DefaultAbility(wooteco.prolog.report.domain.ablity.DefaultAbility) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with DefaultAbility

use of wooteco.prolog.report.domain.ablity.DefaultAbility in project prolog by woowacourse.

the class AbilityService method addDefaultAbilities.

@Transactional
public void addDefaultAbilities(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);
        }
    }
}
Also used : DefaultAbility(wooteco.prolog.report.domain.ablity.DefaultAbility) Ability(wooteco.prolog.report.domain.ablity.Ability) DefaultAbility(wooteco.prolog.report.domain.ablity.DefaultAbility) HashMap(java.util.HashMap) Member(wooteco.prolog.member.domain.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

DefaultAbility (wooteco.prolog.report.domain.ablity.DefaultAbility)3 Transactional (org.springframework.transaction.annotation.Transactional)2 HashMap (java.util.HashMap)1 DisplayName (org.junit.jupiter.api.DisplayName)1 Test (org.junit.jupiter.api.Test)1 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)1 Member (wooteco.prolog.member.domain.Member)1 Ability (wooteco.prolog.report.domain.ablity.Ability)1