diff --git a/backend/src/main/java/wooteco/prolog/article/application/ArticleService.java b/backend/src/main/java/wooteco/prolog/article/application/ArticleService.java index 4dd8f2945..82ea51cff 100644 --- a/backend/src/main/java/wooteco/prolog/article/application/ArticleService.java +++ b/backend/src/main/java/wooteco/prolog/article/application/ArticleService.java @@ -86,13 +86,13 @@ public List getFilteredArticles(final LoginMember member, final ArticleFilterType course, final boolean onlyBookmarked) { if (member.isMember()) { - return articleRepository.findArticlesByCourseAndMember(course.getGroupName(), + return articleRepository.findArticlesByCourseAndMember(course.getPartName(), member.getId(), onlyBookmarked).stream() .map(article -> ArticleResponse.of(article, member.getId())) .collect(toList()); } - return articleRepository.findArticlesByCourse(course.getGroupName()).stream() + return articleRepository.findArticlesByCourse(course.getPartName()).stream() .map(article -> ArticleResponse.of(article, member.getId())) .collect(toList()); } diff --git a/backend/src/main/java/wooteco/prolog/article/domain/ArticleFilterType.java b/backend/src/main/java/wooteco/prolog/article/domain/ArticleFilterType.java index 8eddb65f6..94913a001 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/ArticleFilterType.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/ArticleFilterType.java @@ -9,9 +9,9 @@ public enum ArticleFilterType { BACKEND("백엔드"), FRONTEND("프론트엔드"); - private final String groupName; + private final String partName; - ArticleFilterType(String groupName) { - this.groupName = groupName; + ArticleFilterType(String partName) { + this.partName = partName; } } diff --git a/backend/src/main/java/wooteco/prolog/article/domain/repository/ArticleRepository.java b/backend/src/main/java/wooteco/prolog/article/domain/repository/ArticleRepository.java index 2e02f23ea..69360be64 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/repository/ArticleRepository.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/repository/ArticleRepository.java @@ -18,18 +18,18 @@ public interface ArticleRepository extends JpaRepository { Optional
findFetchLikeById(@Param("id") final Long id); @Query("SELECT DISTINCT a FROM Article a " + - "JOIN GroupMember gm ON a.member.id = gm.member.id " + - "JOIN gm.group mg " + - "WHERE mg.name LIKE %:course " + + "JOIN DepartmentMember dm ON dm.member.id = dm.member.id " + + "JOIN dm.department d " + + "WHERE d.part = :course " + "ORDER by a.createdAt desc") List
findArticlesByCourse(@Param("course") String course); @Query("SELECT DISTINCT a FROM Article a " + - "JOIN GroupMember gm ON a.member.id = gm.member.id " + - "JOIN gm.group mg " + + "JOIN DepartmentMember dm ON a.member.id = dm.member.id " + + "JOIN dm.department d " + "LEFT JOIN a.articleBookmarks.articleBookmarks ab " + "LEFT JOIN a.articleLikes.articleLikes al " + - "WHERE mg.name LIKE %:course AND (:onlyBookmarked = false OR (:onlyBookmarked = true and ab.memberId = :memberId))" + + "WHERE d.part = :course AND (:onlyBookmarked = false OR (:onlyBookmarked = true and ab.memberId = :memberId))" + "ORDER by a.createdAt desc") List
findArticlesByCourseAndMember(@Param("course") String course, @Param("memberId") Long memberId, diff --git a/backend/src/main/java/wooteco/prolog/member/application/GroupMemberService.java b/backend/src/main/java/wooteco/prolog/member/application/DepartmentMemberService.java similarity index 70% rename from backend/src/main/java/wooteco/prolog/member/application/GroupMemberService.java rename to backend/src/main/java/wooteco/prolog/member/application/DepartmentMemberService.java index f673c03f5..80fd7d323 100644 --- a/backend/src/main/java/wooteco/prolog/member/application/GroupMemberService.java +++ b/backend/src/main/java/wooteco/prolog/member/application/DepartmentMemberService.java @@ -10,12 +10,12 @@ @Service @AllArgsConstructor @Transactional(readOnly = true) -public class GroupMemberService { +public class DepartmentMemberService { private DepartmentMemberRepository departmentMemberRepository; - public List findGroupMemberByGroupId(Long groupId) { - return departmentMemberRepository.findByDepartmentId(groupId); + public List findDepartmentMemberByDepartmentId(Long departmentId) { + return departmentMemberRepository.findByDepartmentId(departmentId); } } diff --git a/backend/src/main/java/wooteco/prolog/session/application/SessionMemberService.java b/backend/src/main/java/wooteco/prolog/session/application/SessionMemberService.java index b7635b1b3..9bf2df56c 100644 --- a/backend/src/main/java/wooteco/prolog/session/application/SessionMemberService.java +++ b/backend/src/main/java/wooteco/prolog/session/application/SessionMemberService.java @@ -8,7 +8,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import wooteco.prolog.common.exception.BadRequestException; -import wooteco.prolog.member.application.GroupMemberService; +import wooteco.prolog.member.application.DepartmentMemberService; import wooteco.prolog.member.application.MemberService; import wooteco.prolog.member.application.dto.MemberResponse; import wooteco.prolog.member.domain.Member; @@ -25,7 +25,7 @@ public class SessionMemberService { private SessionMemberRepository sessionMemberRepository; private SessionRepository sessionRepository; private MemberService memberService; - private GroupMemberService groupMemberService; + private DepartmentMemberService departmentMemberService; @Transactional public void registerMember(Long sessionId, Long memberId) { @@ -42,7 +42,7 @@ public void registerMembersByGroupId(Long sessionId, List alreadySessionMembers = sessionMemberRepository.findAllBySessionId( sessionId); - List members = groupMemberService.findGroupMemberByGroupId( + List members = departmentMemberService.findDepartmentMemberByDepartmentId( sessionGroupMemberRequest.getGroupId()).stream() .map(it -> it.getMember()) .collect(toList()); diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/PopularStudylogService.java b/backend/src/main/java/wooteco/prolog/studylog/application/PopularStudylogService.java index 5b93813ce..00dca4fcd 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/PopularStudylogService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/PopularStudylogService.java @@ -52,9 +52,9 @@ public void updatePopularStudylogs(Pageable pageable) { List popularStudylogs = new ArrayList<>(); - for (Part groupType : Part.values()) { + for (Part partType : Part.values()) { popularStudylogs.addAll(filterStudylogsByDepartmets(recentStudylogs, - new Departments(DepartmetsBygroupType.get(groupType)), departmentMembers).stream() + new Departments(DepartmetsBygroupType.get(partType)), departmentMembers).stream() .sorted(Comparator.comparing(Studylog::getPopularScore).reversed()) .limit(pageable.getPageSize()).collect(toList())); } diff --git a/backend/src/test/java/wooteco/prolog/member/application/DepartmentMemberServiceTest.java b/backend/src/test/java/wooteco/prolog/member/application/DepartmentMemberServiceTest.java index db9376bea..4ce3c391a 100644 --- a/backend/src/test/java/wooteco/prolog/member/application/DepartmentMemberServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/member/application/DepartmentMemberServiceTest.java @@ -25,25 +25,25 @@ class DepartmentMemberServiceTest { private DepartmentMemberRepository departmentMemberRepository; @InjectMocks - private GroupMemberService groupMemberService; + private DepartmentMemberService departmentMemberService; @DisplayName("GroupId로 GroupMember를 찾는다.") @Test - void findGroupMemberByGroupId() { + void findDepartmentMemberByDepartmentId() { //given final Long memberId = 1L; - final Long DepartmetId = 2L; + final Long DepartmentId = 2L; final Long groupMemberId = 3L; final Member member = new Member(memberId, "송세연", "아마란스", Role.CREW, 1523L, "image"); - final Department department = new Department(DepartmetId, "백엔드", "2023 백엔드"); + final Department department = new Department(DepartmentId, "백엔드", "2023 백엔드"); final DepartmentMember departmentMember = new DepartmentMember(groupMemberId, member, department); when(departmentMemberRepository.findByDepartmentId(any())).thenReturn(ImmutableList.of(departmentMember)); //when - final List departmentMembers = groupMemberService.findGroupMemberByGroupId( - DepartmetId); + final List departmentMembers = departmentMemberService.findDepartmentMemberByDepartmentId( + DepartmentId); //then assertThat(departmentMembers).containsExactly(departmentMember); diff --git a/backend/src/test/java/wooteco/prolog/member/domain/DepartmentTest.java b/backend/src/test/java/wooteco/prolog/member/domain/DepartmentTest.java index e3b6dc443..1a69c9eed 100644 --- a/backend/src/test/java/wooteco/prolog/member/domain/DepartmentTest.java +++ b/backend/src/test/java/wooteco/prolog/member/domain/DepartmentTest.java @@ -9,19 +9,19 @@ class DepartmentTest { - private static final Department ANDROID_GROUP = new Department(null, "안드로이드", "5기"); - private static final Department BACKEND_GROUP = new Department(null, "백엔드", "5기"); - private static final Department FRONTEND_GROUP = new Department(null, "프론트엔드", "4기"); + private static final Department ANDROID_DEPARTMENT = new Department(null, "안드로이드", "5기"); + private static final Department BACKEND_DEPARTMENT = new Department(null, "백엔드", "5기"); + private static final Department FRONTEND_DEPARTMENT = new Department(null, "프론트엔드", "4기"); @Test - void getGroupType_이름이_그룹명을_포함하면_그룹을_반환한다() { - assertThat(ANDROID_GROUP.getPart()).isEqualTo(ANDROID); - assertThat(BACKEND_GROUP.getPart()).isEqualTo(BACKEND); - assertThat(FRONTEND_GROUP.getPart()).isEqualTo(FRONTEND); + void getPartType_이름이_그룹명을_포함하면_그룹을_반환한다() { + assertThat(ANDROID_DEPARTMENT.getPart()).isEqualTo(ANDROID); + assertThat(BACKEND_DEPARTMENT.getPart()).isEqualTo(BACKEND); + assertThat(FRONTEND_DEPARTMENT.getPart()).isEqualTo(FRONTEND); } @Test - void getGroupType_이름이_포함하는_그룹명이_없으면_예외가_발생한다() { + void getPartType_이름이_포함하는_그룹명이_없으면_예외가_발생한다() { Department department = new Department(null, "테스트", "test"); assertThatThrownBy(department::getPart) diff --git a/backend/src/test/java/wooteco/prolog/session/application/SessionMemberServiceTest.java b/backend/src/test/java/wooteco/prolog/session/application/SessionMemberServiceTest.java index 50ee17c60..5327feb44 100644 --- a/backend/src/test/java/wooteco/prolog/session/application/SessionMemberServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/session/application/SessionMemberServiceTest.java @@ -20,7 +20,7 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import wooteco.prolog.common.exception.BadRequestException; -import wooteco.prolog.member.application.GroupMemberService; +import wooteco.prolog.member.application.DepartmentMemberService; import wooteco.prolog.member.application.MemberService; import wooteco.prolog.member.application.dto.MemberResponse; import wooteco.prolog.member.domain.Member; @@ -45,7 +45,7 @@ class SessionMemberServiceTest { private MemberService memberService; @Mock - private GroupMemberService groupMemberService; + private DepartmentMemberService departmentMemberService; @DisplayName("Member가 회원가입을 할 수 있어야 한다.") @Test @@ -89,7 +89,7 @@ void registerMembersByGroupId() { // then verify(sessionMemberRepository, atMostOnce()).findAllBySessionId(1L); - verify(groupMemberService, atMostOnce()).findGroupMemberByGroupId(request.getGroupId()); + verify(departmentMemberService, atMostOnce()).findDepartmentMemberByDepartmentId(request.getGroupId()); verify(sessionMemberRepository, atMostOnce()).saveAll(null); } diff --git a/backend/src/test/java/wooteco/prolog/studylog/application/PopularStudylogServiceTest.java b/backend/src/test/java/wooteco/prolog/studylog/application/PopularStudylogServiceTest.java index 3c9501037..86e338c64 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/PopularStudylogServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/PopularStudylogServiceTest.java @@ -288,7 +288,7 @@ void findPopularStudylogs_IsAnonymousMemberFalse() { @DisplayName("인기학습 로그를 분야별로 나누어서 반한한다.") @Test - void findPopularStudylogs_filterGroupType() { + void findPopularStudylogs_filterDepartmentType() { { //given final Department frontend = setUpDepartment("프론트엔드", "5기");