From 05c65ed6cfb85ce704883a55ed5fcce4c53bb357 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sat, 3 Aug 2024 02:28:52 +0900 Subject: [PATCH 01/11] =?UTF-8?q?feat=20:=20GetCrewInquiryResponse=20?= =?UTF-8?q?=ED=81=AC=EB=A3=A8=20=EC=A1=B0=ED=9A=8C=20response=20dto=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/crew/GetCrewInquiryResponse.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/java/com/example/likelion12/dto/crew/GetCrewInquiryResponse.java diff --git a/src/main/java/com/example/likelion12/dto/crew/GetCrewInquiryResponse.java b/src/main/java/com/example/likelion12/dto/crew/GetCrewInquiryResponse.java new file mode 100644 index 0000000..63b3b99 --- /dev/null +++ b/src/main/java/com/example/likelion12/dto/crew/GetCrewInquiryResponse.java @@ -0,0 +1,19 @@ +package com.example.likelion12.dto.crew; + +import com.example.likelion12.domain.base.BaseLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class GetCrewInquiryResponse { + /** + * 크루 조회 response dto + */ + private String crewName; + private String crewImg; + private String activityRegionName; + private String exerciseName; + private BaseLevel level; + private String commentSimple; +} From 5feb7e06e83b438e9118c7aabe4c1dd0b01260c5 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sat, 3 Aug 2024 02:29:16 +0900 Subject: [PATCH 02/11] =?UTF-8?q?feat=20:=20CrewService.getCrewInquiries?= =?UTF-8?q?=20=ED=81=AC=EB=A3=A8=EC=A1=B0=ED=9A=8C=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../likelion12/service/CrewService.java | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/example/likelion12/service/CrewService.java b/src/main/java/com/example/likelion12/service/CrewService.java index aeedf57..2bb5a6c 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.java @@ -4,22 +4,22 @@ import com.example.likelion12.domain.*; import com.example.likelion12.domain.base.BaseGender; import com.example.likelion12.domain.base.BaseLevel; -import com.example.likelion12.domain.base.BaseRole; import com.example.likelion12.domain.base.BaseStatus; import com.example.likelion12.dto.crew.GetCrewDetailResponse; +import com.example.likelion12.dto.crew.GetCrewInquiryResponse; import com.example.likelion12.dto.crew.PostCrewRequest; import com.example.likelion12.dto.crew.PostCrewResponse; import com.example.likelion12.repository.*; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Pageable; -import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import javax.swing.undo.CannotRedoException; +import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import static com.example.likelion12.common.response.status.BaseExceptionResponseStatus.*; @@ -77,6 +77,35 @@ public PostCrewResponse createCrew(Long memberId, PostCrewRequest postCrewReques return new PostCrewResponse(crew.getCrewId()); } + /** + * 크루 조회 + */ + public List getCrewInquiries(Long memberId, List crewIds) { + log.info("[CrewService.getCrewInquiries]"); + + List getCrewInquiryResponses = new ArrayList<>(); + + for (Long crewId : crewIds) { + // 조회하고자 하는 크루 + Optional optionalCrew = crewRepository.findByCrewIdAndStatus(crewId, BaseStatus.ACTIVE); + + // 크루가 존재할 경우에만 응답 리스트에 추가 + optionalCrew.ifPresent(crew -> { + GetCrewInquiryResponse response = new GetCrewInquiryResponse( + crew.getCrewName(), + crew.getCrewImg(), + crew.getActivityRegion().getActivityRegionName(), + crew.getExercise().getExerciseName(), + crew.getLevel(), + crew.getCommentSimple() + ); + getCrewInquiryResponses.add(response); + }); + } + + return getCrewInquiryResponses; + } + /** * 크루 상세 조회 */ @@ -151,4 +180,5 @@ public void joinCrew(Long memberId, Long crewId){ throw new CrewException(ALREADY_FULL_CREW); } } + } From 85f88d490d2b8599b4a73d2c1eea6bb79e069f2b Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sat, 3 Aug 2024 02:29:44 +0900 Subject: [PATCH 03/11] =?UTF-8?q?feat=20:=20CrewController.getCrewInquirie?= =?UTF-8?q?s=20=ED=81=AC=EB=A3=A8=EC=A1=B0=ED=9A=8C=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../likelion12/controller/CrewController.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/example/likelion12/controller/CrewController.java b/src/main/java/com/example/likelion12/controller/CrewController.java index 77f0cf3..956adf2 100644 --- a/src/main/java/com/example/likelion12/controller/CrewController.java +++ b/src/main/java/com/example/likelion12/controller/CrewController.java @@ -2,6 +2,7 @@ import com.example.likelion12.common.response.BaseResponse; import com.example.likelion12.dto.crew.GetCrewDetailResponse; +import com.example.likelion12.dto.crew.GetCrewInquiryResponse; import com.example.likelion12.dto.crew.PostCrewRequest; import com.example.likelion12.dto.crew.PostCrewResponse; import com.example.likelion12.service.CrewService; @@ -10,6 +11,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; +import java.util.List; + @Slf4j @RestController @RequiredArgsConstructor @@ -29,6 +32,17 @@ public BaseResponse createCrew(@RequestHeader("Authorization") Long memberId = jwtProvider.extractIdFromHeader(authorization); return new BaseResponse<>(crewService.createCrew(memberId, postCrewRequest)); } + /** + * 크루 조회 + */ + @GetMapping("/inquiry") + public BaseResponse> getCrewInquiries(@RequestHeader("Authorization") String authorization, + @RequestParam List crewId){ + log.info("[CrewController.getCrewInquiries]"); + Long memberId = jwtProvider.extractIdFromHeader(authorization); + return new BaseResponse<>(crewService.getCrewInquiries(memberId, crewId)); + } + /** * 크루 상세 조회 @@ -53,4 +67,5 @@ public BaseResponse joinCrew(@RequestHeader("Authorization") String author return new BaseResponse<>(null); } + } From b49cbac6f06f837fc3471700057ba635a1c0997e Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sat, 3 Aug 2024 02:36:34 +0900 Subject: [PATCH 04/11] =?UTF-8?q?fix=20:=20CrewService.getCrewInquiries=20?= =?UTF-8?q?=ED=81=AC=EB=A3=A8=EC=A1=B0=ED=9A=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../likelion12/service/CrewService.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/example/likelion12/service/CrewService.java b/src/main/java/com/example/likelion12/service/CrewService.java index 2bb5a6c..d8de2bc 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.java @@ -86,21 +86,21 @@ public List getCrewInquiries(Long memberId, List c List getCrewInquiryResponses = new ArrayList<>(); for (Long crewId : crewIds) { - // 조회하고자 하는 크루 - Optional optionalCrew = crewRepository.findByCrewIdAndStatus(crewId, BaseStatus.ACTIVE); - - // 크루가 존재할 경우에만 응답 리스트에 추가 - optionalCrew.ifPresent(crew -> { - GetCrewInquiryResponse response = new GetCrewInquiryResponse( - crew.getCrewName(), - crew.getCrewImg(), - crew.getActivityRegion().getActivityRegionName(), - crew.getExercise().getExerciseName(), - crew.getLevel(), - crew.getCommentSimple() - ); - getCrewInquiryResponses.add(response); - }); + + //조회하고자 하는 크루 + Crew crew = crewRepository.findByCrewIdAndStatus(crewId, BaseStatus.ACTIVE) + .orElseThrow(() -> new CrewException(CANNOT_FOUND_CREW)); + + GetCrewInquiryResponse response = new GetCrewInquiryResponse( + crew.getCrewName(), + crew.getCrewImg(), + crew.getActivityRegion().getActivityRegionName(), + crew.getExercise().getExerciseName(), + crew.getLevel(), + crew.getCommentSimple() + ); + + getCrewInquiryResponses.add(response); } return getCrewInquiryResponses; From b8632338946ff299ec39a3d0223db9925e07754c Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sat, 3 Aug 2024 02:37:39 +0900 Subject: [PATCH 05/11] =?UTF-8?q?fix=20:=20CrewService.getCrewInquiries=20?= =?UTF-8?q?=ED=81=AC=EB=A3=A8=EC=A1=B0=ED=9A=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/example/likelion12/service/CrewService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/example/likelion12/service/CrewService.java b/src/main/java/com/example/likelion12/service/CrewService.java index d8de2bc..fe50259 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.java @@ -19,7 +19,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Optional; import java.util.stream.Collectors; import static com.example.likelion12.common.response.status.BaseExceptionResponseStatus.*; From 63999109f2f0006fd01b2cadde69d2e3eac77cea Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sat, 3 Aug 2024 17:31:22 +0900 Subject: [PATCH 06/11] =?UTF-8?q?feat=20:=20=EC=86=8C=EC=85=9C=EB=A7=81=20?= =?UTF-8?q?=EA=B2=80=EC=83=89=EA=B2=B0=EA=B3=BC=20=ED=95=84=ED=84=B0?= =?UTF-8?q?=EB=A7=81=20request,=20response=20dto=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GetSocialringSearchFilterRequest.java | 25 +++++++++++++++++++ .../GetSocialringSearchFilterResponse.java | 15 +++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/main/java/com/example/likelion12/dto/socialring/GetSocialringSearchFilterRequest.java create mode 100644 src/main/java/com/example/likelion12/dto/socialring/GetSocialringSearchFilterResponse.java diff --git a/src/main/java/com/example/likelion12/dto/socialring/GetSocialringSearchFilterRequest.java b/src/main/java/com/example/likelion12/dto/socialring/GetSocialringSearchFilterRequest.java new file mode 100644 index 0000000..2b882e2 --- /dev/null +++ b/src/main/java/com/example/likelion12/dto/socialring/GetSocialringSearchFilterRequest.java @@ -0,0 +1,25 @@ +package com.example.likelion12.dto.socialring; + +import com.example.likelion12.domain.base.BaseGender; +import com.example.likelion12.domain.base.BaseLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; + + +@Getter +@AllArgsConstructor +public class GetSocialringSearchFilterRequest { + + /** + * 소셜링 검색결과 필터링 request dto + */ + + private String exerciseName; + private BaseGender gender; + private BaseLevel level; + private Integer socialringCostMin; + private Integer socialringCostMax; + private Integer totalRecruitsMin; + private Integer totalRecruitsMax; + +} diff --git a/src/main/java/com/example/likelion12/dto/socialring/GetSocialringSearchFilterResponse.java b/src/main/java/com/example/likelion12/dto/socialring/GetSocialringSearchFilterResponse.java new file mode 100644 index 0000000..ba714a9 --- /dev/null +++ b/src/main/java/com/example/likelion12/dto/socialring/GetSocialringSearchFilterResponse.java @@ -0,0 +1,15 @@ +package com.example.likelion12.dto.socialring; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class GetSocialringSearchFilterResponse { + + /** + * 소셜링 검색결과필터링 response dto + */ + private long socialringId; + +} From 03b83027d4720b8c1c8924ba80790a747f471ad6 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sat, 3 Aug 2024 18:39:21 +0900 Subject: [PATCH 07/11] =?UTF-8?q?feat=20:=20SocialringController.searchFil?= =?UTF-8?q?terSocialring=20=EC=86=8C=EC=85=9C=EB=A7=81=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=EA=B2=B0=EA=B3=BC=20=ED=95=84=ED=84=B0=EB=A7=81=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SocialringController.java | 19 +++++++++++++++---- .../likelion12/service/CrewService.java | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/example/likelion12/controller/SocialringController.java b/src/main/java/com/example/likelion12/controller/SocialringController.java index e4c8f37..31a1c71 100644 --- a/src/main/java/com/example/likelion12/controller/SocialringController.java +++ b/src/main/java/com/example/likelion12/controller/SocialringController.java @@ -2,16 +2,16 @@ import com.example.likelion12.common.response.BaseResponse; import com.example.likelion12.common.response.status.BaseExceptionResponseStatus; -import com.example.likelion12.dto.socialring.GetSocialringDetailResponse; -import com.example.likelion12.dto.socialring.PatchSocialringModifyRequest; -import com.example.likelion12.dto.socialring.PostSocialringRequest; -import com.example.likelion12.dto.socialring.PostSocialringResponse; +import com.example.likelion12.dto.crew.GetCrewInquiryResponse; +import com.example.likelion12.dto.socialring.*; import com.example.likelion12.service.SocialringService; import com.example.likelion12.util.*; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; +import java.util.List; + @Slf4j @RestController @RequiredArgsConstructor @@ -66,4 +66,15 @@ public BaseResponse joinSocialring(@RequestHeader("Authorization") String socialringService.joinSocialring(memberId, socialringId); return new BaseResponse<>(BaseExceptionResponseStatus.SUCCESS, null); } + + /** + * 소셜링 검색결과 필터링 + */ + @GetMapping("/search/filter") + public BaseResponse> searchFilterSocialring(@RequestHeader("Authorization") String authorization, + @RequestBody GetSocialringSearchFilterRequest getSocialringSearchFilterRequest){ + log.info("[SocialringController.searchFilterSocialring]"); + Long memberId = jwtProvider.extractIdFromHeader(authorization); + return new BaseResponse<>(socialringService.searchFilterSocialring(memberId, getSocialringSearchFilterRequest)); + } } diff --git a/src/main/java/com/example/likelion12/service/CrewService.java b/src/main/java/com/example/likelion12/service/CrewService.java index fe50259..50333f6 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.java @@ -158,7 +158,7 @@ public void joinCrew(Long memberId, Long crewId){ //크루 아이디로 참여하려는 크루 찾기 if(memberCrewRepository.existsByMember_MemberIdAndCrew_CrewIdAndStatus(memberId,crewId, BaseStatus.ACTIVE)){ - throw new MemberCrewException(ALREADY_EXIST); + throw new MemberCrewException(ALREADY_EXIST_IN_CREW); } Crew crew = crewRepository.findByCrewIdAndStatus(crewId, BaseStatus.ACTIVE) .orElseThrow(()->new CrewException(CANNOT_FOUND_CREW)); From 4623cad65549ee37fe525dd1d7fd8f3d9d6b0d22 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sat, 3 Aug 2024 18:39:39 +0900 Subject: [PATCH 08/11] =?UTF-8?q?feat=20:=20SocialringRepository.findAllBy?= =?UTF-8?q?Status=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/likelion12/repository/SocialringRepository.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/example/likelion12/repository/SocialringRepository.java b/src/main/java/com/example/likelion12/repository/SocialringRepository.java index c71a7b2..2bb9cf5 100644 --- a/src/main/java/com/example/likelion12/repository/SocialringRepository.java +++ b/src/main/java/com/example/likelion12/repository/SocialringRepository.java @@ -23,4 +23,5 @@ public interface SocialringRepository extends JpaRepository { @Query("SELECT c FROM Socialring c WHERE c.activityRegion.id = :activityRegionId AND c.status = :status ORDER BY c.socialringId ASC") List findTop3ByActivityRegionIdAndStatus(@Param("activityRegionId") Long activityRegionId, @Param("status") BaseStatus status, Pageable pageable); + List findAllByStatus(BaseStatus baseStatus); } From 146257e6c03604a64fbf68ac43e67fca6fd3bb04 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sat, 3 Aug 2024 18:40:00 +0900 Subject: [PATCH 09/11] =?UTF-8?q?feat=20:=20SocialringService.searchFilter?= =?UTF-8?q?Socialring=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../likelion12/service/SocialringService.java | 94 ++++++++++++++++++- 1 file changed, 90 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/example/likelion12/service/SocialringService.java b/src/main/java/com/example/likelion12/service/SocialringService.java index 45be792..0cadbb0 100644 --- a/src/main/java/com/example/likelion12/service/SocialringService.java +++ b/src/main/java/com/example/likelion12/service/SocialringService.java @@ -5,10 +5,7 @@ import com.example.likelion12.domain.base.BaseGender; import com.example.likelion12.domain.base.BaseLevel; import com.example.likelion12.domain.base.BaseStatus; -import com.example.likelion12.dto.socialring.GetSocialringDetailResponse; -import com.example.likelion12.dto.socialring.PatchSocialringModifyRequest; -import com.example.likelion12.dto.socialring.PostSocialringRequest; -import com.example.likelion12.dto.socialring.PostSocialringResponse; +import com.example.likelion12.dto.socialring.*; import com.example.likelion12.repository.*; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -17,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional; import java.time.LocalDate; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -228,4 +226,92 @@ public void joinSocialring(Long memberId, Long socialringId) { throw new SocialringException(ALREADY_FULL_SOCIALRING); } } + + /** + * 소셜링 검색결과 필터링 + */ + @Transactional + public List searchFilterSocialring + (Long memberId, GetSocialringSearchFilterRequest getSocialringSearchFilterRequest) { + log.info("[SocialringService.searchFilterSocialring]"); + + // 전체 소셜링 목록 조회 + List allSocialrings = socialringRepository.findAllByStatus(BaseStatus.ACTIVE); + List responseList = new ArrayList<>(); + + // 요청값의 범위 확인 후 필터링 + for (Socialring socialring : allSocialrings) { + boolean matchesCriteria = true; + + if (getSocialringSearchFilterRequest.getExerciseName() != null) { + if (!socialring.getExercise().getExerciseName().equals(getSocialringSearchFilterRequest.getExerciseName())) { + matchesCriteria = false; + } + } + if (matchesCriteria && getSocialringSearchFilterRequest.getGender() != null) { + if (!socialring.getGender().equals(getSocialringSearchFilterRequest.getGender())) { + matchesCriteria = false; + } + } + if (matchesCriteria && getSocialringSearchFilterRequest.getLevel() != null) { + if (!socialring.getLevel().equals(getSocialringSearchFilterRequest.getLevel())) { + matchesCriteria = false; + } + } + + // 최소, 최대 범위가 둘 다 들어왔을 때 + if (matchesCriteria && getSocialringSearchFilterRequest.getSocialringCostMin() != null && getSocialringSearchFilterRequest.getSocialringCostMax() != null) { + if (!(socialring.getSocialringCost() >= getSocialringSearchFilterRequest.getSocialringCostMin() + && socialring.getSocialringCost() <= getSocialringSearchFilterRequest.getSocialringCostMax())) { + matchesCriteria = false; + } + } + // 최소 범위만 들어왔을 때 + else if (matchesCriteria && getSocialringSearchFilterRequest.getSocialringCostMin() != null) { + if (socialring.getSocialringCost() < getSocialringSearchFilterRequest.getSocialringCostMin()) { + matchesCriteria = false; + } + } + // 최대 범위만 들어왔을 때 + else if (matchesCriteria && getSocialringSearchFilterRequest.getSocialringCostMax() != null) { + if (socialring.getSocialringCost() > getSocialringSearchFilterRequest.getSocialringCostMax()) { + matchesCriteria = false; + } + } + + // 최소, 최대 모집 인원 범위가 둘 다 들어왔을 때 + if (matchesCriteria && getSocialringSearchFilterRequest.getTotalRecruitsMin() != null && getSocialringSearchFilterRequest.getTotalRecruitsMax() != null) { + if (!(socialring.getTotalRecruits() >= getSocialringSearchFilterRequest.getTotalRecruitsMin() + && socialring.getTotalRecruits() <= getSocialringSearchFilterRequest.getTotalRecruitsMax())) { + matchesCriteria = false; + } + } + // 최소 모집 인원만 들어왔을 때 + else if (matchesCriteria && getSocialringSearchFilterRequest.getTotalRecruitsMin() != null) { + if (socialring.getTotalRecruits() < getSocialringSearchFilterRequest.getTotalRecruitsMin()) { + matchesCriteria = false; + } + } + // 최대 모집 인원만 들어왔을 때 + else if (matchesCriteria && getSocialringSearchFilterRequest.getTotalRecruitsMax() != null) { + if (socialring.getTotalRecruits() > getSocialringSearchFilterRequest.getTotalRecruitsMax()) { + matchesCriteria = false; + } + } + + // 조건에 맞으면 응답 리스트에 추가 + if (matchesCriteria) { + GetSocialringSearchFilterResponse response = + new GetSocialringSearchFilterResponse(socialring.getSocialringId()); + responseList.add(response); + } + } + + // 해당하는 소셜링 리스트가 하나도 없을 때 예외 처리 + if (responseList.isEmpty()) { + throw new SocialringException(CANNOT_FOUND_SOCIALRING); + } + + return responseList; + } } From bb0b82d3d3112ff4ea2a43453a8b06343effbf42 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sun, 4 Aug 2024 16:49:31 +0900 Subject: [PATCH 10/11] =?UTF-8?q?fix=20:=20response=20dto=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GetSocialringSearchFilterResponse.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/example/likelion12/dto/socialring/GetSocialringSearchFilterResponse.java b/src/main/java/com/example/likelion12/dto/socialring/GetSocialringSearchFilterResponse.java index ba714a9..974dc0f 100644 --- a/src/main/java/com/example/likelion12/dto/socialring/GetSocialringSearchFilterResponse.java +++ b/src/main/java/com/example/likelion12/dto/socialring/GetSocialringSearchFilterResponse.java @@ -1,8 +1,13 @@ package com.example.likelion12.dto.socialring; +import com.example.likelion12.domain.base.BaseGender; +import com.example.likelion12.domain.base.BaseLevel; +import com.example.likelion12.domain.base.BaseRole; import lombok.AllArgsConstructor; import lombok.Getter; +import java.time.LocalDate; + @Getter @AllArgsConstructor public class GetSocialringSearchFilterResponse { @@ -10,6 +15,14 @@ public class GetSocialringSearchFilterResponse { /** * 소셜링 검색결과필터링 response dto */ - private long socialringId; + private Long socialringId; + private String socialringName; + private String socialringImg; + private String activityRegionName; + private LocalDate socialringDate; + private int socialringCost; + private String commentSimple; + private int currentRecruits; + private int totalRecruits; } From 6875aec71d1b2dfa8791892db725c2cbd49ec0c4 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sun, 4 Aug 2024 16:49:53 +0900 Subject: [PATCH 11/11] =?UTF-8?q?fix=20:=20response=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=EA=B0=92=20=EC=88=98=EC=A0=95=EC=97=90=20=EB=94=B0=EB=A5=B8=20?= =?UTF-8?q?=EC=84=9C=EB=B9=84=EC=8A=A4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/likelion12/service/SocialringService.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/example/likelion12/service/SocialringService.java b/src/main/java/com/example/likelion12/service/SocialringService.java index 0cadbb0..de2a654 100644 --- a/src/main/java/com/example/likelion12/service/SocialringService.java +++ b/src/main/java/com/example/likelion12/service/SocialringService.java @@ -239,6 +239,7 @@ public void joinSocialring(Long memberId, Long socialringId) { List allSocialrings = socialringRepository.findAllByStatus(BaseStatus.ACTIVE); List responseList = new ArrayList<>(); + // 요청값의 범위 확인 후 필터링 for (Socialring socialring : allSocialrings) { boolean matchesCriteria = true; @@ -299,10 +300,17 @@ else if (matchesCriteria && getSocialringSearchFilterRequest.getTotalRecruitsMax } } + // 현재 참여중인 소셜링원 수 확인하기 + int currentSocialrings = memberSocialringRepository.findBySocialring_SocialringIdAndStatus(socialring.getSocialringId(),BaseStatus.ACTIVE) + .orElseThrow(()-> new MemberSocialringException(CANNOT_FOUND_MEMBERSOCIALRING_LIST)).size(); + // 조건에 맞으면 응답 리스트에 추가 if (matchesCriteria) { GetSocialringSearchFilterResponse response = - new GetSocialringSearchFilterResponse(socialring.getSocialringId()); + new GetSocialringSearchFilterResponse(socialring.getSocialringId(), + socialring.getSocialringName(),socialring.getSocialringImg(), + socialring.getActivityRegion().getActivityRegionName(),socialring.getSocialringDate(), + socialring.getSocialringCost(),socialring.getCommentSimple(),currentSocialrings,socialring.getTotalRecruits()); responseList.add(response); } }