From b00a9458a17a6e717fb56c96d7c0688eb1d5d912 Mon Sep 17 00:00:00 2001 From: Youngwoo Yoo <63579113+Yboyu0u@users.noreply.github.com> Date: Fri, 28 Oct 2022 21:40:18 +0900 Subject: [PATCH] =?UTF-8?q?Revert=20"refactor:=20=EC=9E=84=EC=8B=9C?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=20=EA=B8=B0=EB=8A=A5=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?(#1099)"=20(#1100)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit db4b93c10fb287237e2d2f3c51f7901116d5c121. --- .../prolog/docu/StudylogDocumentation.java | 36 +--- .../ability/domain/StudylogTempAbility.java | 43 ----- .../StudylogTempAbilityRepository.java | 12 -- .../studylog/application/StudylogService.java | 55 ++---- .../application/dto/StudylogTempResponse.java | 20 +- .../V31__create_studylogtempAbility_table.sql | 17 -- .../application/StudylogServiceTest.java | 182 ------------------ 7 files changed, 23 insertions(+), 342 deletions(-) delete mode 100644 backend/src/main/java/wooteco/prolog/ability/domain/StudylogTempAbility.java delete mode 100644 backend/src/main/java/wooteco/prolog/ability/domain/repository/StudylogTempAbilityRepository.java delete mode 100644 backend/src/main/resources/db/migration/prod/V31__create_studylogtempAbility_table.sql diff --git a/backend/src/documentation/java/wooteco/prolog/docu/StudylogDocumentation.java b/backend/src/documentation/java/wooteco/prolog/docu/StudylogDocumentation.java index 789d26af7..bdca9cc35 100644 --- a/backend/src/documentation/java/wooteco/prolog/docu/StudylogDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/docu/StudylogDocumentation.java @@ -12,6 +12,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import wooteco.prolog.Documentation; @@ -69,41 +70,6 @@ class StudylogDocumentation extends Documentation { .then().log().all().extract(); } - @Test - void 스터디로그_임시저장_한다() { - //given, when - ExtractableResponse createResponse = given("studylog/create/temp") - .header("Authorization", "Bearer " + 로그인_사용자.getAccessToken()) - .body(createStudylogRequest1()) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .when().put("/studylogs/temp") - .then().log().all().extract(); - - //then - assertThat(createResponse.statusCode()).isEqualTo(HttpStatus.CREATED.value()); - assertThat(createResponse.header("Location")).isNotNull(); - } - - @Test - void 임시저장_스터디로그_조회한다() { - //given - given("studylog/create/temp") - .header("Authorization", "Bearer " + 로그인_사용자.getAccessToken()) - .body(createStudylogRequest1()) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .when().put("/studylogs/temp") - .then().log().all().extract(); - //when - ExtractableResponse createResponse = given("studylog/create/temp") - .header("Authorization", "Bearer " + 로그인_사용자.getAccessToken()) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .when().get("/studylogs/temp") - .then().log().all().extract(); - - // then - assertThat(createResponse.statusCode()).isEqualTo(HttpStatus.OK.value()); - } - @Test void 스터디로그_목록을_조회한다() { // given diff --git a/backend/src/main/java/wooteco/prolog/ability/domain/StudylogTempAbility.java b/backend/src/main/java/wooteco/prolog/ability/domain/StudylogTempAbility.java deleted file mode 100644 index f42b23984..000000000 --- a/backend/src/main/java/wooteco/prolog/ability/domain/StudylogTempAbility.java +++ /dev/null @@ -1,43 +0,0 @@ -package wooteco.prolog.ability.domain; - -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.hibernate.annotations.OnDelete; -import org.hibernate.annotations.OnDeleteAction; -import wooteco.prolog.studylog.domain.StudylogTemp; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@Entity -public class StudylogTempAbility { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - private Long memberId; - - @ManyToOne(fetch = FetchType.EAGER) - @JoinColumn(name = "ability_id", nullable = false) - @OnDelete(action = OnDeleteAction.CASCADE) - private Ability ability; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "studylog_temp_id", nullable = false) - @OnDelete(action = OnDeleteAction.CASCADE) - private StudylogTemp studylogTemp; - - public StudylogTempAbility(Long memberId, Ability ability, StudylogTemp studylogTemp) { - this.memberId = memberId; - this.ability = ability; - this.studylogTemp = studylogTemp; - } -} diff --git a/backend/src/main/java/wooteco/prolog/ability/domain/repository/StudylogTempAbilityRepository.java b/backend/src/main/java/wooteco/prolog/ability/domain/repository/StudylogTempAbilityRepository.java deleted file mode 100644 index a3bc9ab8c..000000000 --- a/backend/src/main/java/wooteco/prolog/ability/domain/repository/StudylogTempAbilityRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package wooteco.prolog.ability.domain.repository; - -import java.util.List; -import org.springframework.data.jpa.repository.JpaRepository; -import wooteco.prolog.ability.domain.StudylogTempAbility; - -public interface StudylogTempAbilityRepository extends JpaRepository { - - void deleteByStudylogTempId(Long studylogTempId); - - List findByStudylogTempId(Long studylogTempId); -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogService.java b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogService.java index 614346e2e..9b679edda 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogService.java @@ -27,14 +27,11 @@ import wooteco.prolog.ability.application.dto.AbilityResponse; import wooteco.prolog.ability.domain.Ability; import wooteco.prolog.ability.domain.StudylogAbility; -import wooteco.prolog.ability.domain.StudylogTempAbility; import wooteco.prolog.ability.domain.repository.StudylogAbilityRepository; -import wooteco.prolog.ability.domain.repository.StudylogTempAbilityRepository; import wooteco.prolog.login.ui.LoginMember; import wooteco.prolog.member.application.MemberService; import wooteco.prolog.member.application.MemberTagService; import wooteco.prolog.member.domain.Member; -import wooteco.prolog.report.exception.AbilityHasChildrenException; import wooteco.prolog.session.application.MissionService; import wooteco.prolog.session.application.SessionService; import wooteco.prolog.session.domain.Mission; @@ -88,7 +85,6 @@ public class StudylogService { private final StudylogTempRepository studylogTempRepository; private final StudylogAbilityRepository studylogAbilityRepository; private final CommentRepository commentRepository; - private final StudylogTempAbilityRepository studylogTempAbilityRepository; private final ApplicationEventPublisher eventPublisher; @Transactional @@ -105,7 +101,12 @@ public List insertStudylogs(Long memberId, @Transactional public StudylogResponse insertStudylog(Long memberId, StudylogRequest studylogRequest) { - Set abilities = findAbility(memberId, studylogRequest); + Set abilities = abilityService.findByIdIn(memberId, + studylogRequest.getAbilities()); + + if (hasChildAndParentAbility(abilities)) { + throw new IllegalArgumentException("자식 역량이 존재하는 경우 부모 역량을 선택할 수 없습니다."); + } Member member = memberService.findById(memberId); Tags tags = tagService.findOrCreate(studylogRequest.getTags()); @@ -148,21 +149,6 @@ private boolean hasChildAndParentAbility(Set abilities) { @Transactional public StudylogTempResponse insertStudylogTemp(Long memberId, StudylogRequest studylogRequest) { - Set abilities = findAbility(memberId, studylogRequest); - StudylogTemp createdStudylogTemp = creteStudylogTemp(memberId, studylogRequest); - - List studylogTempAbilities = abilities.stream() - .map(it -> new StudylogTempAbility(memberId, it, createdStudylogTemp)) - .collect(Collectors.toList()); - - List createdStudylogAbilities = studylogTempAbilityRepository.saveAll( - studylogTempAbilities); - - List abilityResponses = getAbilityTempResponses(createdStudylogAbilities); - return StudylogTempResponse.from(createdStudylogTemp, abilityResponses); - } - - private StudylogTemp creteStudylogTemp(Long memberId, StudylogRequest studylogRequest) { Member member = memberService.findById(memberId); Tags tags = tagService.findOrCreate(studylogRequest.getTags()); Session session = sessionService.findSessionById(studylogRequest.getSessionId()) @@ -179,22 +165,7 @@ private StudylogTemp creteStudylogTemp(Long memberId, StudylogRequest studylogRe deleteStudylogTemp(memberId); StudylogTemp createdStudylogTemp = studylogTempRepository.save(requestedStudylogTemp); - return createdStudylogTemp; - } - - private List getAbilityTempResponses(List createdStudylogAbilities) { - return createdStudylogAbilities.stream() - .map(it -> AbilityResponse.of(it.getAbility())) - .collect(toList()); - } - - private Set findAbility(Long memberId, StudylogRequest studylogRequest) { - Set abilities = abilityService.findByIdIn(memberId, - studylogRequest.getAbilities()); - if (hasChildAndParentAbility(abilities)) { - throw new AbilityHasChildrenException(); - } - return abilities; + return StudylogTempResponse.from(createdStudylogTemp); } private void onStudylogCreatedEvent(Member foundMember, Tags tags, Studylog createdStudylog) { @@ -218,10 +189,7 @@ public StudylogsResponse findStudylogs(StudylogsSearchRequest request, Long memb public StudylogTempResponse findStudylogTemp(Long memberId) { if (studylogTempRepository.existsByMemberId(memberId)) { StudylogTemp studylogTemp = studylogTempRepository.findByMemberId(memberId); - List studylogTempAbilities = studylogTempAbilityRepository.findByStudylogTempId( - studylogTemp.getId()); - List abilitiesResponse = getAbilityTempResponses(studylogTempAbilities); - return StudylogTempResponse.from(studylogTemp, abilitiesResponse); + return StudylogTempResponse.from(studylogTemp); } return StudylogTempResponse.toNull(); } @@ -422,7 +390,12 @@ private void increaseViewCount(LoginMember loginMember, Studylog studylog) { @Transactional public void updateStudylog(Long memberId, Long studylogId, StudylogRequest studylogRequest) { - Set abilities = findAbility(memberId, studylogRequest); + Set abilities = abilityService.findByIdIn(memberId, + studylogRequest.getAbilities()); + + if (hasChildAndParentAbility(abilities)) { + throw new IllegalArgumentException("자식 역량이 존재하는 경우 부모 역량을 선택할 수 없습니다."); + } Studylog studylog = studylogRepository.findById(studylogId).orElseThrow(StudylogNotFoundException::new); studylog.validateBelongTo(memberId); diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogTempResponse.java b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogTempResponse.java index a10becc68..a1144c5dc 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogTempResponse.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogTempResponse.java @@ -1,17 +1,17 @@ package wooteco.prolog.studylog.application.dto; -import static java.util.stream.Collectors.toList; - -import java.util.List; import lombok.Getter; import lombok.NoArgsConstructor; -import wooteco.prolog.ability.application.dto.AbilityResponse; import wooteco.prolog.member.application.dto.MemberResponse; import wooteco.prolog.session.application.dto.MissionResponse; import wooteco.prolog.session.application.dto.SessionResponse; import wooteco.prolog.studylog.domain.StudylogTemp; import wooteco.prolog.studylog.domain.StudylogTempTags; +import java.util.List; + +import static java.util.stream.Collectors.toList; + @NoArgsConstructor @Getter public class StudylogTempResponse { @@ -23,28 +23,24 @@ public class StudylogTempResponse { private SessionResponse session; private MissionResponse mission; private List tags; - private List abilities; - private StudylogTempResponse(MemberResponse author, String title, String content, SessionResponse session, - MissionResponse mission, List tags, List abilities) { + private StudylogTempResponse(MemberResponse author, String title, String content, SessionResponse session, MissionResponse mission, List tags) { this.author = author; this.title = title; this.content = content; this.session = session; this.mission = mission; this.tags = tags; - this.abilities = abilities; } - public static StudylogTempResponse from(StudylogTemp studylogTemp, List abilityResponse) { + public static StudylogTempResponse from(StudylogTemp studylogTemp) { return new StudylogTempResponse( MemberResponse.of(studylogTemp.getMember()), studylogTemp.getTitle(), studylogTemp.getContent(), SessionResponse.of(studylogTemp.getSession()), MissionResponse.of(studylogTemp.getMission()), - toTagResponses(studylogTemp.getStudylogTempTags()), - abilityResponse); + toTagResponses(studylogTemp.getStudylogTempTags())); } //todo TagResponse의 정적팩토리메서드로 리팩터링 @@ -55,6 +51,6 @@ private static List toTagResponses(StudylogTempTags tags) { } public static StudylogTempResponse toNull() { - return new StudylogTempResponse(null, null, null, null, null, null, null); + return new StudylogTempResponse(null, null, null, null, null, null); } } diff --git a/backend/src/main/resources/db/migration/prod/V31__create_studylogtempAbility_table.sql b/backend/src/main/resources/db/migration/prod/V31__create_studylogtempAbility_table.sql deleted file mode 100644 index 5c7f57378..000000000 --- a/backend/src/main/resources/db/migration/prod/V31__create_studylogtempAbility_table.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE studylog_temp_ability( - id BIGINT NOT NULL AUTO_INCREMENT, - member_id BIGINT NOT NULL, - ability_id BIGINT NOT NULL, - studylog_temp_id BIGINT NOT NULL, - PRIMARY KEY (id) -) ENGINE=InnoDB; - -alter table studylog_temp_ability - add constraint FK_STUDYLOG_TEMP_ABILITY_ABILITY - foreign key (ability_id) - references ability (id) on delete cascade; - -alter table studylog_temp_ability - add constraint FK_STUDYLOG_TEMP_ABILITY_STUDYLOG_TEMP - foreign key (studylog_temp_id) - references studylog_temp (id) on delete cascade; diff --git a/backend/src/test/java/wooteco/prolog/studylog/studylog/application/StudylogServiceTest.java b/backend/src/test/java/wooteco/prolog/studylog/studylog/application/StudylogServiceTest.java index 33df5a326..746628b45 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/studylog/application/StudylogServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/studylog/application/StudylogServiceTest.java @@ -31,8 +31,6 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.transaction.annotation.Transactional; -import wooteco.prolog.ability.application.AbilityService; -import wooteco.prolog.ability.application.dto.AbilityCreateRequest; import wooteco.prolog.login.application.dto.GithubProfileResponse; import wooteco.prolog.login.ui.LoginMember; import wooteco.prolog.login.ui.LoginMember.Authority; @@ -49,7 +47,6 @@ import wooteco.prolog.session.domain.repository.MissionRepository; import wooteco.prolog.session.domain.repository.SessionRepository; import wooteco.prolog.studylog.application.CommentService; -import wooteco.prolog.session.domain.repository.MissionRepository; import wooteco.prolog.studylog.application.DocumentService; import wooteco.prolog.studylog.application.StudylogScrapService; import wooteco.prolog.studylog.application.StudylogService; @@ -59,7 +56,6 @@ import wooteco.prolog.studylog.application.dto.StudylogRequest; import wooteco.prolog.studylog.application.dto.StudylogResponse; import wooteco.prolog.studylog.application.dto.StudylogRssFeedResponse; -import wooteco.prolog.studylog.application.dto.StudylogTempResponse; import wooteco.prolog.studylog.application.dto.StudylogsResponse; import wooteco.prolog.studylog.application.dto.TagRequest; import wooteco.prolog.studylog.application.dto.TagResponse; @@ -84,14 +80,6 @@ class StudylogServiceTest { private static final String CONTENT3 = "피케이 스터디로그"; private static final String CONTENT4 = "포모의 스터디로그"; - private static Tag tag1 = new Tag(1L, "소롱의글쓰기"); - private static Tag tag2 = new Tag(2L, "스프링"); - private static Tag tag3 = new Tag(3L, "감자튀기기"); - private static Tag tag4 = new Tag(4L, "집필왕웨지"); - private static Tag tag5 = new Tag(5L, "피케이"); - private static List tags = asList( - tag1, tag2, tag3, tag4, tag5 - ); private static final String TAG1 = "소롱의글쓰리"; private static final String TAG2 = "스프링"; private static final String TAG3 = "감자튀기기"; @@ -106,24 +94,6 @@ class StudylogServiceTest { private static final String URL = "http://localhost:8080"; - private Member member1; - private Member member2; - - private LoginMember loginMember1; - private LoginMember loginMember2; - private LoginMember loginMember3; - - private Session session1; - private Session session2; - - private Mission mission1; - private Mission mission2; - - private Studylog studylog1; - private Studylog studylog2; - private Studylog studylog3; - private Studylog studylog4; - @Autowired private StudylogService studylogService; @@ -141,8 +111,6 @@ class StudylogServiceTest { @Autowired private DocumentService studylogDocumentService; - @Autowired - private AbilityService abilityService; @Autowired private MissionRepository missionRepository; @@ -156,41 +124,6 @@ class StudylogServiceTest { @Autowired private CommentService commentService; - @BeforeEach - void setUp() { - SessionResponse sessionResponse1 = sessionService.create(new SessionRequest("세션1")); - SessionResponse sessionResponse2 = sessionService.create(new SessionRequest("세션2")); - - this.session1 = new Session(sessionResponse1.getId(), sessionResponse1.getName()); - this.session2 = new Session(sessionResponse2.getId(), sessionResponse2.getName()); - - MissionResponse missionResponse1 = missionService - .create(new MissionRequest("자동차 미션", session1.getId())); - MissionResponse missionResponse2 = missionService - .create(new MissionRequest("수동차 미션", session2.getId())); - - this.mission1 = new Mission(missionResponse1.getId(), missionResponse1.getName(), session1); - this.mission2 = new Mission(missionResponse2.getId(), missionResponse2.getName(), session1); - - this.member1 = memberService.findOrCreateMember(new GithubProfileResponse("이름1", "별명1", "1", "image")); - this.member2 = memberService.findOrCreateMember(new GithubProfileResponse("이름2", "별명2", "2", "image")); - - this.loginMember1 = new LoginMember(member1.getId(), Authority.MEMBER); - this.loginMember2 = new LoginMember(member2.getId(), Authority.MEMBER); - this.loginMember3 = new LoginMember(null, Authority.ANONYMOUS); - - this.studylog1 = new Studylog(member1, - TITLE1, "피케이와 포모의 스터디로그", session1, mission1, - asList(tag1, tag2)); - this.studylog2 = new Studylog(member1, - TITLE2, "피케이와 포모의 스터디로그 2", session1, mission1, - asList(tag2, tag3)); - this.studylog3 = new Studylog(member2, - TITLE3, "피케이 스터디로그", session1, mission2, - asList(tag3, tag4, tag5)); - this.studylog4 = new Studylog(member2, TITLE4, "포모의 스터디로그", session1, mission2, emptyList()); - } - @DisplayName("스터디로그를 삽입한다. - 삽입 시 studylogDocument도 삽입된다.") @Test void insert() { @@ -560,80 +493,6 @@ void readRssFeeds() { .containsExactlyInAnyOrderElementsOf(expectedLinkUrl); } - @DisplayName("임시저장된 스터디로그를 조회한다.") - @Test - void findStudylogTemp() { - //given - Mission mission = missionRepository.save(mission1); - String title = "임시저장 제목"; - String content = "임시저장 내용"; - StudylogRequest studylogRequest = new StudylogRequest(title, content, - mission.getId(), - toTagRequests(tags)); - studylogService.insertStudylogTemp(member1.getId(), - studylogRequest); - - //when - final StudylogTempResponse studylogTempResponse = studylogService.findStudylogTemp(member1.getId()); - - //then - assertThat(studylogTempResponse.getTitle()).isEqualTo(title); - assertThat(studylogTempResponse.getContent()).isEqualTo(content); - assertThat(studylogTempResponse.getAbilities()).isEmpty(); - } - - @DisplayName("스터디로그를 임시저장하고 다시 수정후, 다시 임시 저장한다.") - @Test - void insertstudylogTemp_oneMore() { - //given - Mission mission = missionRepository.save(mission1); - String title = "임시저장 제목"; - String content = "임시저장 내용"; - List abilityIds = 역량을_저장한다(); - StudylogRequest studylogRequest = new StudylogRequest(title, content, session1.getId(), - mission.getId(), toTagRequests(tags), abilityIds); - studylogService.insertStudylogTemp(member1.getId(), studylogRequest); - - //when - String newTitle = "새로운 임시저장 제목"; - String newContent = "새로운 임시저장 내용"; - StudylogRequest newStudylogRequest = new StudylogRequest(newTitle, newContent, session1.getId(), - mission.getId(), toTagRequests(tags), abilityIds); - StudylogTempResponse studylogTempResponse = - studylogService.insertStudylogTemp(member1.getId(), newStudylogRequest); - - //then - assertThat(studylogTempResponse.getTitle()).isEqualTo(newTitle); - assertThat(studylogTempResponse.getContent()).isEqualTo(newContent); - assertThat(studylogTempResponse.getAbilities()).isNotEmpty(); - } - - @DisplayName("스터디로그를 임시저장하고 제출한다.") - @Test - void insertstudylogTemp_andSubmit() { - //given - Mission mission = missionRepository.save(mission1); - String title = "임시저장 제목"; - String content = "임시저장 내용"; - List abilityIds = 역량을_저장한다(); - StudylogRequest studylogRequest = new StudylogRequest(title, content, session1.getId(), - mission.getId(), toTagRequests(tags), abilityIds); - studylogService.insertStudylogTemp(member1.getId(), studylogRequest); - - //when - String newTitle = "최종 제출할 제목"; - String newContent = "최종 제출할 내용"; - StudylogRequest newStudylogRequest = new StudylogRequest(newTitle, newContent, session1.getId(), - mission.getId(), toTagRequests(tags), abilityIds); - StudylogResponse studylogResponse = - studylogService.insertStudylog(member1.getId(), newStudylogRequest); - - //then - assertThat(studylogResponse.getTitle()).isEqualTo(newTitle); - assertThat(studylogResponse.getContent()).isEqualTo(newContent); - assertThat(studylogResponse.getAbilities()).isNotEmpty(); - } - @DisplayName("학습로그 목록조회 시 댓글 갯수도 같이 조회한다.") @ParameterizedTest @MethodSource("provideFilterForGetCommentCount") @@ -752,45 +611,4 @@ private MissionResponse createMission(String sessionName, String missionName) { SessionResponse session = sessionService.create(new SessionRequest(sessionName)); return missionService.create(new MissionRequest(missionName, session.getId())); } - - public List insertStudylogs(Member member, Studylog... studylogs) { - return insertStudylogs(member, asList(studylogs)); - } - - private List insertStudylogs(Member member, List studylogs) { - List studylogRequests = studylogs.stream() - .map(studylog -> - new StudylogRequest( - studylog.getTitle(), - studylog.getContent(), - studylog.getSession().getId(), - studylog.getMission().getId(), - toTagRequests(studylog), - Collections.emptyList() - ) - ) - .collect(toList()); - - return studylogService.insertStudylogs(member.getId(), studylogRequests); - } - - private List toTagRequests(List tags) { - return tags.stream() - .map(tag -> new TagRequest(tag.getName())) - .collect(toList()); - } - - private List toTagRequests(Studylog studylog) { - return studylog.getStudylogTags().stream() - .map(studylogTag -> new TagRequest(studylogTag.getTag().getName())) - .collect(toList()); - } - - private List 역량을_저장한다() { - AbilityCreateRequest parentRequest1 = new AbilityCreateRequest("부모1", "부모설명1", "1", null); - AbilityCreateRequest parentRequest2 = new AbilityCreateRequest("부모2", "부모설명2", "2", null); - Long abilityId1 = abilityService.createAbility(member1.getId(), parentRequest1).getId(); - Long abilityId2 = abilityService.createAbility(member1.getId(), parentRequest2).getId(); - return asList(abilityId1, abilityId2); - } }