Skip to content

Commit

Permalink
refactor: 사용하지 않는 QueryProjection 삭제 + 모임 제목에 private final 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
mikekks committed Oct 24, 2024
1 parent 785b09d commit d908f38
Showing 1 changed file with 8 additions and 37 deletions.
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;
@Schema(description = "대상 기수", example = "33")
@NotNull
private final Integer targetActiveGeneration;
Expand Down Expand Up @@ -70,41 +68,13 @@ 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;
@Schema(description = "승인된 신청자 수", example = "3")
@NotNull
private final int approvedCount;

@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 approvedCount) {

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 = approvedCount;
this.approvedCount = approvedCount;
}

public LocalDateTime getmStartDate() {
return mStartDate;
}
Expand All @@ -113,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(),
canJoinOnlyActiveGeneration, meeting.getMeetingStatus(now), meeting.getImageURL(),
meeting.getIsMentorNeeded(), meeting.getMStartDate(), meeting.getMEndDate(), meeting.getCapacity(),
creatorDto, appliedCount);
creatorDto, approvedCount, approvedCount);
}
}

0 comments on commit d908f38

Please sign in to comment.