Skip to content

Commit 3596d39

Browse files
authored
fix : 파티 프론트 요청 사항 완료 (#68)
* fix : 요청사항 1차 완료 * fix : 요청 사항 2차 완료
1 parent c8300c2 commit 3596d39

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

backend/src/main/java/com/back/domain/party/party/controller/ApiV1PartyController.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.back.domain.party.party.controller;
22

3+
import com.back.domain.mission.entity.Mission;
34
import com.back.domain.mission.enums.MissionCategory;
45
import com.back.domain.party.party.dto.*;
56
import com.back.domain.party.party.entity.Party;
@@ -132,10 +133,16 @@ public ResponseEntity<ApiResponse<Page<PartyDto>>> getPublicParties(
132133
}
133134

134135
@GetMapping("/{partyId}")
135-
@Operation(summary = "특정 파티 조회", description = "특정 파티의 상세 정보를 조회하는 API")
136+
@Operation(summary = "파티 상세 조회", description = "특정 파티의 상세 정보를 조회하고 조회수를 1 증가시키는 API (미션ID 포함)")
136137
public ResponseEntity<ApiResponse<PartyDto>> getPartyDetails(@PathVariable Integer partyId) {
138+
// 1. 파티 정보 조회 및 조회수 증가
137139
Party party = partyService.getPartyDetails(partyId);
138-
PartyDto partyDto = new PartyDto(party);
140+
141+
// 2. 파티에 연결된 미션 정보 조회 (Service에 추가된 헬퍼 메서드 사용)
142+
Mission mission = partyService.getMissionByPartyId(partyId);
143+
144+
// 3. Party와 Mission 정보를 모두 DTO에 담아 반환
145+
PartyDto partyDto = new PartyDto(party, mission);
139146

140147
return ResponseEntity
141148
.status(HttpStatus.OK)

backend/src/main/java/com/back/domain/party/party/dto/PartyDto.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class PartyDto {
2323
private Integer maxMembers;
2424
private Boolean isPublic;
2525
private List<PartyMemberDto> members;
26+
private Integer missionId;
2627
private MissionCategory category;
2728
private LocalDate startDate;
2829
private LocalDate endDate;
@@ -46,6 +47,8 @@ public PartyDto(Party party, Mission mission) {
4647

4748
this.views = party.getViews();
4849

50+
this.missionId = mission != null ? mission.getId() : null;
51+
4952
if (mission != null) {
5053
this.category = mission.getCategory();
5154
this.startDate = mission.getStartDate();

backend/src/main/java/com/back/domain/party/party/service/PartyService.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,23 @@ public void deleteParty(Integer partyId, Integer memberId) {
210210
partyRepository.delete(party);
211211
}
212212

213-
@Cacheable(value = "partyList", key = "'all'")
214-
@Transactional(readOnly = true)
215-
public List<Party> getPartyList() {
216-
return partyRepository.findByIsPublic(true);
213+
@Cacheable(value = "partyDetails", key = "#partyId")
214+
@Transactional
215+
public Party getPartyDetails(Integer partyId) {
216+
Party party = partyRepository.findById(partyId)
217+
.orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND, "파티를 찾을 수 없습니다."));
218+
219+
party.incrementViews();
220+
221+
return party;
217222
}
218223

219-
@Cacheable(value = "partyDetails", key = "#partyId")
224+
@Cacheable(value = "missionByParty", key = "#partyId")
220225
@Transactional(readOnly = true)
221-
public Party getPartyDetails(Integer partyId) {
222-
return partyRepository.findById(partyId)
223-
.orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND, "해당 파티를 찾을 수 없습니다."));
226+
public Mission getMissionByPartyId(Integer partyId) {
227+
return missionRepository.findByPartyId(partyId).stream()
228+
.findFirst()
229+
.orElse(null);
224230
}
225231

226232
@Transactional

0 commit comments

Comments
 (0)