Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

로드맵 서비스 가독성 개선 #1617

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a2e4000
Merge pull request #1587 from woowacourse/roadmap-develop
java-saeng Oct 11, 2023
aa035e7
Merge pull request #1595 from woowacourse/feature/1594-guest-fix
WaiNaat Oct 11, 2023
5a1297d
Merge pull request #1597 from woowacourse/article-develop
hong-sile Oct 11, 2023
4c6a678
Merge pull request #1599 from woowacourse/hotfix-guest-profile
Creative-Lee Oct 11, 2023
719bf40
Merge pull request #1601 from woowacourse/hotfix-guest-profile
Creative-Lee Oct 11, 2023
8a8ce14
refactor: MemberGroup을 Department로 변경
wonyongChoi05 Oct 6, 2023
2af8caa
Merge branch 'develop' of https://github.com/woowacourse/prolog into …
wonyongChoi05 Oct 13, 2023
f7ecf9e
feat: flyway migration script
wonyongChoi05 Oct 13, 2023
1200cf7
fix: jpql 수정
wonyongChoi05 Oct 13, 2023
6e559f3
refactor: 깨지는 테스트 수정
mcodnjs Oct 16, 2023
6f1b776
Merge pull request #1604 from woowacourse/fix/1603-roadmap-quiz-progr…
WaiNaat Oct 16, 2023
d0ec8fc
Merge pull request #1605 from woowacourse/refactor/#1559
wonyongChoi05 Oct 18, 2023
dc4fae9
feat: 유저 ID로 답변 개수 조회 기능 구현
nuyh99 Nov 1, 2023
11e87dc
test: 유저 ID로 답변 개수 조회 기능 테스트
nuyh99 Nov 1, 2023
bc41ccb
test: 커리큘럼의 모든 키워드 조회 테스트
nuyh99 Nov 1, 2023
5faa0fb
refactor: 커리큘럼 ID의 모든 키워드 가져오는 로직 JPQL 사용해서 리팩토링
nuyh99 Nov 1, 2023
746ee8c
refactor: Dto -> Map 변환 로직 Stream API 사용
nuyh99 Nov 1, 2023
4eac034
refactor: 키워드 조회 시 추천 포스트 fetch join -> batch size 사용
nuyh99 Nov 1, 2023
c730607
style: doneQuizCount -> answeredQuizCount로 용어 변경
nuyh99 Nov 1, 2023
d94a493
style: 정적 팩토리 메서드 네이밍 변경
nuyh99 Nov 22, 2023
e9cc339
refactor: 진도율 setter 제거 후 dto 내부에서 매핑하도록 변경
nuyh99 Nov 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,39 @@

import io.cucumber.java.en.Given;
import wooteco.prolog.AcceptanceSteps;
import wooteco.prolog.member.domain.GroupMember;
import wooteco.prolog.member.domain.Member;
import wooteco.prolog.member.domain.MemberGroup;
import wooteco.prolog.member.domain.repository.GroupMemberRepository;
import wooteco.prolog.member.domain.repository.MemberGroupRepository;
import wooteco.prolog.member.domain.*;
import wooteco.prolog.member.domain.repository.DepartmentMemberRepository;
import wooteco.prolog.member.domain.repository.DepartmentRepository;
import wooteco.prolog.member.domain.repository.MemberRepository;

import static wooteco.prolog.member.domain.Part.*;
import static wooteco.prolog.member.domain.Term.*;

public class GroupMemberStepDefinitions extends AcceptanceSteps {

private final MemberRepository memberRepository;
private final MemberGroupRepository memberGroupRepository;
private final GroupMemberRepository groupMemberRepository;
private final DepartmentRepository departmentRepository;
private final DepartmentMemberRepository departmentMemberRepository;

public GroupMemberStepDefinitions(MemberRepository memberRepository,
MemberGroupRepository memberGroupRepository,
GroupMemberRepository groupMemberRepository) {
DepartmentRepository departmentRepository,
DepartmentMemberRepository departmentMemberRepository) {
this.memberRepository = memberRepository;
this.memberGroupRepository = memberGroupRepository;
this.groupMemberRepository = groupMemberRepository;
this.departmentRepository = departmentRepository;
this.departmentMemberRepository = departmentMemberRepository;
}

@Given("{string}을 멤버그룹과 그룹멤버에 등록하고")
public void 그룹멤버를_생성하고(String title) {
Member member = memberRepository.findById(1L).get();
MemberGroup 프론트엔드 = memberGroupRepository.save(
new MemberGroup(null, "4기 프론트엔드", "4기 프론트엔드 설명"));
MemberGroup 백엔드 = memberGroupRepository.save(new MemberGroup(null, "4기 백엔드", "4기 백엔드 설명"));
MemberGroup 안드로이드 = memberGroupRepository.save(
new MemberGroup(null, "4기 안드로이드", "4기 안드로이드 설명"));
groupMemberRepository.save(new GroupMember(null, member, 백엔드));
groupMemberRepository.save(new GroupMember(null, member, 프론트엔드));
groupMemberRepository.save(new GroupMember(null, member, 안드로이드));
Department 프론트엔드 = departmentRepository.save(
new Department(null, FRONTEND, FOURTH));
Department 백엔드 = departmentRepository.save(new Department(null, BACKEND, FOURTH));
Department 안드로이드 = departmentRepository.save(
new Department(null, ANDROID, FOURTH));
departmentMemberRepository.save(new DepartmentMember(null, member, 백엔드));
departmentMemberRepository.save(new DepartmentMember(null, member, 프론트엔드));
departmentMemberRepository.save(new DepartmentMember(null, member, 안드로이드));
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package wooteco.prolog.docu;

import static org.assertj.core.api.Assertions.assertThat;
import static wooteco.prolog.member.domain.Part.*;
import static wooteco.prolog.member.domain.Term.*;

import io.restassured.RestAssured;
import io.restassured.response.ExtractableResponse;
Expand All @@ -16,11 +18,9 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import wooteco.prolog.Documentation;
import wooteco.prolog.member.domain.GroupMember;
import wooteco.prolog.member.domain.Member;
import wooteco.prolog.member.domain.MemberGroup;
import wooteco.prolog.member.domain.repository.GroupMemberRepository;
import wooteco.prolog.member.domain.repository.MemberGroupRepository;
import wooteco.prolog.member.domain.*;
import wooteco.prolog.member.domain.repository.DepartmentMemberRepository;
import wooteco.prolog.member.domain.repository.DepartmentRepository;
import wooteco.prolog.member.domain.repository.MemberRepository;
import wooteco.prolog.session.application.dto.MissionRequest;
import wooteco.prolog.session.application.dto.MissionResponse;
Expand All @@ -37,9 +37,9 @@ class StudylogDocumentation extends Documentation {
@Autowired
private MemberRepository memberRepository;
@Autowired
private MemberGroupRepository memberGroupRepository;
private DepartmentRepository departmentRepository;
@Autowired
private GroupMemberRepository groupMemberRepository;
private DepartmentMemberRepository departmentMemberRepository;

@Test
void 스터디로그를_생성한다() {
Expand Down Expand Up @@ -312,14 +312,14 @@ private StudylogRequest createStudylogRequest3() {

private void 회원과_멤버그룹_그룹멤버를_등록함() {
Member member = memberRepository.findById(1L).get();
MemberGroup 프론트엔드 = memberGroupRepository.save(
new MemberGroup(null, "4기 프론트엔드", "4기 프론트엔드 설명"));
MemberGroup 백엔드 = memberGroupRepository.save(new MemberGroup(null, "4기 백엔드", "4기 백엔드 설명"));
MemberGroup 안드로이드 = memberGroupRepository.save(
new MemberGroup(null, "4기 안드로이드", "4기 안드로이드 설명"));
groupMemberRepository.save(new GroupMember(null, member, 백엔드));
groupMemberRepository.save(new GroupMember(null, member, 프론트엔드));
groupMemberRepository.save(new GroupMember(null, member, 안드로이드));
Department 프론트엔드 = departmentRepository.save(
new Department(null, FRONTEND, FOURTH));
Department 백엔드 = departmentRepository.save(new Department(null, BACKEND, FOURTH));
Department 안드로이드 = departmentRepository.save(
new Department(null, ANDROID, FOURTH));
departmentMemberRepository.save(new DepartmentMember(null, member, 백엔드));
departmentMemberRepository.save(new DepartmentMember(null, member, 프론트엔드));
departmentMemberRepository.save(new DepartmentMember(null, member, 안드로이드));
}

private Long 미션_등록함(MissionRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ public List<ArticleResponse> 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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ public interface ArticleRepository extends JpaRepository<Article, Long> {
Optional<Article> 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<Article> 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<Article> findArticlesByCourseAndMember(@Param("course") String course,
@Param("memberId") Long memberId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public enum BadRequestCode {
ARTICLE_IMAGE_URL_OVER_LENGTH_EXCEPTION(12007, "ARTICLE_IMAGE_URL_OVER_LENGTH_EXCEPTION"),
ARTICLE_INVALID_URL_EXCEPTION(12008, "ARTICLE_INVALID_URL_EXCEPTION"),
UNVALIDATED_MEMBER_EXCEPTION(12009, "UNVALIDATED_MEMBER_EXCEPTION");

private int code;
private String message;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package wooteco.prolog.member.application;

import java.util.List;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import wooteco.prolog.member.domain.DepartmentMember;
import wooteco.prolog.member.domain.repository.DepartmentMemberRepository;

@Service
@AllArgsConstructor
@Transactional(readOnly = true)
public class DepartmentMemberService {

private DepartmentMemberRepository departmentMemberRepository;

public List<DepartmentMember> findDepartmentMemberByDepartmentId(Long departmentId) {
return departmentMemberRepository.findByDepartmentId(departmentId);
}

}

This file was deleted.

40 changes: 40 additions & 0 deletions backend/src/main/java/wooteco/prolog/member/domain/Department.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package wooteco.prolog.member.domain;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Department {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Enumerated(value = EnumType.STRING)
private Part part;

@Enumerated(value = EnumType.STRING)
private Term term;

public Department(Long id, Part part, Term term) {
this.id = id;
this.part = part;
this.term = term;
}

public Department(Long id, String part, String term) {
this.id = id;
this.part = Part.getPartByName(part);
this.term = Term.getTermByName(term);
}

public Part getPart() {
return part;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
public class GroupMember {
public class DepartmentMember {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand All @@ -25,12 +25,12 @@ public class GroupMember {
private Member member;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "group_id", nullable = false)
private MemberGroup group;
@JoinColumn(name = "department_id", nullable = false)
private Department department;

public GroupMember(Long id, Member member, MemberGroup group) {
public DepartmentMember(Long id, Member member, Department department) {
this.id = id;
this.member = member;
this.group = group;
this.department = department;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package wooteco.prolog.member.domain;

import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public class Departments {

private List<Department> values;

public boolean isContainsDepartments(Department department) {
return values.contains(department);
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading