Skip to content

Commit cd3e592

Browse files
authored
Merge 9b7b3ea into aad500b
2 parents aad500b + 9b7b3ea commit cd3e592

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

src/main/java/sevenstar/marineleisure/activity/service/ActivityService.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,25 +208,28 @@ public ActivityDetailResponse getActivityDetail(ActivityCategory activity, BigDe
208208
public ActivityWeatherResponse getWeatherBySpot(BigDecimal latitude, BigDecimal longitude) {
209209
OutdoorSpot nearSpot = outdoorSpotRepository.findByCoordinates(latitude, longitude, 1).getFirst();
210210

211-
Fishing fishingSpot = fishingRepository.findBySpotIdOrderByCreatedAt(nearSpot.getId()).get();
211+
Optional<Fishing> fishingSpot = fishingRepository.findBySpotIdOrderByCreatedAt(nearSpot.getId());
212+
213+
if (fishingSpot.isPresent()) {
214+
Fishing fishingSpotGet = fishingSpot.get();
212215

213-
if (fishingSpot != null) {
214216
return new ActivityWeatherResponse(
215217
nearSpot.getName(),
216-
fishingSpot.getWindSpeedMax().toString(),
217-
fishingSpot.getWaveHeightMax().toString(),
218-
fishingSpot.getSeaTempMax().toString()
218+
fishingSpotGet.getWindSpeedMax().toString(),
219+
fishingSpotGet.getWaveHeightMax().toString(),
220+
fishingSpotGet.getSeaTempMax().toString()
219221
);
220222
}
221223

222-
Surfing surfingSpot = surfingRepository.findBySpotIdOrderByCreatedAt(nearSpot.getId()).get();
224+
Optional<Surfing> surfingSpot = surfingRepository.findBySpotIdOrderByCreatedAt(nearSpot.getId());
223225

224-
if (surfingSpot != null) {
226+
if (surfingSpot.isPresent()) {
227+
Surfing surfingSpotGet = surfingSpot.get();
225228
return new ActivityWeatherResponse(
226229
nearSpot.getName(),
227-
surfingSpot.getWindSpeed().toString(),
228-
surfingSpot.getWaveHeight().toString(),
229-
surfingSpot.getSeaTemp().toString()
230+
surfingSpotGet.getWindSpeed().toString(),
231+
surfingSpotGet.getWaveHeight().toString(),
232+
surfingSpotGet.getSeaTemp().toString()
230233
);
231234
} else {
232235
throw new RuntimeException("Spot not found");

src/main/java/sevenstar/marineleisure/meeting/dto/mapper/MeetingMapper.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,14 @@ public Tag UpdateTag(UpdateMeetingRequest request, Tag tag) {
8383
.build();
8484
}
8585

86-
public MeetingDetailResponse MeetingDetailResponseMapper(Meeting targetMeeting, Member host,
86+
public MeetingDetailResponse MeetingDetailResponseMapper(Meeting targetMeeting, Member host,Integer currentParticipant,
8787
OutdoorSpot targetSpot, Tag targetTag) {
8888
return MeetingDetailResponse.builder()
8989
.id(targetMeeting.getId())
9090
.title(targetMeeting.getTitle())
9191
.category(targetMeeting.getCategory())
9292
.capacity(targetMeeting.getCapacity())
93+
.currentParticipants(currentParticipant)
9394
.hostId(targetMeeting.getHostId())
9495
.hostNickName(host.getNickname())
9596
.hostEmail(host.getEmail())
@@ -102,9 +103,7 @@ public MeetingDetailResponse MeetingDetailResponseMapper(Meeting targetMeeting,
102103
.meetingTime(targetMeeting.getMeetingTime())
103104
.status(targetMeeting.getStatus())
104105
.createdAt(targetMeeting.getCreatedAt())
105-
.tag(TagList.builder()
106-
.content(targetTag.getContent())
107-
.build())
106+
.tag(targetTag != null ? TagList.builder().content(targetTag.getContent()).build() : TagList.builder().content(Collections.emptyList()).build())
108107
.build();
109108
}
110109

src/main/java/sevenstar/marineleisure/meeting/dto/response/MeetingDetailResponse.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public record MeetingDetailResponse(
2929
String title,
3030
ActivityCategory category,
3131
long capacity,
32+
Integer currentParticipants,
3233
long hostId,
3334
String hostNickName,
3435
String hostEmail,

src/main/java/sevenstar/marineleisure/meeting/service/MeetingServiceImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,11 @@ public MeetingDetailResponse getMeetingDetails(Long meetingId) {
8282
Member host = memberValidate.foundMember(targetMeeting.getHostId());
8383
OutdoorSpot targetSpot = spotValidate.foundOutdoorSpot(targetMeeting.getSpotId());
8484
Tag targetTag = tagValidate.findByMeetingId(meetingId).orElse(null);
85+
Integer currentParticipants = participantRepository.countMeetingId(targetMeeting.getId()).orElseThrow(
86+
() -> new CustomException(ParticipantError.PARTICIPANT_NOT_FOUND)
87+
);
8588

86-
return meetingMapper.MeetingDetailResponseMapper(targetMeeting, host, targetSpot, targetTag);
89+
return meetingMapper.MeetingDetailResponseMapper(targetMeeting, host,currentParticipants,targetSpot, targetTag);
8790
}
8891

8992
@Override

0 commit comments

Comments
 (0)