|
| 1 | +package dcom.homepage.api.domain.study.dto; |
| 2 | + |
| 3 | +import dcom.homepage.api.domain.study.Study; |
| 4 | +import dcom.homepage.api.domain.study.StudyType; |
| 5 | +import dcom.homepage.api.domain.users.dto.UserResponseDto; |
| 6 | +import io.swagger.annotations.ApiModel; |
| 7 | +import io.swagger.annotations.ApiModelProperty; |
| 8 | +import lombok.AllArgsConstructor; |
| 9 | +import lombok.Builder; |
| 10 | +import lombok.Getter; |
| 11 | +import lombok.Setter; |
| 12 | + |
| 13 | +import java.util.Date; |
| 14 | +import java.util.List; |
| 15 | +import java.util.stream.Collectors; |
| 16 | + |
| 17 | +public class StudyResponseDto { |
| 18 | + @ApiModel(value = "리스트 용 스터디 정보") |
| 19 | + @Builder |
| 20 | + @Getter @Setter |
| 21 | + @AllArgsConstructor |
| 22 | + public static class SimpleInfo { |
| 23 | + @ApiModelProperty(value = "스터디 아이디") |
| 24 | + private Integer id; |
| 25 | + |
| 26 | + @ApiModelProperty(value = "스터디 이름") |
| 27 | + private String name; |
| 28 | + |
| 29 | + @ApiModelProperty(value = "스터디 유형") |
| 30 | + private StudyType type; |
| 31 | + |
| 32 | + @ApiModelProperty(value = "스터디 설명") |
| 33 | + private String description; |
| 34 | + |
| 35 | + @ApiModelProperty(value = "스터디 소유자") |
| 36 | + private UserResponseDto.SimpleProfile owner; |
| 37 | + |
| 38 | + @ApiModelProperty(value = "스터디 생성 일자") |
| 39 | + private Date createdAt; |
| 40 | + |
| 41 | + @ApiModelProperty(value = "스터디 시작 일자") |
| 42 | + private Date startDate; |
| 43 | + |
| 44 | + @ApiModelProperty(value = "스터디 종료 일자") |
| 45 | + private Date endDate; |
| 46 | + |
| 47 | + @ApiModelProperty(value = "스터디 주기") |
| 48 | + private Integer cycle; |
| 49 | + |
| 50 | + public static SimpleInfo of(Study study) { |
| 51 | + return SimpleInfo.builder() |
| 52 | + .id(study.getId()) |
| 53 | + .name(study.getName()) |
| 54 | + .type(study.getType()) |
| 55 | + .description(study.getDescription()) |
| 56 | + .owner(UserResponseDto.SimpleProfile.of(study.getOwner())) |
| 57 | + .createdAt(study.getCreatedAt()) |
| 58 | + .startDate(study.getStartDate()) |
| 59 | + .endDate(study.getEndDate()) |
| 60 | + .cycle(study.getCycle()) |
| 61 | + .build(); |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + @ApiModel(value = "전체 스터디 정보") |
| 66 | + @Builder |
| 67 | + @Getter @Setter |
| 68 | + @AllArgsConstructor |
| 69 | + public static class Info { |
| 70 | + @ApiModelProperty(value = "스터디 아이디") |
| 71 | + private Integer id; |
| 72 | + |
| 73 | + @ApiModelProperty(value = "스터디 이름") |
| 74 | + private String name; |
| 75 | + |
| 76 | + @ApiModelProperty(value = "스터디 유형") |
| 77 | + private StudyType type; |
| 78 | + |
| 79 | + @ApiModelProperty(value = "스터디 설명") |
| 80 | + private String description; |
| 81 | + |
| 82 | + @ApiModelProperty(value = "스터디 소유자") |
| 83 | + private UserResponseDto.SimpleProfile owner; |
| 84 | + |
| 85 | + @ApiModelProperty(value = "스터디 관리자") |
| 86 | + private List<UserResponseDto.SimpleProfile> admin; |
| 87 | + |
| 88 | + @ApiModelProperty(value = "스터디 참여 인원") |
| 89 | + private List<UserResponseDto.SimpleProfile> users; |
| 90 | + |
| 91 | + @ApiModelProperty(value = "스터디 신청 유저") |
| 92 | + private List<UserResponseDto.SimpleProfile> pendingUsers; |
| 93 | + |
| 94 | + @ApiModelProperty(value = "스터디 생성 일자") |
| 95 | + private Date createdAt; |
| 96 | + |
| 97 | + @ApiModelProperty(value = "스터디 시작 일자") |
| 98 | + private Date startDate; |
| 99 | + |
| 100 | + @ApiModelProperty(value = "스터 종료 일자") |
| 101 | + private Date endDate; |
| 102 | + |
| 103 | + @ApiModelProperty(value = "스터디 휴식 시작 일자") |
| 104 | + private Date vacationStartDate; |
| 105 | + |
| 106 | + @ApiModelProperty(value = "스터디 휴식 종료 일자") |
| 107 | + private Date vacationEndDate; |
| 108 | + |
| 109 | + @ApiModelProperty(value = "스터디 주기") |
| 110 | + private Integer cycle; |
| 111 | + |
| 112 | + public static Info of(Study study) { |
| 113 | + return Info.builder() |
| 114 | + .id(study.getId()) |
| 115 | + .name(study.getName()) |
| 116 | + .type(study.getType()) |
| 117 | + .description(study.getDescription()) |
| 118 | + .owner(UserResponseDto.SimpleProfile.of(study.getOwner())) |
| 119 | + .admin(study.getAdmin() |
| 120 | + .stream() |
| 121 | + .map(UserResponseDto.SimpleProfile::of) |
| 122 | + .collect(Collectors.toList())) |
| 123 | + .users(study.getUsers() |
| 124 | + .stream() |
| 125 | + .map(UserResponseDto.SimpleProfile::of) |
| 126 | + .collect(Collectors.toList())) |
| 127 | + .pendingUsers(study.getPendingUsers() |
| 128 | + .stream() |
| 129 | + .map(UserResponseDto.SimpleProfile::of) |
| 130 | + .collect(Collectors.toList())) |
| 131 | + .createdAt(study.getCreatedAt()) |
| 132 | + .startDate(study.getStartDate()) |
| 133 | + .endDate(study.getEndDate()) |
| 134 | + .vacationStartDate(study.getVacationStartDate()) |
| 135 | + .vacationEndDate(study.getVacationEndDate()) |
| 136 | + .cycle(study.getCycle()) |
| 137 | + .build(); |
| 138 | + } |
| 139 | + } |
| 140 | +} |
0 commit comments