Skip to content

Commit 90d0f67

Browse files
authored
Merge pull request #152 from prgrms-web-devcourse-final-project/refactor/party
Refactor/party
2 parents d9c0d45 + 90d2787 commit 90d0f67

File tree

14 files changed

+284
-107
lines changed

14 files changed

+284
-107
lines changed

src/main/java/com/ddobang/backend/domain/board/dto/response/AdminAttachmentResponse.java

-17
This file was deleted.

src/main/java/com/ddobang/backend/domain/board/dto/response/AdminPostDetailResponse.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public record AdminPostDetailResponse(
1212
PostType type,
1313
String title,
1414
String content,
15-
List<AdminAttachmentResponse> attachments,
15+
List<AttachmentResponse> attachments,
1616
List<PostReplyDto> replies,
1717
LocalDateTime createdAt
1818
) {
@@ -22,7 +22,7 @@ public static AdminPostDetailResponse from(Post post) {
2222
post.getType(),
2323
post.getTitle(),
2424
post.getContent(),
25-
post.getAttachments().stream().map(AdminAttachmentResponse::from).toList(),
25+
post.getAttachments().stream().map(AttachmentResponse::from).toList(),
2626
post.isAnswered() ? post.getReplies().stream().map(PostReplyDto::from).toList() : null,
2727
post.getCreatedAt()
2828
);

src/main/java/com/ddobang/backend/domain/board/dto/response/AttachmentResponse.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
public record AttachmentResponse(
66
Long id,
7-
String fileName
7+
String fileName,
8+
String url
89
) {
910
public static AttachmentResponse from(Attachment attachment) {
1011
return new AttachmentResponse(
1112
attachment.getId(),
12-
attachment.getFileName()
13+
attachment.getFileName(),
14+
attachment.getUrl()
1315
);
1416
}
1517
}

src/main/java/com/ddobang/backend/domain/party/controller/PartyController.java

+17-9
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@
1717
import org.springframework.web.bind.annotation.RequestParam;
1818
import org.springframework.web.bind.annotation.RestController;
1919

20-
import com.ddobang.backend.domain.member.entity.Member;
2120
import com.ddobang.backend.domain.member.types.KeywordType;
2221
import com.ddobang.backend.domain.member.types.MemberReviewKeyword;
2322
import com.ddobang.backend.domain.party.dto.PartyDto;
2423
import com.ddobang.backend.domain.party.dto.request.PartyMemberReviewRequest;
2524
import com.ddobang.backend.domain.party.dto.request.PartyRequest;
2625
import com.ddobang.backend.domain.party.dto.request.PartySearchCondition;
26+
import com.ddobang.backend.domain.party.dto.response.MyJoinedPartySummaryResponse;
2727
import com.ddobang.backend.domain.party.dto.response.PartyDetailResponse;
2828
import com.ddobang.backend.domain.party.dto.response.PartyMainResponse;
2929
import com.ddobang.backend.domain.party.dto.response.PartySummaryResponse;
3030
import com.ddobang.backend.domain.party.service.PartyService;
31+
import com.ddobang.backend.domain.party.types.PartyMemberRole;
32+
import com.ddobang.backend.domain.party.types.PartyTodoFilter;
3133
import com.ddobang.backend.global.response.PageDto;
3234
import com.ddobang.backend.global.response.ResponseFactory;
3335
import com.ddobang.backend.global.response.SliceDto;
@@ -132,19 +134,25 @@ public ResponseEntity<Void> unexecuteParty(@PathVariable Long id) {
132134
}
133135

134136
@GetMapping("/joins/{id}")
135-
@Operation(summary = "참여한 모임 목록 조회")
136-
public ResponseEntity<SuccessResponse<PageDto<PartySummaryResponse>>> getJoinedParties(
137+
@Operation(summary = "다른 사람의 참여한 모임 목록 조회")
138+
public ResponseEntity<SuccessResponse<PageDto<PartySummaryResponse>>> getOtherJoinedParties(
137139
@RequestParam(defaultValue = "0") int page,
138140
@RequestParam(defaultValue = "10") int size,
139141
@PathVariable Long id
140142
) {
141-
Member actor = loginMemberProvider.getCurrentMember();
143+
return ResponseFactory.ok(partyService.getOtherJoinedParties(id, page, size));
144+
}
142145

143-
if (id.equals(actor.getId())) {
144-
return ResponseFactory.ok(partyService.getMyJoinedParties(actor, page, size));
145-
} else {
146-
return ResponseFactory.ok(partyService.getOtherJoinedParties(id, page, size));
147-
}
146+
@GetMapping("/joins/me")
147+
@Operation(summary = "내가 참여한 모임 목록 조회")
148+
public ResponseEntity<SuccessResponse<PageDto<MyJoinedPartySummaryResponse>>> getMyJoinedParties(
149+
@RequestParam(required = false) PartyMemberRole role,
150+
@RequestParam(defaultValue = "NONE") PartyTodoFilter todoFilter,
151+
@RequestParam(defaultValue = "0") int page,
152+
@RequestParam(defaultValue = "10") int size
153+
) {
154+
return ResponseFactory.ok(
155+
partyService.getMyJoinedParties(loginMemberProvider.getCurrentMember(), role, todoFilter, page, size));
148156
}
149157

150158
// 모임원 평가

src/main/java/com/ddobang/backend/domain/party/dto/request/PartyMemberReviewRequest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.util.List;
44

55
public record PartyMemberReviewRequest(
6-
Long targetId,
6+
String targetNickname,
77
List<String> reviewKeywords,
88
boolean noShow
99
) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.ddobang.backend.domain.party.dto.response;
2+
3+
import java.time.LocalDateTime;
4+
5+
import com.ddobang.backend.domain.member.entity.Member;
6+
import com.ddobang.backend.domain.party.entity.Party;
7+
import com.ddobang.backend.domain.party.types.PartyMemberRole;
8+
import com.ddobang.backend.domain.party.types.PartyStatus;
9+
import com.ddobang.backend.domain.store.entity.Store;
10+
import com.ddobang.backend.domain.theme.entity.Theme;
11+
12+
public record MyJoinedPartySummaryResponse(
13+
Long partyId,
14+
String title,
15+
LocalDateTime scheduledAt,
16+
Integer acceptedParticipantsCount,
17+
Integer totalParticipants,
18+
Boolean rookieAvailable,
19+
String storeName,
20+
Long themeId,
21+
String themeName,
22+
String themeThumbnailUrl,
23+
Long hostId,
24+
String hostNickname,
25+
String hostProfilePictureUrl,
26+
PartyMemberRole role,
27+
Boolean reviewed,
28+
PartyStatus status
29+
) {
30+
public static MyJoinedPartySummaryResponse from(Party party, Member actor, boolean reviewed) {
31+
Theme theme = party.getTheme();
32+
Member host = party.getHost();
33+
Store store = theme.getStore();
34+
35+
return new MyJoinedPartySummaryResponse(
36+
party.getId(),
37+
party.getTitle(),
38+
party.getScheduledAt(),
39+
party.getTotalParticipants() - party.getParticipantsNeeded() + party.getAcceptedParticipantsCount(),
40+
party.getTotalParticipants(),
41+
party.getRookieAvailable(),
42+
store.getName(),
43+
theme.getId(),
44+
theme.getName(),
45+
theme.getThumbnailUrl(),
46+
host.getId(),
47+
host.getNickname(),
48+
host.getProfilePictureUrl(),
49+
50+
party.getPartyMemberRole(actor),
51+
reviewed,
52+
party.getStatus()
53+
);
54+
}
55+
}

src/main/java/com/ddobang/backend/domain/party/repository/PartyRepositoryCustom.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@
77

88
import com.ddobang.backend.domain.member.entity.Member;
99
import com.ddobang.backend.domain.party.dto.request.PartySearchCondition;
10+
import com.ddobang.backend.domain.party.dto.response.MyJoinedPartySummaryResponse;
1011
import com.ddobang.backend.domain.party.dto.response.PartySummaryResponse;
12+
import com.ddobang.backend.domain.party.types.PartyMemberRole;
13+
import com.ddobang.backend.domain.party.types.PartyTodoFilter;
1114
import com.ddobang.backend.domain.theme.entity.Theme;
1215

1316
public interface PartyRepositoryCustom {
1417
List<PartySummaryResponse> getParties(Long lastId, int size, PartySearchCondition partySearchCondition);
1518

1619
List<PartySummaryResponse> getPartiesByTheme(Theme theme, Long lastId, int size);
1720

18-
Page<PartySummaryResponse> findByMemberJoined(Member member, Pageable pageable, boolean myList);
21+
Page<PartySummaryResponse> findOtherMemberJoinedParties(Member member, Pageable pageable);
22+
23+
Page<MyJoinedPartySummaryResponse> findMyPartyHistories(Member member, PartyMemberRole role,
24+
PartyTodoFilter todoFilter, Pageable pageable);
1925
}

0 commit comments

Comments
 (0)