From 90db0f1417c514687882e2fefbf02ff8ae99b030 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Fri, 2 Aug 2024 20:00:54 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat=20:=20member=20socialring=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EC=98=88=EC=99=B8=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 | 3 ++- 1 file changed, 2 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 2785144..0b72216 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 @@ -40,10 +40,11 @@ public enum BaseExceptionResponseStatus implements ResponseStatus{ /** - * 8000: membersocialring 관련 + * 8000: member socialring 관련 */ CANNOT_FOUND_MEMBERSOCIALRING(8000, HttpStatus.BAD_REQUEST.value(), "해당하는 멤버소셜링을 찾을 수 없습니다."), CANNOT_MEMBERSOCIALRING_CAPTAIN(8001, HttpStatus.BAD_REQUEST.value(), "소셜링 수정,삭제에 접근할수없는 권한입니다."), + CANNOT_FOUND_MEMBERSOCIALRING_LIST(8002, HttpStatus.BAD_REQUEST.value(), "해당하는 멤버소셜링 리스트를 찾을 수 없습니다."), /** * 9000 : crew 관련 From ea46ffc6c0b3b1d99d66213e85e95d1aa9fe31ff Mon Sep 17 00:00:00 2001 From: hd0rable Date: Fri, 2 Aug 2024 20:01:19 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat=20:=20=EC=86=8C=EC=85=9C=EB=A7=81=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20response=20dto=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GetSocialringDetailResponse.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/main/java/com/example/likelion12/dto/socialring/GetSocialringDetailResponse.java diff --git a/src/main/java/com/example/likelion12/dto/socialring/GetSocialringDetailResponse.java b/src/main/java/com/example/likelion12/dto/socialring/GetSocialringDetailResponse.java new file mode 100644 index 0000000..34451bd --- /dev/null +++ b/src/main/java/com/example/likelion12/dto/socialring/GetSocialringDetailResponse.java @@ -0,0 +1,54 @@ +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; +import java.util.List; + +@Getter +@AllArgsConstructor +public class GetSocialringDetailResponse { + + /** + * 소셜링 상세 조회 response dto + */ + private BaseRole memberRole; + private String socialringName; + private String socialringImg; + private String activityRegionName; + private String facilityName; + private String exerciseName; + private int totalRecruits; + private LocalDate socialringDate; + private int socialringCost; + private String comment; + private String commentSimple; + private BaseGender gender; + private BaseLevel level; + private List members; + private List recommands; + + @Getter + @AllArgsConstructor + public static class Socialrings { + private String memberImg; + } + + @Getter + @AllArgsConstructor + public static class Recommands{ + 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 8ffcf16ac49b4b58b45468edfc14f4b6b47a20b2 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Fri, 2 Aug 2024 20:02:08 +0900 Subject: [PATCH 3/5] =?UTF-8?q?feat=20:=20=EC=86=8C=EC=85=9C=EB=A7=81=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=EB=A5=BC=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20=EB=A0=88=ED=8F=AC=EC=A7=80=ED=86=A0=EB=A6=AC=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 --- .../likelion12/repository/MemberSocialringRepository.java | 5 ++++- .../likelion12/repository/SocialringRepository.java | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/likelion12/repository/MemberSocialringRepository.java b/src/main/java/com/example/likelion12/repository/MemberSocialringRepository.java index 0e6a495..3eeef28 100644 --- a/src/main/java/com/example/likelion12/repository/MemberSocialringRepository.java +++ b/src/main/java/com/example/likelion12/repository/MemberSocialringRepository.java @@ -4,10 +4,13 @@ import com.example.likelion12.domain.base.BaseStatus; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.List; import java.util.Optional; public interface MemberSocialringRepository extends JpaRepository { - //Optional findByMemberIdAndSocialringIdAndStatus(Long memberId, Long socialringId, BaseStatus status); + Optional findByMember_MemberIdAndSocialring_SocialringIdAndStatus(Long memberId, Long socialringId, BaseStatus status); + Optional> findBySocialring_SocialringIdAndStatus(Long socialringId, BaseStatus baseStatus); } + diff --git a/src/main/java/com/example/likelion12/repository/SocialringRepository.java b/src/main/java/com/example/likelion12/repository/SocialringRepository.java index d0c0620..c71a7b2 100644 --- a/src/main/java/com/example/likelion12/repository/SocialringRepository.java +++ b/src/main/java/com/example/likelion12/repository/SocialringRepository.java @@ -2,13 +2,14 @@ import com.example.likelion12.domain.Socialring; import com.example.likelion12.domain.base.BaseStatus; +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.util.List; import java.util.Optional; -import java.util.Optional; public interface SocialringRepository extends JpaRepository { @@ -17,4 +18,9 @@ public interface SocialringRepository extends JpaRepository { Optional> findTop4ByOrderBySocialringDate(); Optional findBySocialringIdAndStatus(Long socialringId, BaseStatus status); + + // 특정 activity_region_id 값을 가진 상위 3개의 Socialring를 반환하는 쿼리 + @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); + } From 329c7aba17c6f3b8ff3b790a63400a0bb52dfe08 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Fri, 2 Aug 2024 20:02:23 +0900 Subject: [PATCH 4/5] =?UTF-8?q?feat=20:=20=EC=86=8C=EC=85=9C=EB=A7=81=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../likelion12/controller/SocialringController.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/example/likelion12/controller/SocialringController.java b/src/main/java/com/example/likelion12/controller/SocialringController.java index 7a8ae62..f1ea6af 100644 --- a/src/main/java/com/example/likelion12/controller/SocialringController.java +++ b/src/main/java/com/example/likelion12/controller/SocialringController.java @@ -2,6 +2,7 @@ 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; @@ -9,7 +10,6 @@ import com.example.likelion12.util.*; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; @Slf4j @@ -45,4 +45,15 @@ public BaseResponse modifySocialring(@RequestHeader("Authorization") Strin return new BaseResponse<>(BaseExceptionResponseStatus.SUCCESS, null); } + /** + * 소셜링 상세 조회 + */ + @GetMapping("") + public BaseResponse getSocialringDetail(@RequestHeader("Authorization") String authorization, + @RequestParam Long socialringId){ + log.info("[SocialringController.getSocialringDetail]"); + Long memberId = jwtProvider.extractIdFromHeader(authorization); + return new BaseResponse<>(socialringService.getSocialringDetail(memberId, socialringId)); + } + } From 24c35d41f022e3f8fb770d1ca616a3ce04ff35a9 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Fri, 2 Aug 2024 20:02:52 +0900 Subject: [PATCH 5/5] =?UTF-8?q?feat=20:=20=EC=86=8C=EC=85=9C=EB=A7=81=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../likelion12/service/SocialringService.java | 55 ++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/likelion12/service/SocialringService.java b/src/main/java/com/example/likelion12/service/SocialringService.java index 05e5506..80f71a7 100644 --- a/src/main/java/com/example/likelion12/service/SocialringService.java +++ b/src/main/java/com/example/likelion12/service/SocialringService.java @@ -5,16 +5,20 @@ 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.repository.*; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDate; +import java.util.List; +import java.util.stream.Collectors; import static com.example.likelion12.common.response.status.BaseExceptionResponseStatus.*; @@ -30,7 +34,9 @@ public class SocialringService { private final ActivityRegionRepository activityRegionRepository; private final MemberSocialringRepository memberSocialringRepository; - //소셜링등록 + /** + * 소셜링 등록 + */ @Transactional public PostSocialringResponse createSocialring(Long memberId, PostSocialringRequest postSocialringRequest) { log.info("[SocialringService.createSocialring]"); @@ -66,7 +72,9 @@ public PostSocialringResponse createSocialring(Long memberId, PostSocialringRequ return new PostSocialringResponse(socialring.getSocialringId()); } - //소셜링 수정 + /** + * 소셜링 수정 + */ @Transactional public void modifySocialring(Long memberId, Long socialringId, PatchSocialringModifyRequest patchSocialringModifyRequest) { log.info("[SocialringService.modifySocialring]"); @@ -138,6 +146,49 @@ public void modifySocialring(Long memberId, Long socialringId, PatchSocialringMo } + /** + * 소셜링 상세 조회 + */ + @Transactional + public GetSocialringDetailResponse getSocialringDetail(Long memberId, Long socialringId) { + log.info("[SocialringService.getSocialringDetail]"); + // 상세조회하고자 하는 소셜링 + Socialring socialring = socialringRepository.findBySocialringIdAndStatus(socialringId, BaseStatus.ACTIVE) + .orElseThrow(() -> new SocialringException(CANNOT_FOUND_SOCIALRING)); + // 상세조회하고자 하는 멤버의 멤버소셜링 + MemberSocialring memberSocialring = memberSocialringRepository.findByMember_MemberIdAndSocialring_SocialringIdAndStatus(memberId, + socialringId, BaseStatus.ACTIVE).orElseThrow(() -> new MemberSocialringException(CANNOT_FOUND_MEMBERSOCIALRING)); + // 소셜링에 등록된 멤버 리스트 추출 + List memberSocialringList = memberSocialringRepository.findBySocialring_SocialringIdAndStatus + (socialringId, BaseStatus.ACTIVE).orElseThrow(()-> new MemberSocialringException( CANNOT_FOUND_MEMBERSOCIALRING_LIST)); + // 소셜링에 등록된 멤버 리스트에서 사진만 추출해서 반환 + List memberImgList = memberSocialringList.stream() + .map(MemberSocialring -> new GetSocialringDetailResponse.Socialrings(memberSocialring.getMember().getMemberImg())) + .collect(Collectors.toList()); + + List recommandsList = socialringRepository.findTop3ByActivityRegionIdAndStatus( + socialring.getActivityRegion().getActivityRegionId(), BaseStatus.ACTIVE, Pageable.ofSize(3)) + .stream().map(socialrings -> new GetSocialringDetailResponse.Recommands( + socialrings.getSocialringId(), + socialrings.getSocialringName(), + socialrings.getSocialringImg(), + socialrings.getActivityRegion().getActivityRegionName(), + socialrings.getSocialringDate(), + socialrings.getSocialringCost(), + socialrings.getCommentSimple(), + socialrings.getMemberSocialringList().size(), + socialrings.getTotalRecruits() + )).collect(Collectors.toList()); + + GetSocialringDetailResponse getSocialringDetailResponse = new GetSocialringDetailResponse(memberSocialring.getRole(),socialring.getSocialringName(), + socialring.getSocialringImg(), socialring.getActivityRegion().getActivityRegionName(),socialring.getFacility().getFacilityName(), + socialring.getExercise().getExerciseName(),socialring.getTotalRecruits(),socialring.getSocialringDate(), + socialring.getSocialringCost(),socialring.getComment(),socialring.getCommentSimple(),socialring.getGender(), + socialring.getLevel(),memberImgList,recommandsList); + + return getSocialringDetailResponse; + + } }