Skip to content

Commit

Permalink
feat: 상세 조회시, id 및 place 정보 반환하도록 구현, ACCEPT 상태만 리스트에 추가하도록 구현 (#64)
Browse files Browse the repository at this point in the history
* feat: 주최시 sparkId 리턴하도록 구현

* feat: 상세 조회시, id 및 place 정보 반환하도록 구현 (#14)

* feat: 상세 조회시, ACCEPT 상태인 멤버만 리스트에 추가되도록 구현 (#14)
  • Loading branch information
ympark99 authored Oct 2, 2023
1 parent fd2a530 commit 6ca0a57
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@AllArgsConstructor
public class SparkResponse {

long sparkId;
Long sparkId;

String title;

Expand Down Expand Up @@ -50,6 +50,10 @@ public class SparkResponse {

String detailAddress;

Long placeId;

String placeName;

Double lng;

Double lat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import javax.persistence.criteria.Join;
import javax.persistence.criteria.Predicate;

import com.onna.onnaback.domain.place.adapter.in.web.response.PlaceSearchDto;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Repository;
Expand Down Expand Up @@ -62,8 +61,10 @@ public List<SparkResponse> getSparkListByPlaceId(Pageable pageable, Long placeId
.sparkType(spark.getType())
.sparkDate(spark.getSparkDate())
.capacity(spark.getCapacity())
.memberCount((long) spark.getMemberSparkMappingList().size())
.price(spark.getPrice())
.memberCount(
(long) spark.getMemberSparkMappingList()
.size())
.price(spark.getPrice())
.hostName(spark.getHost().getName())
.hostDetail(spark.getHostDetail())
.hostImg(spark.getHost().getProfileImg())
Expand Down Expand Up @@ -182,6 +183,7 @@ public SparkResponse getSparkInfo(Long id) {
Spark spark = sparkRepository.findSparkAndHost(id);

return SparkResponse.builder()
.sparkId(spark.getSparkId())
.title(spark.getTitle())
.img(spark.getImg())
.sparkType(spark.getType())
Expand All @@ -194,58 +196,63 @@ public SparkResponse getSparkInfo(Long id) {
.hostDetail(spark.getHostDetail())
.memberCount(spark.getMemberCount())
.recruitType(spark.getRecruitType())
.placeId(spark.getPlace().getPlaceId())
.placeName(spark.getPlace().getName())
.lng(spark.getPlace().getLongitude())
.lat(spark.getPlace().getLatitude())
.detailAddress(spark.getPlace().getDetailAddress())
.participateMember(
spark.getMemberSparkMappingList()
.stream().map(
memberSparkMapping -> ParticipateMemberDto.builder()
.memberId(
memberSparkMapping.getApplicant()
.getMemberId())
.profileImg(
memberSparkMapping.getApplicant()
.getProfileImg())
.build()
).collect(Collectors.toList()))
.stream()
.filter(memberSparkMapping -> memberSparkMapping.getAcceptStatus()
== AcceptStatus.ACCEPT)
.map(
memberSparkMapping -> ParticipateMemberDto.builder()
.memberId(
memberSparkMapping.getApplicant()
.getMemberId())
.profileImg(
memberSparkMapping.getApplicant()
.getProfileImg())
.build()
).collect(Collectors.toList()))
.build();
}

@Override
public List<SparkResponse> searchSpark(String value) {
return sparkRepository.findByTitleContaining(value).stream().map(
spark -> SparkResponse.builder()
.sparkId(spark.getSparkId())
.sparkDate(spark.getSparkDate())
.sparkType(spark.getType())
.memberCount(spark.getMemberCount())
.hostImg(spark.getHost().getProfileImg())
.img(spark.getImg())
.durationHour(spark.getDurationHour())
.detailAddress(spark.getPlace().getDetailAddress())
.hostName(spark.getHost().getName())
.hostDetail(spark.getHostDetail())
.recruitType(spark.getRecruitType())
.capacity(spark.getCapacity())
.title(spark.getTitle())
.price(spark.getPrice())
.description(spark.getDescription())
.lat(spark.getPlace().getLatitude())
.lng(spark.getPlace().getLatitude())
.participateMember(
spark.getMemberSparkMappingList()
.stream().map(
memberSparkMapping -> ParticipateMemberDto.builder()
.memberId(
memberSparkMapping.getApplicant()
.getMemberId())
.profileImg(
memberSparkMapping.getApplicant()
.getProfileImg())
.build()
).collect(Collectors.toList()))
.build()
.sparkId(spark.getSparkId())
.sparkDate(spark.getSparkDate())
.sparkType(spark.getType())
.memberCount(spark.getMemberCount())
.hostImg(spark.getHost().getProfileImg())
.img(spark.getImg())
.durationHour(spark.getDurationHour())
.detailAddress(spark.getPlace().getDetailAddress())
.hostName(spark.getHost().getName())
.hostDetail(spark.getHostDetail())
.recruitType(spark.getRecruitType())
.capacity(spark.getCapacity())
.title(spark.getTitle())
.price(spark.getPrice())
.description(spark.getDescription())
.lat(spark.getPlace().getLatitude())
.lng(spark.getPlace().getLatitude())
.participateMember(
spark.getMemberSparkMappingList()
.stream().map(
memberSparkMapping -> ParticipateMemberDto.builder()
.memberId(
memberSparkMapping.getApplicant()
.getMemberId())
.profileImg(
memberSparkMapping.getApplicant()
.getProfileImg())
.build()
).collect(Collectors.toList()))
.build()
).collect(Collectors.toList());
}

Expand Down

0 comments on commit 6ca0a57

Please sign in to comment.