Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat : 소셜링 취소하기 #67

Merged
merged 5 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,17 @@ public BaseResponse<Void> joinSocialring(@RequestHeader("Authorization") String
socialringService.joinSocialring(memberId, socialringId);
return new BaseResponse<>(BaseExceptionResponseStatus.SUCCESS, null);
}

/**
* 소셜링 취소하기
*/
@PatchMapping("/cancel")
public BaseResponse<Void> cancelSocialring(@RequestHeader("Authorization") String authorization,
@RequestParam("socialringId") Long socialringId) {
log.info("[SocialringController.cancelSocialring]");
Long memberId = jwtProvider.extractIdFromHeader(authorization);
socialringService.cancelSocialring(memberId, socialringId);
return new BaseResponse<>(BaseExceptionResponseStatus.SUCCESS, null);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
1 change: 0 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ spring:
kakao:
client-id: ${CLIENT_ID}
redirect-uri: http://43.202.94.241:8080/auth/kakao/callback

---
jwt:
secret: ${JWT_SECRET}
Expand Down