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

refactor: 승인된 신청자 수 필드 추가 #464

Merged
merged 3 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -3,16 +3,14 @@
import java.time.LocalDateTime;

import java.util.List;
import java.util.Objects;

import org.sopt.makers.crew.main.global.constant.CrewConst;
import org.sopt.makers.crew.main.entity.meeting.Meeting;
import org.sopt.makers.crew.main.entity.meeting.enums.MeetingCategory;
import org.sopt.makers.crew.main.entity.meeting.enums.MeetingJoinablePart;
import org.sopt.makers.crew.main.entity.meeting.vo.ImageUrlVO;
import org.sopt.makers.crew.main.entity.user.User;

import com.querydsl.core.annotations.QueryProjection;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
Expand All @@ -28,7 +26,7 @@ public class MeetingResponseDto {
private final Integer id;
@Schema(description = "모임 제목", example = "모임 제목입니다")
@NotNull
String title;
private final String title;
mikekks marked this conversation as resolved.
Show resolved Hide resolved
@Schema(description = "대상 기수", example = "33")
@NotNull
private final Integer targetActiveGeneration;
Expand Down Expand Up @@ -70,36 +68,12 @@ public class MeetingResponseDto {
@Schema(description = "모임장 정보", example = "")
@NotNull
private final MeetingCreatorDto user;
@Schema(description = "신청 승인 수", example = "7")
@Schema(description = "TODO: FE에서 수정 완료 후 삭제 ", example = "[DEPRECATED]")
@NotNull
private final int appliedCount;

@QueryProjection
public MeetingResponseDto(Integer id, String title, Integer targetActiveGeneration,
@NotNull MeetingJoinablePart[] joinableParts, MeetingCategory category, Boolean canJoinOnlyActiveGeneration,
Integer status,
List<ImageUrlVO> imageURL, Boolean isMentorNeeded, LocalDateTime mStartDate, LocalDateTime mEndDate,
int capacity,
MeetingCreatorDto user, int appliedCount) {

boolean processedCanJoinOnlyActiveGeneration = canJoinOnlyActiveGeneration
&& (CrewConst.ACTIVE_GENERATION.equals(targetActiveGeneration));

this.id = id;
this.title = title;
this.targetActiveGeneration = targetActiveGeneration;
this.joinableParts = joinableParts;
this.category = category.getValue();
this.canJoinOnlyActiveGeneration = processedCanJoinOnlyActiveGeneration;
this.status = status;
this.imageURL = imageURL;
this.isMentorNeeded = isMentorNeeded;
this.mStartDate = mStartDate;
this.mEndDate = mEndDate;
this.capacity = capacity;
this.user = user;
this.appliedCount = appliedCount;
}
@Schema(description = "승인된 신청자 수", example = "3")
@NotNull
private final int approvedCount;

public LocalDateTime getmStartDate() {
return mStartDate;
Expand All @@ -109,15 +83,16 @@ public LocalDateTime getmEndDate() {
return mEndDate;
}

public static MeetingResponseDto of(Meeting meeting, User meetingCreator, int appliedCount, LocalDateTime now) {
public static MeetingResponseDto of(Meeting meeting, User meetingCreator, int approvedCount, LocalDateTime now) {
MeetingCreatorDto creatorDto = MeetingCreatorDto.of(meetingCreator);
boolean canJoinOnlyActiveGeneration = meeting.getTargetActiveGeneration() == CrewConst.ACTIVE_GENERATION
boolean canJoinOnlyActiveGeneration =
Objects.equals(meeting.getTargetActiveGeneration(), CrewConst.ACTIVE_GENERATION)
&& meeting.getCanJoinOnlyActiveGeneration();

return new MeetingResponseDto(meeting.getId(), meeting.getTitle(),
meeting.getTargetActiveGeneration(), meeting.getJoinableParts(), meeting.getCategory(),
meeting.getTargetActiveGeneration(), meeting.getJoinableParts(), meeting.getCategory().getValue(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

왜 Category Getter에는 getValue() 옵션이 추가되었을까요?

기존에는 없었어서 여쭈어봅니다.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

스크린샷 2024-10-26 오후 4 12 36

기존에도 getValue()를 사용하지 않았나요?!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저게 enum이 아니라 "스터디" 이런식으로 줘야해서 그랬던 거 같습니다!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아하 확인했습니다!

public LocalDateTime getmStartDate() {
    return mStartDate;
}

public LocalDateTime getmEndDate() {
    return mEndDate;
}

해당 getter도 사용하지 않는 것 같은데 삭제하는게 어떨까요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거는 예전에 스웨거 때문에 남겨둔걸로 기억해요!!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 하지 않으면 스웨거 상에서 앞에 "m" 글자가 사라지더라고요..

canJoinOnlyActiveGeneration, meeting.getMeetingStatus(now), meeting.getImageURL(),
meeting.getIsMentorNeeded(), meeting.getMStartDate(), meeting.getMEndDate(), meeting.getCapacity(),
creatorDto, appliedCount);
creatorDto, approvedCount, approvedCount);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ void normal_getMeetings_success() {
"title", "category", "canJoinOnlyActiveGeneration",
"mStartDate", "mEndDate",
"capacity", "isMentorNeeded", "targetActiveGeneration",
"joinableParts", "status", "appliedCount"
"joinableParts", "status", "approvedCount"
).containsExactly(
tuple("세미나 구합니다 - 신청후", "세미나", false,
LocalDateTime.of(2024, 5, 29, 0, 0),
Expand Down Expand Up @@ -542,7 +542,7 @@ void getOnlyActiveGenerationMeeting_getMeetings_meetings() {
"title", "category", "canJoinOnlyActiveGeneration",
"mStartDate", "mEndDate",
"capacity", "isMentorNeeded", "targetActiveGeneration",
"joinableParts", "status", "appliedCount"
"joinableParts", "status", "approvedCount"
).containsExactly(
tuple("스터디 구합니다1", "행사", true,
LocalDateTime.of(2024, 5, 29, 0, 0),
Expand Down Expand Up @@ -588,7 +588,7 @@ void getByCategory_getMeetings_meetings() {
"title", "category", "canJoinOnlyActiveGeneration",
"mStartDate", "mEndDate",
"capacity", "isMentorNeeded", "targetActiveGeneration",
"joinableParts", "status", "appliedCount"
"joinableParts", "status", "approvedCount"
).containsExactly(
tuple("세미나 구합니다 - 신청후", "세미나", false,
LocalDateTime.of(2024, 5, 29, 0, 0),
Expand Down
Loading