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 1/4] =?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 2/4] =?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 3/4] =?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 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 4/4] =?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); }