Skip to content

Commit

Permalink
♻️ [STMT-187] 활동 간략/상세 목록 조회 API에 스터디 정보 추가 (#171)
Browse files Browse the repository at this point in the history
* ♻️ [STMT-187] 활동 상세 목록 조회 쿼리에서 study table을 조인문 추가하여 스터디 이름 가져오기

* ♻️ [STMT-187] 활동 상세 목록 조회 응답에 스터디 이름 추가에 따라 기존 코드 수정

- ActivityLinkedStudy 도메인에 name 필드 추가
- ActivitySource에 study source record 추가
- 다른 부가 컴포넌트들에 study name 추가

* ✅ [STMT-187] 활동 상세 목록 응답 필드에 스터디 이름 추가

* ♻️ [STMT-187] 활동 간략 목록 조회 쿼리에 study name 정보 추가

* ✅ [STMT-187] 활동 간략 목록 조회 쿼리에 study name 정보 추가에 따른 응답필드 수정
  • Loading branch information
05AM authored Jan 6, 2025
1 parent f704720 commit 8edf6e1
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
@Builder
public record ActivityListBriefResponse(
Long id,
Long studyId,
String studyName,
String category,
String title,
LocalDateTime startDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
@Builder
public record ActivityListDetailedPageResponse(
Long id,
Long studyId,
String studyName,
String category,
String title,
String content,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ public class ActivityPersistenceMapper {
public Activity toDomain(ActivityJpaEntity entity) {
ActivitySource request = ActivitySource.builder()
.id(entity.getId())
.study(ActivitySource.ActivityLinkedStudyCreateSource.builder()
.id(entity.getStudy().getId())
.name(entity.getStudy().getName())
.build())
.author(ActivitySource.ActivityMemberCreateSource.builder()
.id(entity.getAuthor().getId())
.name(entity.getAuthor().getName())
.image(entity.getAuthor().getImage())
.build())
.studyId(entity.getStudy().getId())
.category(entity.getCategory())
.title(entity.getTitle())
.content(entity.getContent())
Expand All @@ -51,14 +54,15 @@ public Page<Activity> toDomainPages(Page<ActivityJpaEntity> entities) {
public ActivityJpaEntity toEntity(Activity domain) {
return ActivityJpaEntity.builder()
.id(domain.getId())
.study(ActivityLinkedStudyJpaEntity.builder()
.id(domain.getStudy().getId())
.name(domain.getStudy().getName())
.build())
.author(ActivityMemberJpaEntity.builder()
.id(domain.getAuthor().getId())
.name(domain.getAuthor().getName())
.image(domain.getAuthor().getImage())
.build())
.study(ActivityLinkedStudyJpaEntity.builder()
.id(domain.getStudy().getId())
.build())
.category(domain.getCategory())
.title(domain.getTitle())
.content(domain.getContent())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ public class ActivityLinkedStudyJpaEntity {
@Comment("스터디 id")
private Long id;

@Column(name = "name")
@Comment("스터디명")
private String name;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.stumeet.server.activity.adapter.out.persistence;

import static com.stumeet.server.activity.adapter.out.model.QActivityJpaEntity.*;
import static com.stumeet.server.activity.adapter.out.model.QActivityLinkedStudyJpaEntity.*;
import static com.stumeet.server.activity.adapter.out.model.QActivityParticipantJpaEntity.*;

import java.time.LocalDateTime;
Expand Down Expand Up @@ -32,6 +33,7 @@ public Page<ActivityJpaEntity> findDetailPagesByCondition(
Pageable pageable, Boolean isNotice, Long studyId, ActivityCategory category) {
List<ActivityJpaEntity> content = query
.selectFrom(activityJpaEntity)
.join(activityJpaEntity.study, activityLinkedStudyJpaEntity).fetchJoin()
.where(
isNoticeEq(isNotice),
studyIdEq(studyId),
Expand Down Expand Up @@ -61,6 +63,8 @@ public Page<ActivityListBriefResponse> findBriefsByConditionWithPagination(Pagea
.select(
new QActivityListBriefResponse(
activityJpaEntity.id,
activityLinkedStudyJpaEntity.id,
activityLinkedStudyJpaEntity.name,
activityJpaEntity.category.stringValue(),
activityJpaEntity.title,
activityJpaEntity.startDate,
Expand All @@ -71,6 +75,7 @@ public Page<ActivityListBriefResponse> findBriefsByConditionWithPagination(Pagea
)
)
.from(activityJpaEntity)
.join(activityJpaEntity.study, activityLinkedStudyJpaEntity)
.leftJoin(activityParticipantJpaEntity)
.on(
activityJpaEntity.id.eq(activityParticipantJpaEntity.activity.id)
Expand Down Expand Up @@ -113,6 +118,8 @@ public List<ActivityListBriefResponse> findBriefsByCondition(Boolean isNotice, L
.select(
new QActivityListBriefResponse(
activityJpaEntity.id,
activityLinkedStudyJpaEntity.id,
activityLinkedStudyJpaEntity.name,
activityJpaEntity.category.stringValue(),
activityJpaEntity.title,
activityJpaEntity.startDate,
Expand All @@ -123,6 +130,7 @@ public List<ActivityListBriefResponse> findBriefsByCondition(Boolean isNotice, L
)
)
.from(activityJpaEntity)
.join(activityJpaEntity.study, activityLinkedStudyJpaEntity)
.leftJoin(activityParticipantJpaEntity)
.on(
activityJpaEntity.id.eq(activityParticipantJpaEntity.activity.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class ActivityUseCaseMapper {
public ActivitySource toCreateSource(Long studyId, ActivityCreateCommand command, Long id) {
return ActivitySource.builder()
.id(null)
.studyId(studyId)
.study(ActivitySource.ActivityLinkedStudyCreateSource.builder()
.id(studyId)
.build())
.author(ActivitySource.ActivityMemberCreateSource.builder()
.id(id)
.build())
Expand All @@ -48,7 +50,9 @@ public ActivitySource toCreateSource(Long studyId, ActivityCreateCommand command
public ActivitySource toUpdateSource(Activity exist, ActivityUpdateCommand command) {
return ActivitySource.builder()
.id(exist.getId())
.studyId(exist.getStudy().getId())
.study(ActivitySource.ActivityLinkedStudyCreateSource.builder()
.id(exist.getId())
.build())
.author(ActivitySource.ActivityMemberCreateSource.builder()
.id(exist.getAuthor().getId())
.build())
Expand Down Expand Up @@ -95,6 +99,8 @@ public ActivityDetailResponse toDetailResponse(
private ActivityListDetailedPageResponse toListDetailedPageResponse(Activity activity) {
return ActivityListDetailedPageResponse.builder()
.id(activity.getId())
.studyId(activity.getStudy().getId())
.studyName(activity.getStudy().getName())
.category(activity.getCategory().name())
.title(activity.getTitle())
.content(activity.getContent())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@Builder
public record ActivitySource(
Long id,
Long studyId,
ActivityLinkedStudyCreateSource study,
ActivityMemberCreateSource author,
ActivityCategory category,
String title,
Expand All @@ -27,4 +27,11 @@ public record ActivityMemberCreateSource(
String image
) {
}

@Builder
public record ActivityLinkedStudyCreateSource(
Long id,
String name
) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ public enum ActivityCategory {
public Activity create(ActivitySource source) {
return Default.builder()
.id(source.id())
.study(ActivityLinkedStudy.builder().id(source.studyId()).build())
.study(ActivityLinkedStudy.builder()
.id(source.study().id())
.name(source.study().name())
.build())
.author(ActivityMember.builder()
.id(source.author().id())
.name(source.author().name())
Expand Down Expand Up @@ -49,7 +52,10 @@ public void validateStatus(ActivityStatus status) {
public Activity create(ActivitySource source) {
return Meet.builder()
.id(source.id())
.study(ActivityLinkedStudy.builder().id(source.studyId()).build())
.study(ActivityLinkedStudy.builder()
.id(source.study().id())
.name(source.study().name())
.build())
.author(ActivityMember.builder()
.id(source.author().id())
.name(source.author().name())
Expand Down Expand Up @@ -83,7 +89,10 @@ public void validateStatus(ActivityStatus status) {
public Activity create(ActivitySource source) {
return Assignment.builder()
.id(source.id())
.study(ActivityLinkedStudy.builder().id(source.studyId()).build())
.study(ActivityLinkedStudy.builder()
.id(source.study().id())
.name(source.study().name())
.build())
.author(ActivityMember.builder()
.id(source.author().id())
.name(source.author().name())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@Getter
public class ActivityLinkedStudy {
private Long id;
private String name;

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ void success() throws Exception {
fieldWithPath("message").description("응답 메시지"),
fieldWithPath("data.items[]").description("활동 상세 목록"),
fieldWithPath("data.items[].id").description("활동 ID"),
fieldWithPath("data.items[].studyId").description("활동 연관 스터디 ID"),
fieldWithPath("data.items[].studyName").description("활동 연관 스터디명"),
fieldWithPath("data.items[].category").description("활동 유형"),
fieldWithPath("data.items[].title").description("활동 제목"),
fieldWithPath("data.items[].content").description("활동 내용"),
Expand Down Expand Up @@ -332,6 +334,8 @@ void success() throws Exception {
fieldWithPath("message").description("응답 메시지"),
fieldWithPath("data.items[]").description("활동 상세 목록"),
fieldWithPath("data.items[].id").description("활동 ID"),
fieldWithPath("data.items[].studyId").description("활동 연관 스터디 ID"),
fieldWithPath("data.items[].studyName").description("활동 연관 스터디명"),
fieldWithPath("data.items[].category").description("활동 유형"),
fieldWithPath("data.items[].title").description("활동 제목"),
fieldWithPath("data.items[].startDate").description("활동 시작일"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ void success() throws Exception {
fieldWithPath("data.studyDetail.isDeleted").description("삭제 여부"),
fieldWithPath("data.activityNotice").description("최근 공지 활동"),
fieldWithPath("data.activityNotice.id").description("활동 ID"),
fieldWithPath("data.activityNotice.studyId").description("활동 연관 스터디 ID"),
fieldWithPath("data.activityNotice.studyName").description("활동 연관 스터디명"),
fieldWithPath("data.activityNotice.category").description("활동 유형"),
fieldWithPath("data.activityNotice.title").description("활동 제목"),
fieldWithPath("data.activityNotice.content").description("활동 내용"),
Expand Down
4 changes: 3 additions & 1 deletion src/test/java/com/stumeet/server/stub/ActivityStub.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ public static ActivitySource getDefaultCreateSource() {
Member member = MemberStub.getMember();
return ActivitySource.builder()
.id(1L)
.studyId(StudyStub.getStudyId())
.study(ActivitySource.ActivityLinkedStudyCreateSource.builder()
.id(StudyStub.getStudyId())
.build())
.author(ActivitySource.ActivityMemberCreateSource.builder()
.id(member.getId())
.name(member.getName())
Expand Down

0 comments on commit 8edf6e1

Please sign in to comment.