Skip to content

Commit

Permalink
feat: 주최내역 초기화면 N명 신청대기 기능 구현 (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
ympark99 committed Sep 8, 2023
1 parent b88cb67 commit 70d8b3a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ public class HostListDto {

RecruitType recruitType;

Long waitingCount; // 신청 대기 수

@Builder
public HostListDto(Long sparkId, String placeName, Always always, LocalDateTime sparkDate,
DurationHour durationHour, Long memberCount, Long capacity,
Long price, String title, RecruitType recruitType) {
Long price, String title, RecruitType recruitType, Long waitingCount) {
this.sparkId = sparkId;
this.placeName = placeName;
this.always = always;
Expand All @@ -45,5 +47,6 @@ public HostListDto(Long sparkId, String placeName, Always always, LocalDateTime
this.price = price;
this.title = title;
this.recruitType = recruitType;
this.waitingCount = waitingCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Repository;

import com.onna.onnaback.domain.apply.domain.AcceptStatus;
import com.onna.onnaback.domain.apply.domain.MemberSparkMapping;
import com.onna.onnaback.domain.member.domain.Member;
import com.onna.onnaback.domain.place.adapter.out.persistence.PlaceRepository;
import com.onna.onnaback.domain.place.domain.Place;
Expand Down Expand Up @@ -150,6 +152,13 @@ public List<HostListDto> getHostList(Member host) {
List<HostListDto> hostListDtos = new ArrayList<>();

for (Spark spark : sparks) {
// 신청 대기 수 카운트
List<MemberSparkMapping> memberSparkMapping = spark.getMemberSparkMappingList();
Long waitingCount = memberSparkMapping.stream()
.filter(mapping -> mapping.getAcceptStatus()
== AcceptStatus.PENDING)
.count();

hostListDtos.add(new HostListDto(
spark.getSparkId(),
spark.getPlace().getName(),
Expand All @@ -160,7 +169,8 @@ public List<HostListDto> getHostList(Member host) {
spark.getCapacity(),
spark.getPrice(),
spark.getTitle(),
spark.getRecruitType()
spark.getRecruitType(),
waitingCount
));
}

Expand Down

0 comments on commit 70d8b3a

Please sign in to comment.