|
20 | 20 | @Slf4j |
21 | 21 | public class SpaceResponse { |
22 | 22 |
|
23 | | - @Builder |
24 | | - @Schema(description = "스페이스 정보 응답") |
25 | | - public record SpaceWithMemberCountInfo( |
26 | | - @Schema(description = "스페이스 ID") |
27 | | - @NotNull |
28 | | - Long id, |
29 | | - @Schema(description = "프로젝트 유형 카테고리") |
30 | | - @NotNull |
31 | | - SpaceCategory category, |
32 | | - @Schema(description = "진행중인 프로젝트 유형") |
33 | | - @NotNull |
34 | | - List<SpaceField> fieldList, |
35 | | - @Schema(description = "이름") |
36 | | - @NotNull |
37 | | - String name, |
38 | | - @Schema(description = "공간 설명") |
39 | | - String introduction, |
40 | | - @Schema(description = "설정된 회고 폼 아이디") |
41 | | - Long formId, |
42 | | - @Schema(description = "설정된 회고 폼 태그") |
43 | | - String formTag, |
44 | | - @Schema(description = "소속된 회원 수") |
45 | | - Long memberCount, |
46 | | - @Schema(description = "스페이스 배너 이미지") |
47 | | - String bannerUrl, |
48 | | - @Schema(description = "스페이스 생성 일자") |
49 | | - LocalDateTime createdAt, |
50 | | - @Schema(description = "스페이스 리더 아이디") |
51 | | - Leader leader |
52 | | - ) { |
53 | | - public static SpaceWithMemberCountInfo toResponse(SpaceWithMemberCount space) { |
54 | | - |
55 | | - return SpaceWithMemberCountInfo.builder() |
56 | | - .id(space.getId()) |
57 | | - .category(space.getCategory()) |
58 | | - .fieldList(space.getFieldList()) |
59 | | - .name(space.getName()) |
60 | | - .introduction(space.getIntroduction()) |
61 | | - .formId(space.getFormId()) |
62 | | - .formTag(space.getFormTag()) |
63 | | - .memberCount(space.getMemberCount()) |
64 | | - .bannerUrl(space.getBannerUrl()) |
65 | | - .createdAt(space.getCreatedAt()) |
66 | | - .leader(space.getLeader()) |
67 | | - .build(); |
68 | | - } |
69 | | - |
70 | | - public static SpaceWithMemberCountInfo of(Space space, Form form, Long memberCount, Leader leader) { |
71 | | - String formTag = form != null ? form.getFormTag().getTag() : null; |
72 | | - |
73 | | - return SpaceWithMemberCountInfo.builder() |
74 | | - .id(space.getId()) |
75 | | - .category(space.getCategory()) |
76 | | - .fieldList(space.getFieldList()) |
77 | | - .name(space.getName()) |
78 | | - .introduction(space.getIntroduction()) |
79 | | - .formId(space.getFormId()) |
80 | | - .formTag(formTag) |
81 | | - .memberCount(memberCount) |
82 | | - .bannerUrl(space.getBannerUrl()) |
83 | | - .createdAt(space.getCreatedAt()) |
84 | | - .leader(leader) |
85 | | - .build(); |
86 | | - } |
87 | | - } |
88 | | - |
89 | | - @Builder |
90 | | - @Schema |
91 | | - public record SpacePage( |
92 | | - @Schema |
93 | | - List<SpaceWithMemberCountInfo> data, |
94 | | - |
95 | | - @Schema |
96 | | - Meta meta |
97 | | - ) { |
98 | | - |
99 | | - public static SpacePage toResponse(List<SpaceWithMemberCountInfo> spaceInfo, Meta meta) { |
100 | | - return SpacePage.builder().data(spaceInfo).meta(meta).build(); |
101 | | - } |
102 | | - } |
103 | | - |
104 | | - @Builder |
105 | | - @Schema |
106 | | - public record SpaceCreateResponse( |
107 | | - @Schema(title = "생성된 스페이스 아이디", description = """ |
108 | | - |
109 | | - 생성 완료된 스페이스의 아이디 |
110 | | - |
111 | | - """) |
112 | | - Long spaceId |
113 | | - ) { |
114 | | - } |
115 | | - |
116 | | - @Builder |
117 | | - @Schema |
118 | | - public record SpaceMemberResponse( |
119 | | - @Schema(title = "맴버 아이디") |
120 | | - Long id, |
121 | | - @Schema(title = "멤버 프로필 사진") |
122 | | - String avatar, |
123 | | - |
124 | | - @Schema(title = "멤버 이름") |
125 | | - String name, |
126 | | - |
127 | | - @Schema(title = "스페이스 리더 여부") |
128 | | - Boolean isLeader |
129 | | - ) { |
130 | | - public static SpaceMemberResponse of(Member member, boolean isLeader) { |
131 | | - return SpaceMemberResponse |
132 | | - .builder() |
133 | | - .id(member.getId()) |
134 | | - .name(member.getName()) |
135 | | - .avatar(member.getProfileImageUrl()) |
136 | | - .isLeader(isLeader) |
137 | | - .build(); |
138 | | - } |
139 | | - } |
| 23 | + @Builder |
| 24 | + @Schema(description = "스페이스 정보 응답") |
| 25 | + public record SpaceWithMemberCountInfo( |
| 26 | + @Schema(description = "스페이스 ID") |
| 27 | + @NotNull |
| 28 | + Long id, |
| 29 | + @Schema(description = "프로젝트 유형 카테고리") |
| 30 | + @NotNull |
| 31 | + SpaceCategory category, |
| 32 | + @Schema(description = "진행중인 프로젝트 유형") |
| 33 | + @NotNull |
| 34 | + List<SpaceField> fieldList, |
| 35 | + @Schema(description = "이름") |
| 36 | + @NotNull |
| 37 | + String name, |
| 38 | + @Schema(description = "공간 설명") |
| 39 | + String introduction, |
| 40 | + @Schema(description = "설정된 회고 폼 아이디") |
| 41 | + Long formId, |
| 42 | + @Schema(description = "설정된 회고 폼 태그") |
| 43 | + String formTag, |
| 44 | + @Schema(description = "소속된 회원 수") |
| 45 | + Long memberCount, |
| 46 | + @Schema(description = "스페이스 배너 이미지") |
| 47 | + String bannerUrl, |
| 48 | + @Schema(description = "스페이스 생성 일자") |
| 49 | + LocalDateTime createdAt, |
| 50 | + @Schema(description = "스페이스 리더 아이디") |
| 51 | + Leader leader |
| 52 | + |
| 53 | + ) { |
| 54 | + public static SpaceWithMemberCountInfo of(Space space, Form form, Long memberCount, Leader leader) { |
| 55 | + String formTag = form != null ? form.getFormTag().getTag() : null; |
| 56 | + |
| 57 | + return SpaceWithMemberCountInfo.builder() |
| 58 | + .id(space.getId()) |
| 59 | + .category(space.getCategory()) |
| 60 | + .fieldList(space.getFieldList()) |
| 61 | + .name(space.getName()) |
| 62 | + .introduction(space.getIntroduction()) |
| 63 | + .formId(space.getFormId()) |
| 64 | + .formTag(formTag) |
| 65 | + .memberCount(memberCount) |
| 66 | + .bannerUrl(space.getBannerUrl()) |
| 67 | + .createdAt(space.getCreatedAt()) |
| 68 | + .leader(leader) |
| 69 | + .build(); |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + @Builder |
| 74 | + @Schema(description = "스페이스 정보 응답 (회원 수 및 회고 수 포함)") |
| 75 | + public record SpaceWithMemberCountAndRetrospectCount( |
| 76 | + @Schema(description = "스페이스 ID") |
| 77 | + @NotNull |
| 78 | + Long id, |
| 79 | + @Schema(description = "프로젝트 유형 카테고리") |
| 80 | + @NotNull |
| 81 | + SpaceCategory category, |
| 82 | + @Schema(description = "진행중인 프로젝트 유형") |
| 83 | + @NotNull |
| 84 | + List<SpaceField> fieldList, |
| 85 | + @Schema(description = "이름") |
| 86 | + @NotNull |
| 87 | + String name, |
| 88 | + @Schema(description = "공간 설명") |
| 89 | + String introduction, |
| 90 | + @Schema(description = "설정된 회고 폼 아이디") |
| 91 | + Long formId, |
| 92 | + @Schema(description = "설정된 회고 폼 태그") |
| 93 | + String formTag, |
| 94 | + @Schema(description = "소속된 회원 수") |
| 95 | + Long memberCount, |
| 96 | + @Schema(description = "스페이스 배너 이미지") |
| 97 | + String bannerUrl, |
| 98 | + @Schema(description = "스페이스 생성 일자") |
| 99 | + LocalDateTime createdAt, |
| 100 | + @Schema(description = "스페이스 리더 아이디") |
| 101 | + Leader leader, |
| 102 | + @Schema(description = "누적 회고 수") |
| 103 | + Long retrospectCount, |
| 104 | + @Schema(description = "진행중인 회고 수") |
| 105 | + Long proceedingRetrospectCount |
| 106 | + |
| 107 | + ) { |
| 108 | + public static SpaceWithMemberCountAndRetrospectCount toResponse(SpaceWithMemberCount space, Long retrospectCount, |
| 109 | + Long proceedingRetrospectCount) { |
| 110 | + |
| 111 | + return SpaceWithMemberCountAndRetrospectCount.builder() |
| 112 | + .id(space.getId()) |
| 113 | + .category(space.getCategory()) |
| 114 | + .fieldList(space.getFieldList()) |
| 115 | + .name(space.getName()) |
| 116 | + .introduction(space.getIntroduction()) |
| 117 | + .formId(space.getFormId()) |
| 118 | + .formTag(space.getFormTag()) |
| 119 | + .memberCount(space.getMemberCount()) |
| 120 | + .bannerUrl(space.getBannerUrl()) |
| 121 | + .createdAt(space.getCreatedAt()) |
| 122 | + .leader(space.getLeader()) |
| 123 | + .retrospectCount(retrospectCount) |
| 124 | + .proceedingRetrospectCount(proceedingRetrospectCount) |
| 125 | + .build(); |
| 126 | + } |
| 127 | + } |
| 128 | + |
| 129 | + @Builder |
| 130 | + @Schema |
| 131 | + public record SpacePage( |
| 132 | + @Schema |
| 133 | + List<SpaceWithMemberCountAndRetrospectCount> data, |
| 134 | + |
| 135 | + @Schema |
| 136 | + Meta meta |
| 137 | + ) { |
| 138 | + |
| 139 | + public static SpacePage toResponse(List<SpaceWithMemberCountAndRetrospectCount> spaceInfo, Meta meta) { |
| 140 | + return SpacePage.builder().data(spaceInfo).meta(meta).build(); |
| 141 | + } |
| 142 | + } |
| 143 | + |
| 144 | + @Builder |
| 145 | + @Schema |
| 146 | + public record SpaceCreateResponse( |
| 147 | + @Schema(title = "생성된 스페이스 아이디", description = """ |
| 148 | + |
| 149 | + 생성 완료된 스페이스의 아이디 |
| 150 | + |
| 151 | + """) |
| 152 | + Long spaceId |
| 153 | + ) { |
| 154 | + } |
| 155 | + |
| 156 | + @Builder |
| 157 | + @Schema |
| 158 | + public record SpaceMemberResponse( |
| 159 | + @Schema(title = "맴버 아이디") |
| 160 | + Long id, |
| 161 | + @Schema(title = "멤버 프로필 사진") |
| 162 | + String avatar, |
| 163 | + |
| 164 | + @Schema(title = "멤버 이름") |
| 165 | + String name, |
| 166 | + |
| 167 | + @Schema(title = "스페이스 리더 여부") |
| 168 | + Boolean isLeader |
| 169 | + ) { |
| 170 | + public static SpaceMemberResponse of(Member member, boolean isLeader) { |
| 171 | + return SpaceMemberResponse |
| 172 | + .builder() |
| 173 | + .id(member.getId()) |
| 174 | + .name(member.getName()) |
| 175 | + .avatar(member.getProfileImageUrl()) |
| 176 | + .isLeader(isLeader) |
| 177 | + .build(); |
| 178 | + } |
| 179 | + } |
140 | 180 | } |
0 commit comments