use of wooteco.prolog.ability.application.dto.StudylogAbilityRequest in project prolog by woowacourse.
the class StudylogAbilityService method updateStudylogAbilities.
@Transactional
public List<AbilityResponse> updateStudylogAbilities(Long memberId, Long studylogId, StudylogAbilityRequest studylogAbilityRequest) {
Studylog studylog = studylogService.findStudylogById(studylogId);
studylog.validateBelongTo(memberId);
List<Ability> abilities = abilityService.findByIdIn(memberId, studylogAbilityRequest.getAbilities());
// 자식 역량이 있는데 부모 역량이 있는 경우 예외처리
abilities.stream().filter(it -> !it.isParent()).filter(it -> abilities.contains(it.getParent())).findFirst().ifPresent(it -> {
throw new IllegalArgumentException("자식 역량이 존재하는 경우 부모 역량을 선택할 수 없습니다.");
});
List<StudylogAbility> studylogAbilities = abilities.stream().map(it -> new StudylogAbility(memberId, it, studylog)).collect(Collectors.toList());
studylogAbilityRepository.deleteByStudylogId(studylogId);
List<StudylogAbility> persistStudylogAbilities = studylogAbilityRepository.saveAll(studylogAbilities);
return persistStudylogAbilities.stream().map(it -> AbilityResponse.of(it.getAbility())).collect(Collectors.toList());
}
use of wooteco.prolog.ability.application.dto.StudylogAbilityRequest in project prolog by woowacourse.
the class StudylogAbilityStepDefinitions method 역량에학습로그를맵핑하면.
@When("{string} 학습로그에 {string} 역량을 맵핑하(면)(고)")
public void 역량에학습로그를맵핑하면(String studylogName, String abilityName) {
HierarchyAbilityResponse ability = (HierarchyAbilityResponse) context.storage.get(abilityName);
StudylogResponse studylog = (StudylogResponse) context.storage.get(studylogName);
StudylogAbilityRequest requestBody = new StudylogAbilityRequest(Lists.newArrayList(ability.getId()));
context.invokeHttpPutWithToken("/studylogs/" + studylog.getId() + "/abilities", requestBody);
}
use of wooteco.prolog.ability.application.dto.StudylogAbilityRequest in project prolog by woowacourse.
the class StudylogAbilityStepDefinitions method 학습로그에역량을맵핑하면.
@When("{string} 학습로그에 {string}, {string} 역량을 맵핑하(면)(고)")
public void 학습로그에역량을맵핑하면(String studylogName, String abilityName1, String abilityName2) {
HierarchyAbilityResponse ability1 = (HierarchyAbilityResponse) context.storage.get(abilityName1);
HierarchyAbilityResponse ability2 = (HierarchyAbilityResponse) context.storage.get(abilityName2);
StudylogResponse studylog = (StudylogResponse) context.storage.get(studylogName);
StudylogAbilityRequest requestBody = new StudylogAbilityRequest(Lists.newArrayList(ability1.getId(), ability2.getId()));
context.invokeHttpPutWithToken("/studylogs/" + studylog.getId() + "/abilities", requestBody);
}
Aggregations