Skip to content

Commit

Permalink
[#148] Add v2 meetingdetaildto
Browse files Browse the repository at this point in the history
  • Loading branch information
emost22 committed Apr 3, 2023
1 parent 9c6c46d commit 517ca31
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.promise8.wwwbe.model.v1.dto.PromiseDayOfWeek;
import com.promise8.wwwbe.model.v1.dto.PromiseTime;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -12,6 +13,7 @@
@Setter
@Getter
@Builder
@ApiModel(value = "ConfirmedPromise", description = "확정된 약속 정보")
public class ConfirmedPromise {
@ApiModelProperty(value = "confirmedDate", notes = "확정된 날짜")
private LocalDate promiseDate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
package com.promise8.wwwbe.model.v2.dto.res;

import com.promise8.wwwbe.model.v1.dto.res.ConfirmedPromiseResDtoV1;
import com.promise8.wwwbe.model.v1.entity.MeetingEntityV1;
import com.promise8.wwwbe.model.v1.entity.MeetingStatusV1;
import com.promise8.wwwbe.model.v1.entity.MeetingUserEntityV1;
import com.promise8.wwwbe.model.v1.entity.UserEntityV1;
import com.promise8.wwwbe.service.MeetingServiceHelper;
import com.promise8.wwwbe.service.ThumbnailHelper;
import io.swagger.annotations.ApiModel;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDate;
import java.util.List;

@Setter
@Getter
@Builder
Expand All @@ -19,4 +29,59 @@ public class MeetingGetResDtoV2 {
private int votingCount;
private String meetingCode;
private String shortLink;
private ConfirmedPromise confirmedPromise;
private LocalDate startDate;
private LocalDate endDate;
private List<UserInfoDtoV2> joinedUserInfoList;
private List<UserPromiseTimeResDtoV2> promiseTimeList;
private List<UserPromisePlaceResDtoV2> promisePlaceList;
private MeetingStatusV1 meetingStatus;
private ThumbnailHelper.YaksokiType yaksokiType;

public static MeetingGetResDtoV2 of(
MeetingEntityV1 meetingEntity,
List<UserInfoDtoV2> userInfoDtoList,
List<UserPromisePlaceResDtoV2> userPromisePlaceResDtoList,
List<UserPromiseTimeResDtoV2> userPromiseTimeResDtoList,
ConfirmedPromiseResDtoV1 confirmedPromiseResDto,
UserEntityV1 userEntity) {

String currentUserName = null;
if (meetingEntity.getMeetingUserEntityList() != null) {
for (MeetingUserEntityV1 meetingUserEntity : meetingEntity.getMeetingUserEntityList()) {
if (userEntity.getUserId().equals(meetingUserEntity.getUserEntity().getUserId())) {
currentUserName = meetingUserEntity.getMeetingUserName();
break;
}
}
}

ConfirmedPromise confirmedPromise = ConfirmedPromise.builder()
.promiseDate(confirmedPromiseResDto.getPromiseDate())
.promiseDayOfWeek(MeetingServiceHelper.getPromiseDayOfWeek(confirmedPromiseResDto.getPromiseDate()))
.promiseTime(confirmedPromiseResDto.getPromiseTime())
.promisePlace(confirmedPromiseResDto.getPromisePlace())
.build();

boolean isNoMeetingUser = meetingEntity.getMeetingUserEntityList() == null || meetingEntity.getMeetingUserEntityList().isEmpty();
return MeetingGetResDtoV2.builder()
.meetingId(meetingEntity.getMeetingId())
.meetingName(meetingEntity.getMeetingName())
.minimumAlertMembers(meetingEntity.getConditionCount().intValue())
.currentUserName(currentUserName == null ? userEntity.getUserName() : currentUserName)
.isHost(userEntity.getUserId().equals(meetingEntity.getCreator().getUserId()))
.joinedCount(isNoMeetingUser ? 0 : meetingEntity.getMeetingUserEntityList().size())
.votingCount(confirmedPromiseResDto.getVotingUserCount())
.meetingCode(meetingEntity.getMeetingCode())
.shortLink(meetingEntity.getShortLink())
.confirmedPromise(confirmedPromise)
.startDate(meetingEntity.getStartDate())
.endDate(meetingEntity.getEndDate())
.joinedUserInfoList(userInfoDtoList)
.promiseTimeList(userPromiseTimeResDtoList)
.promisePlaceList(userPromisePlaceResDtoList)
.meetingStatus(meetingEntity.getMeetingStatus())
.yaksokiType(ThumbnailHelper.getYaksoki(meetingEntity.getMeetingId()))
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.promise8.wwwbe.model.v2.dto.res;

import com.promise8.wwwbe.service.ThumbnailHelper;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class UserInfoDtoV2 {
private String joinedUserName;
private ThumbnailHelper.CharacterType characterType;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.promise8.wwwbe.model.v2.dto.res;

import com.promise8.wwwbe.service.ThumbnailHelper;
import com.promise8.wwwbe.model.v1.entity.MeetingPlaceEntityV1;
import com.promise8.wwwbe.model.v1.entity.PlaceVoteEntityV1;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

@Setter
@Getter
@Builder
@ApiModel(value = "UserPromisePlace", description = "유저들이 선택한 장소")
public class UserPromisePlaceResDtoV2 {
@ApiModelProperty(value = "placeId", required = true, notes = "장소 id")
private Long placeId;
@ApiModelProperty(value = "promisePlace", required = true, notes = "해당 장소를 선택한 유저")
private String promisePlace;
@ApiModelProperty(value = "votedUserCount", required = true, notes = "해당 장소를 투표한 사람 수")
private int votedUserCount;
@ApiModelProperty(value = "userInfoList", required = true, notes = "해당 장소를 선택한 유저 list")
private List<UserInfoDtoV2> userInfoList;

public static UserPromisePlaceResDtoV2 of(MeetingPlaceEntityV1 meetingPlaceEntity, Long userId) {
List<UserInfoDtoV2> userInfoList = new ArrayList<>();
for (PlaceVoteEntityV1 placeVoteEntity : meetingPlaceEntity.getPlaceVoteEntityList()) {
userInfoList.add(
new UserInfoDtoV2(
placeVoteEntity.getMeetingUserEntity().getMeetingUserName(),
ThumbnailHelper.getCharacter(
placeVoteEntity.getMeetingUserEntity().getUserEntity().getUserId(),
placeVoteEntity.getMeetingUserEntity().getUserEntity().getUserId().equals(userId)
)
)
);
}

return UserPromisePlaceResDtoV2.builder()
.placeId(meetingPlaceEntity.getMeetingPlaceId())
.promisePlace(meetingPlaceEntity.getPromisePlace())
.userInfoList(userInfoList)
.votedUserCount(userInfoList.size())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.promise8.wwwbe.model.v2.dto.res;

import com.promise8.wwwbe.model.v1.dto.PromiseDayOfWeek;
import com.promise8.wwwbe.model.v1.dto.PromiseTime;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDate;
import java.util.List;

@Setter
@Getter
@Builder
@ApiModel(value = "UserPromiseTime", description = "유저들이 선택한 날짜, 시간대")
public class UserPromiseTimeResDtoV2 {
@ApiModelProperty(value = "timetableId", required = true, notes = "시간 id")
private Long timetableId;
@ApiModelProperty(value = "promiseDate", required = true, notes = "날짜")
private LocalDate promiseDate;
@ApiModelProperty(value = "promiseTime", required = true, notes = "시간대")
private PromiseTime promiseTime;
@ApiModelProperty(value = "promiseDayOfWeek", required = true, notes = "요일")
private PromiseDayOfWeek promiseDayOfWeek;
@ApiModelProperty(value = "userInfoList", required = true, notes = "해당 날짜, 시간대를 선택한 유저 list")
private List<UserInfoDtoV2> userInfoList;
}

0 comments on commit 517ca31

Please sign in to comment.