From 05c65ed6cfb85ce704883a55ed5fcce4c53bb357 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sat, 3 Aug 2024 02:28:52 +0900 Subject: [PATCH 01/44] =?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/44] =?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/44] =?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/44] =?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/44] =?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/44] =?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/44] =?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/44] =?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/44] =?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 83a60ec7f0133e683281505a7eda72a5ec7a42c1 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sat, 3 Aug 2024 20:05:34 +0900 Subject: [PATCH 10/44] =?UTF-8?q?feat=20:=20CrewController.searchFilterCre?= =?UTF-8?q?w=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../likelion12/controller/CrewController.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/example/likelion12/controller/CrewController.java b/src/main/java/com/example/likelion12/controller/CrewController.java index 956adf2..d053b22 100644 --- a/src/main/java/com/example/likelion12/controller/CrewController.java +++ b/src/main/java/com/example/likelion12/controller/CrewController.java @@ -1,10 +1,7 @@ package com.example.likelion12.controller; 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.dto.crew.*; import com.example.likelion12.service.CrewService; import com.example.likelion12.util.*; import lombok.RequiredArgsConstructor; @@ -67,5 +64,16 @@ public BaseResponse joinCrew(@RequestHeader("Authorization") String author return new BaseResponse<>(null); } + /** + * 크루 검색결과 필터링 + */ + @GetMapping("/search/filter") + public BaseResponse> searchFilterCrew(@RequestHeader("Authorization") String authorization, + @RequestBody GetCrewSearchFilterRequest getCrewSearchFilterRequest) { + log.info("[CrewController.searchFilterCrew]"); + Long memberId = jwtProvider.extractIdFromHeader(authorization); + return new BaseResponse<>(crewService.searchFilterCrew(memberId, getCrewSearchFilterRequest)); + } + } From 45adfbe033ac5c87917f68c33c9d1fff8248f59e Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sat, 3 Aug 2024 20:05:55 +0900 Subject: [PATCH 11/44] =?UTF-8?q?feat=20:=20CrewRepository.findAllByStatus?= =?UTF-8?q?=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/likelion12/repository/CrewRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/likelion12/repository/CrewRepository.java b/src/main/java/com/example/likelion12/repository/CrewRepository.java index 40da843..1759447 100644 --- a/src/main/java/com/example/likelion12/repository/CrewRepository.java +++ b/src/main/java/com/example/likelion12/repository/CrewRepository.java @@ -17,7 +17,7 @@ public interface CrewRepository extends JpaRepository { Optional> findTop4ByMemberCrewListSize(); Optional findByCrewIdAndStatus(Long crewId, BaseStatus status); - + List findAllByStatus(BaseStatus baseStatus); // 특정 exercise_id 값을 가진 상위 3개의 Crew를 반환하는 쿼리 @Query("SELECT c FROM Crew c WHERE c.exercise.id = :exerciseId AND c.status = :status ORDER BY c.crewId ASC") List findTop3ByExerciseIdAndStatus(@Param("exerciseId") Long exerciseId, @Param("status") BaseStatus status, Pageable pageable); From 213c5bb5e208ba8ec7a045db33c88912b36fce4f Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sat, 3 Aug 2024 20:06:14 +0900 Subject: [PATCH 12/44] =?UTF-8?q?feat=20:=20CrewService.searchFilterCrew?= =?UTF-8?q?=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 | 86 ++++++++++++++++++- 1 file changed, 82 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/example/likelion12/service/CrewService.java b/src/main/java/com/example/likelion12/service/CrewService.java index 50333f6..183a839 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.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.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.dto.crew.*; import com.example.likelion12.repository.*; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -180,4 +177,85 @@ public void joinCrew(Long memberId, Long crewId){ } } + /** + * 크루 검색결과 필터링 + */ + @Transactional + public List searchFilterCrew(Long memberId, GetCrewSearchFilterRequest getCrewSearchFilterRequest) { + log.info("[CrewService.searchFilterCrew]"); + + // 전체 소셜링 목록 조회 + List allCrews = crewRepository.findAllByStatus(BaseStatus.ACTIVE); + List responseList = new ArrayList<>(); + + // 요청값의 범위 확인 후 필터링 + for (Crew crew : allCrews) { + boolean matchesCriteria = true; + + if (matchesCriteria && getCrewSearchFilterRequest.getGender() != null) { + if (!crew.getGender().equals(getCrewSearchFilterRequest.getGender())) { + matchesCriteria = false; + } + } + if (matchesCriteria && getCrewSearchFilterRequest.getLevel() != null) { + if (!crew.getLevel().equals(getCrewSearchFilterRequest.getLevel())) { + matchesCriteria = false; + } + } + + // 최소, 최대 범위가 둘 다 들어왔을 때 + if (matchesCriteria && getCrewSearchFilterRequest.getCrewCostMin() != null && getCrewSearchFilterRequest.getCrewCostMax() != null) { + if (!(crew.getCrewCost() >= getCrewSearchFilterRequest.getCrewCostMin() + && crew.getCrewCost() <= getCrewSearchFilterRequest.getCrewCostMax())) { + matchesCriteria = false; + } + } + // 최소 범위만 들어왔을 때 + else if (matchesCriteria && getCrewSearchFilterRequest.getCrewCostMin() != null) { + if (crew.getCrewCost() < getCrewSearchFilterRequest.getCrewCostMin()) { + matchesCriteria = false; + } + } + // 최대 범위만 들어왔을 때 + else if (matchesCriteria && getCrewSearchFilterRequest.getCrewCostMax() != null) { + if (crew.getCrewCost() > getCrewSearchFilterRequest.getCrewCostMax()) { + matchesCriteria = false; + } + } + + // 최소, 최대 모집 인원 범위가 둘 다 들어왔을 때 + if (matchesCriteria && getCrewSearchFilterRequest.getTotalRecruitsMin() != null && getCrewSearchFilterRequest.getTotalRecruitsMax() != null) { + if (!(crew.getTotalRecruits() >= getCrewSearchFilterRequest.getTotalRecruitsMin() + && crew.getTotalRecruits() <= getCrewSearchFilterRequest.getTotalRecruitsMax())) { + matchesCriteria = false; + } + } + // 최소 모집 인원만 들어왔을 때 + else if (matchesCriteria && getCrewSearchFilterRequest.getTotalRecruitsMin() != null) { + if (crew.getTotalRecruits() < getCrewSearchFilterRequest.getTotalRecruitsMin()) { + matchesCriteria = false; + } + } + // 최대 모집 인원만 들어왔을 때 + else if (matchesCriteria && getCrewSearchFilterRequest.getTotalRecruitsMax() != null) { + if (crew.getTotalRecruits() > getCrewSearchFilterRequest.getTotalRecruitsMax()) { + matchesCriteria = false; + } + } + + // 조건에 맞으면 응답 리스트에 추가 + if (matchesCriteria) { + GetCrewSearchFilterResponse response = + new GetCrewSearchFilterResponse(crew.getCrewId()); + responseList.add(response); + } + } + + // 해당하는 크루 리스트가 하나도 없을 때 예외 처리 + if (responseList.isEmpty()) { + throw new CrewException(CANNOT_FOUND_CREW); + } + + return responseList; + } } From 245e9e57b556ea053cbdbad42cdcfdecc11ab6fa Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sat, 3 Aug 2024 20:06:38 +0900 Subject: [PATCH 13/44] =?UTF-8?q?feat=20:=20=ED=81=AC=EB=A3=A8=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=20req?= =?UTF-8?q?uest/response=20dto=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/crew/GetCrewSearchFilterRequest.java | 21 +++++++++++++++++++ .../dto/crew/GetCrewSearchFilterResponse.java | 13 ++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/main/java/com/example/likelion12/dto/crew/GetCrewSearchFilterRequest.java create mode 100644 src/main/java/com/example/likelion12/dto/crew/GetCrewSearchFilterResponse.java diff --git a/src/main/java/com/example/likelion12/dto/crew/GetCrewSearchFilterRequest.java b/src/main/java/com/example/likelion12/dto/crew/GetCrewSearchFilterRequest.java new file mode 100644 index 0000000..56bc7aa --- /dev/null +++ b/src/main/java/com/example/likelion12/dto/crew/GetCrewSearchFilterRequest.java @@ -0,0 +1,21 @@ +package com.example.likelion12.dto.crew; + +import com.example.likelion12.domain.base.BaseGender; +import com.example.likelion12.domain.base.BaseLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class GetCrewSearchFilterRequest { + + /** + * 크루 검색결과 필터링 request dto + */ + private BaseGender gender; + private BaseLevel level; + private Integer crewCostMin; + private Integer crewCostMax; + private Integer totalRecruitsMin; + private Integer totalRecruitsMax; +} diff --git a/src/main/java/com/example/likelion12/dto/crew/GetCrewSearchFilterResponse.java b/src/main/java/com/example/likelion12/dto/crew/GetCrewSearchFilterResponse.java new file mode 100644 index 0000000..210db08 --- /dev/null +++ b/src/main/java/com/example/likelion12/dto/crew/GetCrewSearchFilterResponse.java @@ -0,0 +1,13 @@ +package com.example.likelion12.dto.crew; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class GetCrewSearchFilterResponse { + /** + * 크루 검색결과 필터링 response dto + */ + private Long crewId; +} From f7194c20ccbd0867e5d71e4b8aa5d88f70dee383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AA=85=EC=A7=84?= Date: Sat, 3 Aug 2024 22:47:09 +0900 Subject: [PATCH 14/44] =?UTF-8?q?feat=20:=20=EC=86=8C=EC=85=9C=EB=A7=81=20?= =?UTF-8?q?=EC=B7=A8=EC=86=8C=ED=95=98=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SocialringController.java | 13 ++++++++++ .../likelion12/domain/MemberSocialring.java | 5 ++++ .../likelion12/service/SocialringService.java | 24 +++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/src/main/java/com/example/likelion12/controller/SocialringController.java b/src/main/java/com/example/likelion12/controller/SocialringController.java index e4c8f37..84bb32a 100644 --- a/src/main/java/com/example/likelion12/controller/SocialringController.java +++ b/src/main/java/com/example/likelion12/controller/SocialringController.java @@ -66,4 +66,17 @@ public BaseResponse joinSocialring(@RequestHeader("Authorization") String socialringService.joinSocialring(memberId, socialringId); return new BaseResponse<>(BaseExceptionResponseStatus.SUCCESS, null); } + + /** + * 소셜링 취소하기 + */ + @PatchMapping("/cancel") + public BaseResponse cancelSocialring(@RequestHeader("Authorization") String authorization, + @RequestParam Long socialringId) { + log.info("[SocialringController.cancelSocialring]"); + Long memberId = jwtProvider.extractIdFromHeader(authorization); + socialringService.cancelSocialring(memberId, socialringId); + return new BaseResponse<>(BaseExceptionResponseStatus.SUCCESS, null); + } + } diff --git a/src/main/java/com/example/likelion12/domain/MemberSocialring.java b/src/main/java/com/example/likelion12/domain/MemberSocialring.java index a60cde3..c6e2ef9 100644 --- a/src/main/java/com/example/likelion12/domain/MemberSocialring.java +++ b/src/main/java/com/example/likelion12/domain/MemberSocialring.java @@ -45,4 +45,9 @@ public MemberSocialring(BaseRole baseRole, Socialring socialring, Member member, this.member = member; this.status = baseStatus; } + + // 상태를 'delete'로 변경하는 메서드 + public void setStatusToDelete() { + this.status = BaseStatus.DELETE; + } } diff --git a/src/main/java/com/example/likelion12/service/SocialringService.java b/src/main/java/com/example/likelion12/service/SocialringService.java index 45be792..16639d6 100644 --- a/src/main/java/com/example/likelion12/service/SocialringService.java +++ b/src/main/java/com/example/likelion12/service/SocialringService.java @@ -228,4 +228,28 @@ public void joinSocialring(Long memberId, Long socialringId) { throw new SocialringException(ALREADY_FULL_SOCIALRING); } } + + /** + * 소셜링 취소 + */ + @Transactional + public void cancelSocialring(Long memberId, Long socialringId) { + log.info("[SocialringService.cancelSocialring]"); + + // 소셜링을 취소하고자 하는 멤버 찾고 + Member member = memberRepository.findByMemberIdAndStatus(memberId, BaseStatus.ACTIVE) + .orElseThrow(() -> new MemberException(CANNOT_FOUND_MEMBER)); + + // 취소하고자 하는 소셜링 찾고 + Socialring socialring = socialringRepository.findBySocialringIdAndStatus(socialringId, BaseStatus.ACTIVE) + .orElseThrow(() -> new SocialringException(CANNOT_FOUND_SOCIALRING)); + + // 해당 소셜링에 등록된 멤버 소셜링 중, 취소할 멤버의 소셜링 상태를 'delete'로 변경 + MemberSocialring memberSocialring = memberSocialringRepository.findByMember_MemberIdAndSocialring_SocialringIdAndStatus(memberId, + socialringId, BaseStatus.ACTIVE).orElseThrow(() -> new MemberSocialringException(CANNOT_FOUND_MEMBERSOCIALRING)); + + memberSocialring.setStatusToDelete(); + memberSocialringRepository.save(memberSocialring); + } + } From 7dddc43d4db8c5e5b55ce89474959e40c8f6632e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AA=85=EC=A7=84?= Date: Sat, 3 Aug 2024 23:38:06 +0900 Subject: [PATCH 15/44] =?UTF-8?q?fix=20:=20=EC=9A=94=EC=B2=ADparam=20?= =?UTF-8?q?=EC=98=A4=ED=83=80=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/likelion12/controller/SocialringController.java | 2 +- src/main/resources/application.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/likelion12/controller/SocialringController.java b/src/main/java/com/example/likelion12/controller/SocialringController.java index 84bb32a..0ba48cc 100644 --- a/src/main/java/com/example/likelion12/controller/SocialringController.java +++ b/src/main/java/com/example/likelion12/controller/SocialringController.java @@ -72,7 +72,7 @@ public BaseResponse joinSocialring(@RequestHeader("Authorization") String */ @PatchMapping("/cancel") public BaseResponse cancelSocialring(@RequestHeader("Authorization") String authorization, - @RequestParam Long socialringId) { + @RequestParam("socialringId") Long socialringId) { log.info("[SocialringController.cancelSocialring]"); Long memberId = jwtProvider.extractIdFromHeader(authorization); socialringService.cancelSocialring(memberId, socialringId); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index fc45c65..aa84b1a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -26,7 +26,7 @@ spring: registration: kakao: client-id: ${CLIENT_ID} - redirect-uri: http://43.202.94.241:8080/auth/kakao/callback + redirect-uri: http://localhost:8080/auth/kakao/callback --- jwt: From cbe012cd193b81ac60f4bad9913a537defb78980 Mon Sep 17 00:00:00 2001 From: jungeun Date: Sun, 4 Aug 2024 00:24:15 +0900 Subject: [PATCH 16/44] =?UTF-8?q?feat=20:=20application.yml=20=EB=A6=AC?= =?UTF-8?q?=EB=8B=A4=EC=9D=B4=EB=A0=89=ED=8A=B8=EC=A3=BC=EC=86=8C=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=EB=90=9C=20=EC=A3=BC=EC=86=8C=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index aa84b1a..0f93bb8 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -26,8 +26,7 @@ spring: registration: kakao: client-id: ${CLIENT_ID} - redirect-uri: http://localhost:8080/auth/kakao/callback - + redirect-uri: http://43.202.94.241:8080/auth/kakao/callback --- jwt: secret: ${JWT_SECRET} From bb0b82d3d3112ff4ea2a43453a8b06343effbf42 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sun, 4 Aug 2024 16:49:31 +0900 Subject: [PATCH 17/44] =?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 18/44] =?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); } } From 3a6d527a5346c183394af513e6dce545c3334b66 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sun, 4 Aug 2024 17:07:06 +0900 Subject: [PATCH 19/44] =?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 --- .../likelion12/dto/crew/GetCrewSearchFilterResponse.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/example/likelion12/dto/crew/GetCrewSearchFilterResponse.java b/src/main/java/com/example/likelion12/dto/crew/GetCrewSearchFilterResponse.java index 210db08..345ca18 100644 --- a/src/main/java/com/example/likelion12/dto/crew/GetCrewSearchFilterResponse.java +++ b/src/main/java/com/example/likelion12/dto/crew/GetCrewSearchFilterResponse.java @@ -10,4 +10,12 @@ public class GetCrewSearchFilterResponse { * 크루 검색결과 필터링 response dto */ private Long crewId; + private String crewName; + private String crewImg; + private int crewCost; + private String activityRegionName; + private String exerciseName; + private int currentRecruits; + private int totalRecruits; + private String commentSimple; } From 4e9f9a3b82359d6275898ad983e1f39fb9eaf66f Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sun, 4 Aug 2024 17:07:14 +0900 Subject: [PATCH 20/44] =?UTF-8?q?fix=20:=20response=20dto=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=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 --- .../java/com/example/likelion12/service/CrewService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 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 183a839..2d7c060 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.java @@ -243,10 +243,17 @@ else if (matchesCriteria && getCrewSearchFilterRequest.getTotalRecruitsMax() != } } + // 현재 참여중인 크루원 수 확인하기 + int currentCrews = memberCrewRepository.findByCrew_CrewIdAndStatus(crew.getCrewId(), BaseStatus.ACTIVE) + .orElseThrow(()->new MemberCrewException(CANNOT_FOUND_MEMBERCREW_LIST)).size(); + // 조건에 맞으면 응답 리스트에 추가 if (matchesCriteria) { GetCrewSearchFilterResponse response = - new GetCrewSearchFilterResponse(crew.getCrewId()); + new GetCrewSearchFilterResponse(crew.getCrewId(),crew.getCrewName(), + crew.getCrewImg(),crew.getCrewCost(),crew.getActivityRegion().getActivityRegionName(), + crew.getExercise().getExerciseName(),currentCrews,crew.getTotalRecruits(), + crew.getCommentSimple()); responseList.add(response); } } From 3dba168610164d28342ffc50061dd24f5a873d2a Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sun, 4 Aug 2024 18:07:17 +0900 Subject: [PATCH 21/44] =?UTF-8?q?fix=20:=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/likelion12/controller/CrewController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/likelion12/controller/CrewController.java b/src/main/java/com/example/likelion12/controller/CrewController.java index d053b22..ff2be70 100644 --- a/src/main/java/com/example/likelion12/controller/CrewController.java +++ b/src/main/java/com/example/likelion12/controller/CrewController.java @@ -1,6 +1,7 @@ package com.example.likelion12.controller; import com.example.likelion12.common.response.BaseResponse; +import com.example.likelion12.dto.SearchRequest; import com.example.likelion12.dto.crew.*; import com.example.likelion12.service.CrewService; import com.example.likelion12.util.*; @@ -34,10 +35,10 @@ public BaseResponse createCrew(@RequestHeader("Authorization") */ @GetMapping("/inquiry") public BaseResponse> getCrewInquiries(@RequestHeader("Authorization") String authorization, - @RequestParam List crewId){ + @RequestBody SearchRequest searchRequest){ log.info("[CrewController.getCrewInquiries]"); Long memberId = jwtProvider.extractIdFromHeader(authorization); - return new BaseResponse<>(crewService.getCrewInquiries(memberId, crewId)); + return new BaseResponse<>(crewService.getCrewInquiries(memberId,searchRequest)); } From a184c733d9b996e5eeb065a1d611718fde1f72f4 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sun, 4 Aug 2024 18:07:30 +0900 Subject: [PATCH 22/44] =?UTF-8?q?fix=20:=20=ED=8E=98=EC=9D=B4=EC=A7=95=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=EC=97=90=EB=94=B0?= =?UTF-8?q?=EB=A5=B8=20=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/CrewService.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/example/likelion12/service/CrewService.java b/src/main/java/com/example/likelion12/service/CrewService.java index 2d7c060..4885b97 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.java @@ -5,6 +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.SearchRequest; import com.example.likelion12.dto.crew.*; import com.example.likelion12.repository.*; import lombok.RequiredArgsConstructor; @@ -76,16 +77,20 @@ public PostCrewResponse createCrew(Long memberId, PostCrewRequest postCrewReques /** * 크루 조회 */ - public List getCrewInquiries(Long memberId, List crewIds) { + public List getCrewInquiries(Long memberId, SearchRequest searchRequest) { log.info("[CrewService.getCrewInquiries]"); + List allCrews = crewRepository.findAllByStatus(BaseStatus.ACTIVE); List getCrewInquiryResponses = new ArrayList<>(); - for (Long crewId : crewIds) { + // offset과 limit 계산 + int offset = searchRequest.getOffset(); + int recordSize = searchRequest.getRecordSize(); + + // 페이징 처리된 크루 목록 생성 + for (int i = offset; i < Math.min(offset + recordSize, allCrews.size()); i++) { - //조회하고자 하는 크루 - Crew crew = crewRepository.findByCrewIdAndStatus(crewId, BaseStatus.ACTIVE) - .orElseThrow(() -> new CrewException(CANNOT_FOUND_CREW)); + Crew crew = allCrews.get(i); GetCrewInquiryResponse response = new GetCrewInquiryResponse( crew.getCrewName(), From b88cef2656f628fd98f36a40331d6f46a9317a85 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sun, 4 Aug 2024 18:07:48 +0900 Subject: [PATCH 23/44] =?UTF-8?q?feat=20:=20=ED=8E=98=EC=9D=B4=EC=A7=95=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=9C=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 --- .../example/likelion12/dto/SearchRequest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/com/example/likelion12/dto/SearchRequest.java diff --git a/src/main/java/com/example/likelion12/dto/SearchRequest.java b/src/main/java/com/example/likelion12/dto/SearchRequest.java new file mode 100644 index 0000000..af104c5 --- /dev/null +++ b/src/main/java/com/example/likelion12/dto/SearchRequest.java @@ -0,0 +1,17 @@ +package com.example.likelion12.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class SearchRequest { + + private int page; // 현재 페이지 번호 + private int recordSize; // 페이지당 출력할 데이터 개수 + private int pageSize; // 화면 하단에 출력할 페이지 사이즈 + + public int getOffset() { + return (page - 1) * recordSize; + } +} From 7c54e5a64f3582fe01dd3d7f631ee10250b30ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AA=85=EC=A7=84?= Date: Sun, 4 Aug 2024 21:12:18 +0900 Subject: [PATCH 24/44] =?UTF-8?q?feat=20:=20=EB=A9=A4=EB=B2=84=EC=86=8C?= =?UTF-8?q?=EC=85=9C=EB=A7=81=20captain=EC=9D=80=20=EC=86=8C=EC=85=9C?= =?UTF-8?q?=EB=A7=81=EC=B7=A8=EC=86=8C=ED=95=A0=20=EC=88=98=EC=97=86?= =?UTF-8?q?=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/status/BaseExceptionResponseStatus.java | 1 + .../likelion12/service/SocialringService.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/example/likelion12/common/response/status/BaseExceptionResponseStatus.java b/src/main/java/com/example/likelion12/common/response/status/BaseExceptionResponseStatus.java index 22b4557..f3754f8 100644 --- a/src/main/java/com/example/likelion12/common/response/status/BaseExceptionResponseStatus.java +++ b/src/main/java/com/example/likelion12/common/response/status/BaseExceptionResponseStatus.java @@ -47,6 +47,7 @@ public enum BaseExceptionResponseStatus implements ResponseStatus{ CANNOT_MEMBERSOCIALRING_CAPTAIN(8001, HttpStatus.BAD_REQUEST.value(), "소셜링 수정,삭제에 접근할수없는 권한입니다."), CANNOT_FOUND_MEMBERSOCIALRING_LIST(8002, HttpStatus.BAD_REQUEST.value(), "해당하는 멤버소셜링 리스트를 찾을 수 없습니다."), ALREADY_EXIST_IN_SOCIALRING(8003, HttpStatus.BAD_REQUEST.value(), "해당 소셜링에 이미 등록된 멤버입니다."), + CANNOT_CANCEL_BY_CAPTAIN(8004, HttpStatus.BAD_REQUEST.value(), "소셜링 모임장은 소셜링을 나갈 수 없습니다. 소셜링 삭제를 이용해주세요"), /** * 9000 : crew 관련 diff --git a/src/main/java/com/example/likelion12/service/SocialringService.java b/src/main/java/com/example/likelion12/service/SocialringService.java index 16639d6..d7e8e6f 100644 --- a/src/main/java/com/example/likelion12/service/SocialringService.java +++ b/src/main/java/com/example/likelion12/service/SocialringService.java @@ -4,6 +4,7 @@ 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.socialring.GetSocialringDetailResponse; import com.example.likelion12.dto.socialring.PatchSocialringModifyRequest; @@ -244,10 +245,19 @@ public void cancelSocialring(Long memberId, Long socialringId) { Socialring socialring = socialringRepository.findBySocialringIdAndStatus(socialringId, BaseStatus.ACTIVE) .orElseThrow(() -> new SocialringException(CANNOT_FOUND_SOCIALRING)); - // 해당 소셜링에 등록된 멤버 소셜링 중, 취소할 멤버의 소셜링 상태를 'delete'로 변경 + // 해당 소셜링에 등록된 멤버 소셜링 중, 취소할 멤버의 멤버소셜링 값을 가져와서 MemberSocialring memberSocialring = memberSocialringRepository.findByMember_MemberIdAndSocialring_SocialringIdAndStatus(memberId, socialringId, BaseStatus.ACTIVE).orElseThrow(() -> new MemberSocialringException(CANNOT_FOUND_MEMBERSOCIALRING)); + // 가져온 멤버 소셜링의 값으로 캡틴인지 확인하고 + memberSocialringService.ConfirmCaptainMemberSocialring(memberSocialring); + + // 캡틴인 경우 예외 발생 + if (memberSocialring.getRole() == BaseRole.CAPTAIN) { + throw new MemberSocialringException(CANNOT_CANCEL_BY_CAPTAIN); + } + + // 캡틴이 아닌경우 정상적으로 상태를 DELETE로 변경 memberSocialring.setStatusToDelete(); memberSocialringRepository.save(memberSocialring); } From 6707355b3dd5422ae0ce514f4e63a016e72efbae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AA=85=EC=A7=84?= Date: Sun, 4 Aug 2024 21:55:15 +0900 Subject: [PATCH 25/44] =?UTF-8?q?feat=20:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20application.yml=20=EB=A1=9C=EC=BB=AC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index fc45c65..aa84b1a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -26,7 +26,7 @@ spring: registration: kakao: client-id: ${CLIENT_ID} - redirect-uri: http://43.202.94.241:8080/auth/kakao/callback + redirect-uri: http://localhost:8080/auth/kakao/callback --- jwt: From d999b6e80ddd200dbbca6d7d8e551c4a5d6705f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AA=85=EC=A7=84?= Date: Sun, 4 Aug 2024 22:06:56 +0900 Subject: [PATCH 26/44] =?UTF-8?q?feat=20:=20CrewController=EC=97=90=20?= =?UTF-8?q?=EC=B0=B8=EC=97=AC=EC=A4=91=EC=9D=B8=20=ED=81=AC=EB=A3=A8=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=A0=91=EA=B7=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/likelion12/controller/CrewController.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/example/likelion12/controller/CrewController.java b/src/main/java/com/example/likelion12/controller/CrewController.java index 6eaf155..1977067 100644 --- a/src/main/java/com/example/likelion12/controller/CrewController.java +++ b/src/main/java/com/example/likelion12/controller/CrewController.java @@ -77,4 +77,13 @@ public BaseResponse cancelCrew(@RequestHeader("Authorization") String auth return new BaseResponse<>(null); } + /** + * 참여중인 크루 조회 + */ + @GetMapping("") + public BaseResponse getJoinCrew(@RequestHeader("Authorization") String authorization){ + log.info("[CrewController.getJoinCrewDetail]"); + Long memberId = jwtProvider.extractIdFromHeader(authorization); + return new BaseResponse<>(crewService.getJoinCrewDetail(memberId)); + } } From 12849c3ba0c54ccd6cfbb07e814f9c79d144289b Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sun, 4 Aug 2024 22:25:50 +0900 Subject: [PATCH 27/44] =?UTF-8?q?feat=20:=20=ED=81=AC=EB=A3=A8=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EA=B4=80=EB=A0=A8=20=EC=98=88=EC=99=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/response/status/BaseExceptionResponseStatus.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/example/likelion12/common/response/status/BaseExceptionResponseStatus.java b/src/main/java/com/example/likelion12/common/response/status/BaseExceptionResponseStatus.java index 08b3ac6..a78fad3 100644 --- a/src/main/java/com/example/likelion12/common/response/status/BaseExceptionResponseStatus.java +++ b/src/main/java/com/example/likelion12/common/response/status/BaseExceptionResponseStatus.java @@ -64,6 +64,7 @@ public enum BaseExceptionResponseStatus implements ResponseStatus{ ALREADY_EXIST_IN_CREW(10002, HttpStatus.BAD_REQUEST.value(), "해당 크루에 이미 등록된 멤버입니다."), NOT_MEMBERCREW_CAPTAIN(10003, HttpStatus.BAD_REQUEST.value(), "크루 수정,삭제에 접근할수없는 권한입니다."), NOT_CREW_MEMBERCREW(10004, HttpStatus.BAD_REQUEST.value(), "해당 크루에 참여 상태가 아닙니다."), + CANNOT_CREW_CANCEL(10005, HttpStatus.BAD_REQUEST.value(), "해당 크루를 탈퇴 할 수 없습니다. 크루 삭제를 이용해주세요."), /** * 11000 : Review 관련 From 774317153f7afb33dea207858d6e7d5bf20783c7 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sun, 4 Aug 2024 22:27:03 +0900 Subject: [PATCH 28/44] =?UTF-8?q?fix=20:=20CrewService.cancelCrew=20?= =?UTF-8?q?=ED=81=AC=EB=A3=A8=20=ED=83=88=ED=87=B4=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=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 --- .../likelion12/service/CrewService.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/example/likelion12/service/CrewService.java b/src/main/java/com/example/likelion12/service/CrewService.java index 630e89d..5e530da 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.java @@ -4,6 +4,7 @@ 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.PostCrewRequest; @@ -194,22 +195,27 @@ public void cancelCrew(Long memberId, Long crewId) { // 크루를 탈퇴하고자 하는 member Member member = memberRepository.findByMemberIdAndStatus(memberId, BaseStatus.ACTIVE) - .orElseThrow(()-> new MemberException(CANNOT_FOUND_MEMBER)); + .orElseThrow(() -> new MemberException(CANNOT_FOUND_MEMBER)); //탈퇴하고자 하는 크루 Crew crew = crewRepository.findByCrewIdAndStatus(crewId, BaseStatus.ACTIVE) - .orElseThrow(()->new CrewException(CANNOT_FOUND_CREW)); + .orElseThrow(() -> new CrewException(CANNOT_FOUND_CREW)); //탈퇴하고자 하는 크루의 멤버크루 //해당크루와 관계없음(해당크루에 등록되있지 않음), 멤버크루가 존재하지않음 - MemberCrew memberCrew = memberCrewRepository.findByMember_MemberIdAndCrew_CrewIdAndStatus( memberId, crewId, BaseStatus.ACTIVE) - .orElseThrow(()->new MemberCrewException(NOT_CREW_MEMBERCREW)); + MemberCrew memberCrew = memberCrewRepository.findByMember_MemberIdAndCrew_CrewIdAndStatus(memberId, crewId, BaseStatus.ACTIVE) + .orElseThrow(() -> new MemberCrewException(NOT_CREW_MEMBERCREW)); - //CAPTAIN일 경우 크루 삭제 - if(memberCrewService.ConfirmCaptainMemberCrew(memberCrew)) - deleteCrew(memberId,crewId); - else //크루 탈퇴 - memberCrewRepository.delete(memberCrew); + //CAPTAIN일 경우 예외처리 --> 크루삭제 + if (BaseRole.CAPTAIN.equals(memberCrew.getRole())){ + throw new MemberCrewException(CANNOT_CREW_CANCEL); + } + //크루 탈퇴 + else { + //멤버크루 삭제 + memberCrew.DeleteMemberCrewInfo(BaseStatus.DELETE); + memberCrewRepository.save(memberCrew); + } } } From 7e2c06ed73ae988928240e74705e1dc41dfd180a Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sun, 4 Aug 2024 22:27:33 +0900 Subject: [PATCH 29/44] =?UTF-8?q?fix=20:=20MemberCrewService.ConfirmCaptai?= =?UTF-8?q?nMemberCrew=20=EB=A9=A4=EB=B2=84=ED=81=AC=EB=A3=A8=20=EC=84=9C?= =?UTF-8?q?=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 --- .../java/com/example/likelion12/service/MemberCrewService.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/example/likelion12/service/MemberCrewService.java b/src/main/java/com/example/likelion12/service/MemberCrewService.java index 3c7c31d..41ed6cc 100644 --- a/src/main/java/com/example/likelion12/service/MemberCrewService.java +++ b/src/main/java/com/example/likelion12/service/MemberCrewService.java @@ -45,12 +45,11 @@ public void createMemberCrew(Member member, Crew crew){ /** * 크루 수정,삭제 시 접근하는 member가 CAPTAIN 인지 확인 */ - public boolean ConfirmCaptainMemberCrew(MemberCrew memberCrew) { + public void ConfirmCaptainMemberCrew(MemberCrew memberCrew) { log.info("[MemberCrewService.ConfirmCaptainMemberCrew]"); if (!BaseRole.CAPTAIN.equals(memberCrew.getRole())) { throw new MemberCrewException(NOT_MEMBERCREW_CAPTAIN); } - return true; } } From aec2e74651346324a58aa57c6b529c089a048fdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AA=85=EC=A7=84?= Date: Sun, 4 Aug 2024 23:37:54 +0900 Subject: [PATCH 30/44] =?UTF-8?q?feat=20:=20getJoinCrewResponse=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/crew/GetJoinCrewResponse.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/java/com/example/likelion12/dto/crew/GetJoinCrewResponse.java diff --git a/src/main/java/com/example/likelion12/dto/crew/GetJoinCrewResponse.java b/src/main/java/com/example/likelion12/dto/crew/GetJoinCrewResponse.java new file mode 100644 index 0000000..03fd69a --- /dev/null +++ b/src/main/java/com/example/likelion12/dto/crew/GetJoinCrewResponse.java @@ -0,0 +1,18 @@ +package com.example.likelion12.dto.crew; + +import com.example.likelion12.domain.MemberCrew; +import com.example.likelion12.domain.base.BaseRole; +import com.example.likelion12.domain.base.BaseStatus; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +public class GetJoinCrewResponse { + + private List memberCrewList; +} From fb17ffac676aeb18208aa6f67f71e032e80eb1a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AA=85=EC=A7=84?= Date: Sun, 4 Aug 2024 23:51:56 +0900 Subject: [PATCH 31/44] =?UTF-8?q?feat=20:=20getJoinCrew=EB=A5=BC=20getCrew?= =?UTF-8?q?Service=EC=97=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../likelion12/service/CrewService.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/java/com/example/likelion12/service/CrewService.java b/src/main/java/com/example/likelion12/service/CrewService.java index 630e89d..27c4972 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.java @@ -1,11 +1,13 @@ package com.example.likelion12.service; import com.example.likelion12.common.exception.*; +import com.example.likelion12.common.response.BaseResponse; 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.BaseStatus; import com.example.likelion12.dto.crew.GetCrewDetailResponse; +import com.example.likelion12.dto.crew.GetJoinCrewResponse; import com.example.likelion12.dto.crew.PostCrewRequest; import com.example.likelion12.dto.crew.PostCrewResponse; import com.example.likelion12.repository.*; @@ -212,4 +214,25 @@ public void cancelCrew(Long memberId, Long crewId) { memberCrewRepository.delete(memberCrew); } + + /** + * 참여중인 크루 조회하기 + */ + @Transactional + public GetJoinCrewResponse getJoinCrew(Long memberId) { + log.info("[CrewService.getJoinCrew]"); + + // 멤버Id로 멤버찾고 + Member member = memberRepository.findByMemberIdAndStatus(memberId, BaseStatus.ACTIVE) + .orElseThrow(()-> new MemberException(CANNOT_FOUND_MEMBER)); + + // 멤버가 가지고 있는 crew를 리스트로 가져오고 + List memberCrewList = member.getMemberCrewList(); + + // 가져온 리스트를 Response Dto 에 담아서 + GetJoinCrewResponse getJoinCrewResponse = new GetJoinCrewResponse(memberCrewList); + + // 반환하기 + return getJoinCrewResponse; + } } From 65a21e6c26f7fd8d2833f56844898c1835d3bfc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AA=85=EC=A7=84?= Date: Sun, 4 Aug 2024 23:52:40 +0900 Subject: [PATCH 32/44] =?UTF-8?q?feat=20:=20CrewController=EC=97=90=20getJ?= =?UTF-8?q?oinCrew=20=ED=95=A8=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/likelion12/controller/CrewController.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/example/likelion12/controller/CrewController.java b/src/main/java/com/example/likelion12/controller/CrewController.java index 1977067..77d3d33 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.GetJoinCrewResponse; import com.example.likelion12.dto.crew.PostCrewRequest; import com.example.likelion12.dto.crew.PostCrewResponse; import com.example.likelion12.service.CrewService; @@ -81,9 +82,9 @@ public BaseResponse cancelCrew(@RequestHeader("Authorization") String auth * 참여중인 크루 조회 */ @GetMapping("") - public BaseResponse getJoinCrew(@RequestHeader("Authorization") String authorization){ - log.info("[CrewController.getJoinCrewDetail]"); + public BaseResponse getJoinCrew(@RequestHeader("Authorization") String authorization){ + log.info("[CrewController.getJoinCrew]"); Long memberId = jwtProvider.extractIdFromHeader(authorization); - return new BaseResponse<>(crewService.getJoinCrewDetail(memberId)); + return new BaseResponse<>(crewService.getJoinCrew(memberId)); } } From 8474a9a0626e6f696b9e4a17b8c90ea63ca5421d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AA=85=EC=A7=84?= Date: Mon, 5 Aug 2024 00:27:59 +0900 Subject: [PATCH 33/44] =?UTF-8?q?fix=20:=20=EC=9A=94=EC=B2=AD=20url=20/cre?= =?UTF-8?q?w=20->=20/cre/join=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/likelion12/controller/CrewController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/likelion12/controller/CrewController.java b/src/main/java/com/example/likelion12/controller/CrewController.java index 77d3d33..4d865ab 100644 --- a/src/main/java/com/example/likelion12/controller/CrewController.java +++ b/src/main/java/com/example/likelion12/controller/CrewController.java @@ -81,7 +81,7 @@ public BaseResponse cancelCrew(@RequestHeader("Authorization") String auth /** * 참여중인 크루 조회 */ - @GetMapping("") + @GetMapping("/join") public BaseResponse getJoinCrew(@RequestHeader("Authorization") String authorization){ log.info("[CrewController.getJoinCrew]"); Long memberId = jwtProvider.extractIdFromHeader(authorization); From 9587651b74c08e7f3d7e786a6c73afb6be947298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AA=85=EC=A7=84?= Date: Mon, 5 Aug 2024 01:02:14 +0900 Subject: [PATCH 34/44] =?UTF-8?q?fix=20:=20=EB=A9=A4=EB=B2=84=20->=20?= =?UTF-8?q?=EB=A9=A4=EB=B2=84=ED=81=AC=EB=A3=A8=20->=20=ED=81=AC=EB=A3=A8?= =?UTF-8?q?=20->=20=ED=95=84=EC=9A=94=ED=95=9C=EC=A0=95=EB=B3=B4=EB=A7=8C?= =?UTF-8?q?=20dto=20=EB=B0=A9=EC=8B=9D=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../likelion12/controller/CrewController.java | 7 +++++-- .../dto/crew/GetJoinCrewResponse.java | 4 +++- .../likelion12/service/CrewService.java | 19 ++++++++++++++----- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/example/likelion12/controller/CrewController.java b/src/main/java/com/example/likelion12/controller/CrewController.java index 4d865ab..9ca58bb 100644 --- a/src/main/java/com/example/likelion12/controller/CrewController.java +++ b/src/main/java/com/example/likelion12/controller/CrewController.java @@ -11,6 +11,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; +import java.util.List; + @Slf4j @RestController @RequiredArgsConstructor @@ -82,9 +84,10 @@ public BaseResponse cancelCrew(@RequestHeader("Authorization") String auth * 참여중인 크루 조회 */ @GetMapping("/join") - public BaseResponse getJoinCrew(@RequestHeader("Authorization") String authorization){ + public BaseResponse> getJoinCrew(@RequestHeader("Authorization") String authorization) { log.info("[CrewController.getJoinCrew]"); Long memberId = jwtProvider.extractIdFromHeader(authorization); - return new BaseResponse<>(crewService.getJoinCrew(memberId)); + List joinCrewResponses = crewService.getJoinCrew(memberId); + return new BaseResponse<>(joinCrewResponses); } } diff --git a/src/main/java/com/example/likelion12/dto/crew/GetJoinCrewResponse.java b/src/main/java/com/example/likelion12/dto/crew/GetJoinCrewResponse.java index 03fd69a..707a567 100644 --- a/src/main/java/com/example/likelion12/dto/crew/GetJoinCrewResponse.java +++ b/src/main/java/com/example/likelion12/dto/crew/GetJoinCrewResponse.java @@ -14,5 +14,7 @@ @NoArgsConstructor public class GetJoinCrewResponse { - private List memberCrewList; + private String crewName; + private String crewImg; + private String commentSimple; } diff --git a/src/main/java/com/example/likelion12/service/CrewService.java b/src/main/java/com/example/likelion12/service/CrewService.java index 27c4972..cd5f26f 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.java @@ -219,20 +219,29 @@ public void cancelCrew(Long memberId, Long crewId) { * 참여중인 크루 조회하기 */ @Transactional - public GetJoinCrewResponse getJoinCrew(Long memberId) { + public List getJoinCrew(Long memberId) { log.info("[CrewService.getJoinCrew]"); // 멤버Id로 멤버찾고 Member member = memberRepository.findByMemberIdAndStatus(memberId, BaseStatus.ACTIVE) .orElseThrow(()-> new MemberException(CANNOT_FOUND_MEMBER)); - // 멤버가 가지고 있는 crew를 리스트로 가져오고 + // 멤버가 가지고 있는 멤버크루를 리스트로 가져오고 List memberCrewList = member.getMemberCrewList(); - // 가져온 리스트를 Response Dto 에 담아서 - GetJoinCrewResponse getJoinCrewResponse = new GetJoinCrewResponse(memberCrewList); + // 그 멤버크루로 속해있는 크루들을 가져와서 필요한 정보만 dto에 담고 + List joinCrewResponses = memberCrewList.stream() + .map(memberCrew -> { + Crew crew = memberCrew.getCrew(); + return new GetJoinCrewResponse( + crew.getCrewName(), + crew.getCrewImg(), + crew.getCommentSimple() + ); + }) + .collect(Collectors.toList()); // 반환하기 - return getJoinCrewResponse; + return joinCrewResponses; } } From 7fad3f66d48b4d45278107a8b1caa433eae0398d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AA=85=EC=A7=84?= Date: Mon, 5 Aug 2024 01:23:23 +0900 Subject: [PATCH 35/44] =?UTF-8?q?application.yml=20=EB=A1=9C=EC=BB=AC?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=84=9C=EB=B2=84=EB=A1=9C=20=EB=B3=B5?= =?UTF-8?q?=EA=B5=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index aa84b1a..fc45c65 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -26,7 +26,7 @@ spring: registration: kakao: client-id: ${CLIENT_ID} - redirect-uri: http://localhost:8080/auth/kakao/callback + redirect-uri: http://43.202.94.241:8080/auth/kakao/callback --- jwt: From 1fd79e5275e89c7e4bda54b8f52681ac31da1c43 Mon Sep 17 00:00:00 2001 From: jungeun Date: Mon, 5 Aug 2024 18:22:26 +0900 Subject: [PATCH 36/44] =?UTF-8?q?feat=20:=20GetCrewSearchResponse=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/GetCrewSearchResponse.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/java/com/example/likelion12/dto/crew/GetCrewSearchResponse.java diff --git a/src/main/java/com/example/likelion12/dto/crew/GetCrewSearchResponse.java b/src/main/java/com/example/likelion12/dto/crew/GetCrewSearchResponse.java new file mode 100644 index 0000000..f31df1d --- /dev/null +++ b/src/main/java/com/example/likelion12/dto/crew/GetCrewSearchResponse.java @@ -0,0 +1,18 @@ +package com.example.likelion12.dto.crew; + +import com.example.likelion12.domain.base.BaseLevel; +import lombok.AllArgsConstructor; +import lombok.Data; + +@AllArgsConstructor +@Data +public class GetCrewSearchResponse { + + private long crewId; + private String crewName; + private String crewImg; + private String activeAreaName; + private String commentSimple; + private BaseLevel level; + private String exerciseName; +} From df30c07f0aff2c8ac26b4c3102b5d01dbf474fbc Mon Sep 17 00:00:00 2001 From: jungeun Date: Mon, 5 Aug 2024 18:22:34 +0900 Subject: [PATCH 37/44] =?UTF-8?q?feat=20:=20=ED=81=AC=EB=A3=A8=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../likelion12/controller/CrewController.java | 16 ++++++ .../likelion12/repository/CrewRepository.java | 18 +++++++ .../likelion12/service/CrewService.java | 52 +++++++++++++++++++ 3 files changed, 86 insertions(+) diff --git a/src/main/java/com/example/likelion12/controller/CrewController.java b/src/main/java/com/example/likelion12/controller/CrewController.java index 6eaf155..6f4d201 100644 --- a/src/main/java/com/example/likelion12/controller/CrewController.java +++ b/src/main/java/com/example/likelion12/controller/CrewController.java @@ -1,13 +1,16 @@ package com.example.likelion12.controller; import com.example.likelion12.common.response.BaseResponse; +import com.example.likelion12.common.response.status.BaseExceptionResponseStatus; import com.example.likelion12.dto.crew.GetCrewDetailResponse; +import com.example.likelion12.dto.crew.GetCrewSearchResponse; import com.example.likelion12.dto.crew.PostCrewRequest; import com.example.likelion12.dto.crew.PostCrewResponse; import com.example.likelion12.service.CrewService; import com.example.likelion12.util.*; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Page; import org.springframework.web.bind.annotation.*; @Slf4j @@ -77,4 +80,17 @@ public BaseResponse cancelCrew(@RequestHeader("Authorization") String auth return new BaseResponse<>(null); } + /** + * 크루 검색 + */ + @GetMapping("/search") + public BaseResponse> searchSocialrings( + @RequestParam(required = false) String keyWord, + @RequestParam(required = false) String activityRegionName, + @RequestParam(required = false) String exerciseName, + @RequestParam(defaultValue = "0") int page + ) { + Page responses = crewService.searchCrews(keyWord, activityRegionName, exerciseName,page, 9); + return new BaseResponse<>(BaseExceptionResponseStatus.SUCCESS, responses); + } } diff --git a/src/main/java/com/example/likelion12/repository/CrewRepository.java b/src/main/java/com/example/likelion12/repository/CrewRepository.java index 40da843..895f737 100644 --- a/src/main/java/com/example/likelion12/repository/CrewRepository.java +++ b/src/main/java/com/example/likelion12/repository/CrewRepository.java @@ -2,11 +2,13 @@ import com.example.likelion12.domain.Crew; import com.example.likelion12.domain.base.BaseStatus; +import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import java.time.LocalDate; import java.util.List; import java.util.Optional; @@ -21,4 +23,20 @@ public interface CrewRepository extends JpaRepository { // 특정 exercise_id 값을 가진 상위 3개의 Crew를 반환하는 쿼리 @Query("SELECT c FROM Crew c WHERE c.exercise.id = :exerciseId AND c.status = :status ORDER BY c.crewId ASC") List findTop3ByExerciseIdAndStatus(@Param("exerciseId") Long exerciseId, @Param("status") BaseStatus status, Pageable pageable); + + /** 정적쿼리가 동적쿼리보다 빠르기때문에 정적쿼리 + * JPA에서 제공하는 페이징 이용!*/ + @Query("SELECT c FROM Crew c " + + "WHERE (:keyWord IS NULL OR c.crewName LIKE %:keyWord% " + + "OR c.commentSimple LIKE %:keyWord%) " + + "AND (:exerciseId IS NULL OR (c.exercise.id = :exerciseId AND c.exercise.status = :status)) " + + "AND (:activityRegionId IS NULL OR (c.activityRegion.id = :activityRegionId AND c.activityRegion.status = :status)) " + + "AND c.status = :status ") + Page searchCrew( + @Param("keyWord") String keyWord, + @Param("exerciseId") Long exerciseId, + @Param("activityRegionId") Long activityRegionId, + @Param("status") BaseStatus status, + Pageable pageable + ); } \ No newline at end of file diff --git a/src/main/java/com/example/likelion12/service/CrewService.java b/src/main/java/com/example/likelion12/service/CrewService.java index 630e89d..1b92669 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.java @@ -6,16 +6,20 @@ import com.example.likelion12.domain.base.BaseLevel; import com.example.likelion12.domain.base.BaseStatus; import com.example.likelion12.dto.crew.GetCrewDetailResponse; +import com.example.likelion12.dto.crew.GetCrewSearchResponse; 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.Page; +import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import static com.example.likelion12.common.response.status.BaseExceptionResponseStatus.*; @@ -212,4 +216,52 @@ public void cancelCrew(Long memberId, Long crewId) { memberCrewRepository.delete(memberCrew); } + + /** + * 크루 검색 + */ + public Page searchCrews(String keyWord, String activityRegionName, String exerciseName, int page, int size) { + Long activityRegionId = getActivityRegionIdByName(activityRegionName, BaseStatus.ACTIVE); + Long exerciseId = getActivityExerciseIdByName(exerciseName, BaseStatus.ACTIVE); + + Pageable pageable = PageRequest.of(page, size); + Page results = crewRepository.searchCrew( + keyWord, exerciseId, activityRegionId, BaseStatus.ACTIVE, pageable + ); + return results.map(crew -> { + return new GetCrewSearchResponse( + crew.getCrewId(), + crew.getCrewName(), + crew.getCrewImg(), + crew.getActivityRegion().getActivityRegionName(), + crew.getCommentSimple(), + crew.getLevel(), + crew.getExercise().getExerciseName() + ); + }); + } + + private Long getActivityRegionIdByName(String name, BaseStatus status){ + Long activityRegionId = null; + /** 이름으로 지역아이디 얻기 */ + if (name != null) { + Optional activityRegionOpt = activityRegionRepository.findByActivityRegionNameAndStatus(name, status); + if (activityRegionOpt.isPresent()) { + activityRegionId = activityRegionOpt.get().getActivityRegionId(); + } + } + return activityRegionId; + } + + private Long getActivityExerciseIdByName(String name, BaseStatus status){ + Long ExerciseId = null; + /** 이름으로 활동아이디 얻기 */ + if (name != null) { + Optional activityRegionOpt = exerciseRepository.findByExerciseNameAndStatus(name, status); + if (activityRegionOpt.isPresent()) { + ExerciseId = activityRegionOpt.get().getExerciseId(); + } + } + return ExerciseId; + } } From c0b265e02927ec520425c06b7cf2d812f15ee602 Mon Sep 17 00:00:00 2001 From: jungeun Date: Mon, 5 Aug 2024 18:26:46 +0900 Subject: [PATCH 38/44] =?UTF-8?q?feat=20:=20=ED=81=AC=EB=A3=A8=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/likelion12/controller/CrewController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/likelion12/controller/CrewController.java b/src/main/java/com/example/likelion12/controller/CrewController.java index 6f4d201..af0e46f 100644 --- a/src/main/java/com/example/likelion12/controller/CrewController.java +++ b/src/main/java/com/example/likelion12/controller/CrewController.java @@ -84,7 +84,7 @@ public BaseResponse cancelCrew(@RequestHeader("Authorization") String auth * 크루 검색 */ @GetMapping("/search") - public BaseResponse> searchSocialrings( + public BaseResponse> searchCrews( @RequestParam(required = false) String keyWord, @RequestParam(required = false) String activityRegionName, @RequestParam(required = false) String exerciseName, From d39389670556d41e70bcbf774f7058ce5b0ba104 Mon Sep 17 00:00:00 2001 From: jungeun Date: Mon, 5 Aug 2024 19:21:09 +0900 Subject: [PATCH 39/44] =?UTF-8?q?feat=20:=20cors=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=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/config/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/likelion12/config/SecurityConfig.java b/src/main/java/com/example/likelion12/config/SecurityConfig.java index 5d64c5c..150bb56 100644 --- a/src/main/java/com/example/likelion12/config/SecurityConfig.java +++ b/src/main/java/com/example/likelion12/config/SecurityConfig.java @@ -41,7 +41,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { @Bean public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration configuration = new CorsConfiguration(); - configuration.setAllowedOrigins(Arrays.asList("http://example.com")); // 허용할 도메인 설정 + configuration.setAllowedOrigins(Arrays.asList("http://localhost:3000")); // 허용할 도메인 설정 configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE")); // 허용할 HTTP 메서드 설정 configuration.setAllowedHeaders(Arrays.asList("*")); // 허용할 헤더 설정 configuration.setAllowCredentials(true); // 자격 증명 허용 설정 From 80e62dc6efaa0cf97b2d359aee120d8766950cdd Mon Sep 17 00:00:00 2001 From: jungeun Date: Mon, 5 Aug 2024 19:27:27 +0900 Subject: [PATCH 40/44] =?UTF-8?q?feat=20:=20cors=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../likelion12/config/SecurityConfig.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/example/likelion12/config/SecurityConfig.java b/src/main/java/com/example/likelion12/config/SecurityConfig.java index 150bb56..ca10697 100644 --- a/src/main/java/com/example/likelion12/config/SecurityConfig.java +++ b/src/main/java/com/example/likelion12/config/SecurityConfig.java @@ -4,6 +4,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpMethod; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configurers.CsrfConfigurer; import org.springframework.security.config.http.SessionCreationPolicy; @@ -24,16 +25,17 @@ public class SecurityConfig { public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http .csrf(CsrfConfigurer::disable) - .cors(cors -> cors.configurationSource(corsConfigurationSource())) // CORS 설정 추가 + .cors(cors -> cors.configurationSource(corsConfigurationSource())) .authorizeHttpRequests(requests -> requests - .requestMatchers("/test", "/auth/kakao/callback", "/user/signup","/main").permitAll() // 이 URL은 모두에게 허용 - .anyRequest().authenticated() // 그 외의 모든 요청은 인증 필요 + .requestMatchers(HttpMethod.OPTIONS, "/**").permitAll() + .requestMatchers("/test", "/auth/kakao/callback", "/user/signup", "/main").permitAll() + .anyRequest().authenticated() ) .sessionManagement(sessionManagement -> sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS) - ) // 세션을 사용하지 않으므로 STATELESS 설정 - .addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); // JwtAuthenticationFilter를 UsernamePasswordAuthenticationFilter 전에 추가 + ) + .addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); return http.build(); } @@ -42,8 +44,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration configuration = new CorsConfiguration(); configuration.setAllowedOrigins(Arrays.asList("http://localhost:3000")); // 허용할 도메인 설정 - configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE")); // 허용할 HTTP 메서드 설정 - configuration.setAllowedHeaders(Arrays.asList("*")); // 허용할 헤더 설정 + configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PATCH", "DELETE")); // 허용할 HTTP 메서드 설정 + configuration.setAllowedHeaders(Arrays.asList("Authorization", "Cache-Control", "Content-Type")); // 허용할 헤더 설정 configuration.setAllowCredentials(true); // 자격 증명 허용 설정 UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); source.registerCorsConfiguration("/**", configuration); From 1e85f248dafae461fd704f3766b726903f2969d9 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Mon, 5 Aug 2024 19:57:27 +0900 Subject: [PATCH 41/44] =?UTF-8?q?fix=20:=20=ED=8E=98=EC=9D=B4=EC=A7=95?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20request=20dto=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/dto/SearchRequest.java | 4 +--- src/main/java/com/example/likelion12/service/CrewService.java | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/example/likelion12/dto/SearchRequest.java b/src/main/java/com/example/likelion12/dto/SearchRequest.java index af104c5..ed43c36 100644 --- a/src/main/java/com/example/likelion12/dto/SearchRequest.java +++ b/src/main/java/com/example/likelion12/dto/SearchRequest.java @@ -8,10 +8,8 @@ public class SearchRequest { private int page; // 현재 페이지 번호 - private int recordSize; // 페이지당 출력할 데이터 개수 - private int pageSize; // 화면 하단에 출력할 페이지 사이즈 public int getOffset() { - return (page - 1) * recordSize; + return (page - 1) * 9; } } diff --git a/src/main/java/com/example/likelion12/service/CrewService.java b/src/main/java/com/example/likelion12/service/CrewService.java index 4885b97..5194d04 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.java @@ -85,7 +85,7 @@ public List getCrewInquiries(Long memberId, SearchReques // offset과 limit 계산 int offset = searchRequest.getOffset(); - int recordSize = searchRequest.getRecordSize(); + int recordSize = 9 ; // 페이징 처리된 크루 목록 생성 for (int i = offset; i < Math.min(offset + recordSize, allCrews.size()); i++) { From 6cbad08662d87a7b050d3e4cddd4f73479a64fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AA=85=EC=A7=84?= Date: Mon, 5 Aug 2024 22:19:49 +0900 Subject: [PATCH 42/44] =?UTF-8?q?fix=20:=20=EC=9D=91=EB=8B=B5=20DTO?= =?UTF-8?q?=EC=97=90=20=EC=A7=80=EC=97=AD=EC=9D=B4=EB=A6=84,=20=EC=9A=B4?= =?UTF-8?q?=EB=8F=99=EC=9D=B4=EB=A6=84=20,=20=EC=B0=B8=EA=B0=80=EC=9E=90?= =?UTF-8?q?=20=EC=88=98=EC=A4=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/likelion12/dto/crew/GetJoinCrewResponse.java | 4 ++++ .../java/com/example/likelion12/service/CrewService.java | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/example/likelion12/dto/crew/GetJoinCrewResponse.java b/src/main/java/com/example/likelion12/dto/crew/GetJoinCrewResponse.java index 707a567..90bb2dc 100644 --- a/src/main/java/com/example/likelion12/dto/crew/GetJoinCrewResponse.java +++ b/src/main/java/com/example/likelion12/dto/crew/GetJoinCrewResponse.java @@ -1,6 +1,7 @@ package com.example.likelion12.dto.crew; import com.example.likelion12.domain.MemberCrew; +import com.example.likelion12.domain.base.BaseLevel; import com.example.likelion12.domain.base.BaseRole; import com.example.likelion12.domain.base.BaseStatus; import lombok.AllArgsConstructor; @@ -17,4 +18,7 @@ public class GetJoinCrewResponse { private String crewName; private String crewImg; private String commentSimple; + private String exercise_name; + private String activty_area_name; + private BaseLevel level; } diff --git a/src/main/java/com/example/likelion12/service/CrewService.java b/src/main/java/com/example/likelion12/service/CrewService.java index 9fb3220..b1958a8 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.java @@ -268,7 +268,10 @@ public List getJoinCrew(Long memberId) { return new GetJoinCrewResponse( crew.getCrewName(), crew.getCrewImg(), - crew.getCommentSimple() + crew.getCommentSimple(), + crew.getActivityRegion().getActivityRegionName(), + crew.getExercise().getExerciseName(), + crew.getLevel() ); }) .collect(Collectors.toList()); From 91aacad0ddedac082f9831ea196287812cb8fa7b Mon Sep 17 00:00:00 2001 From: hd0rable Date: Tue, 6 Aug 2024 01:13:32 +0900 Subject: [PATCH 43/44] =?UTF-8?q?fix=20:=20=ED=81=AC=EB=A3=A8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20dto=EC=88=98=EC=A0=95=EC=97=90=EB=94=B0=EB=A5=B8=20?= =?UTF-8?q?=EC=84=9C=EB=B9=84=EC=8A=A4,=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../likelion12/controller/CrewController.java | 5 ++--- .../com/example/likelion12/dto/SearchRequest.java | 15 --------------- .../example/likelion12/service/CrewService.java | 5 ++--- 3 files changed, 4 insertions(+), 21 deletions(-) delete mode 100644 src/main/java/com/example/likelion12/dto/SearchRequest.java diff --git a/src/main/java/com/example/likelion12/controller/CrewController.java b/src/main/java/com/example/likelion12/controller/CrewController.java index dca7c7e..a892a48 100644 --- a/src/main/java/com/example/likelion12/controller/CrewController.java +++ b/src/main/java/com/example/likelion12/controller/CrewController.java @@ -1,7 +1,6 @@ package com.example.likelion12.controller; import com.example.likelion12.common.response.BaseResponse; -import com.example.likelion12.dto.SearchRequest; import com.example.likelion12.dto.crew.*; import com.example.likelion12.dto.crew.GetCrewDetailResponse; import com.example.likelion12.dto.crew.GetCrewInquiryResponse; @@ -39,10 +38,10 @@ public BaseResponse createCrew(@RequestHeader("Authorization") */ @GetMapping("/inquiry") public BaseResponse> getCrewInquiries(@RequestHeader("Authorization") String authorization, - @RequestBody SearchRequest searchRequest){ + @RequestParam int page){ log.info("[CrewController.getCrewInquiries]"); Long memberId = jwtProvider.extractIdFromHeader(authorization); - return new BaseResponse<>(crewService.getCrewInquiries(memberId,searchRequest)); + return new BaseResponse<>(crewService.getCrewInquiries(memberId,page)); } diff --git a/src/main/java/com/example/likelion12/dto/SearchRequest.java b/src/main/java/com/example/likelion12/dto/SearchRequest.java deleted file mode 100644 index ed43c36..0000000 --- a/src/main/java/com/example/likelion12/dto/SearchRequest.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.example.likelion12.dto; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public class SearchRequest { - - private int page; // 현재 페이지 번호 - - public int getOffset() { - return (page - 1) * 9; - } -} diff --git a/src/main/java/com/example/likelion12/service/CrewService.java b/src/main/java/com/example/likelion12/service/CrewService.java index 629ff4c..490ce7a 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.java @@ -5,7 +5,6 @@ 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.SearchRequest; import com.example.likelion12.dto.crew.*; import com.example.likelion12.repository.*; import lombok.RequiredArgsConstructor; @@ -77,14 +76,14 @@ public PostCrewResponse createCrew(Long memberId, PostCrewRequest postCrewReques /** * 크루 조회 */ - public List getCrewInquiries(Long memberId, SearchRequest searchRequest) { + public List getCrewInquiries(Long memberId, int page) { log.info("[CrewService.getCrewInquiries]"); List allCrews = crewRepository.findAllByStatus(BaseStatus.ACTIVE); List getCrewInquiryResponses = new ArrayList<>(); // offset과 limit 계산 - int offset = searchRequest.getOffset(); + int offset = (page - 1) * 9; int recordSize = 9 ; // 페이징 처리된 크루 목록 생성 From d848a6b272816e9e5d2832be0b8c84805efa4197 Mon Sep 17 00:00:00 2001 From: jungeun Date: Tue, 6 Aug 2024 01:56:14 +0900 Subject: [PATCH 44/44] =?UTF-8?q?fix=20:=20import=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/likelion12/controller/CrewController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/example/likelion12/controller/CrewController.java b/src/main/java/com/example/likelion12/controller/CrewController.java index 651dff4..29331b0 100644 --- a/src/main/java/com/example/likelion12/controller/CrewController.java +++ b/src/main/java/com/example/likelion12/controller/CrewController.java @@ -1,6 +1,7 @@ package com.example.likelion12.controller; import com.example.likelion12.common.response.BaseResponse; +import com.example.likelion12.common.response.status.BaseExceptionResponseStatus; import com.example.likelion12.dto.crew.*; import com.example.likelion12.service.CrewService; import com.example.likelion12.util.*;