From 7007c52af637c36f55b17c8ccdcf751fe0d2f559 Mon Sep 17 00:00:00 2001 From: hocaron Date: Sat, 17 Aug 2024 15:25:52 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=8C=9D=EC=97=85=20=EC=B4=88=EA=B8=B0?= =?UTF-8?q?=ED=99=94=20api=20=EB=A5=BC=20=EC=B6=94=EA=B0=80=ED=95=98?= =?UTF-8?q?=EB=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/popup/MemberPopupService.java | 4 + .../popup/MemberPopupFacadeService.java | 9 ++ .../ui/popup/MemberPopupController.java | 117 ++++++++++-------- 3 files changed, 78 insertions(+), 52 deletions(-) diff --git a/mashup-domain/src/main/java/kr/mashup/branding/service/popup/MemberPopupService.java b/mashup-domain/src/main/java/kr/mashup/branding/service/popup/MemberPopupService.java index 0702333f..19dcd901 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/service/popup/MemberPopupService.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/service/popup/MemberPopupService.java @@ -31,4 +31,8 @@ public Boolean isEnabledMemberPopup(Member member, PopupType popupType) { // 페이지에 방문하지 않은 경우(팝업 상태 활성화) && 마지막으로 본 일자가 현재 보다 과거인 경우 return memberPopup.get().getIsEnabled() && memberPopup.get().getLastViewedAt().toLocalDate().isBefore(LocalDate.now()); } + + public void deleteMemberPopup(Member member) { + memberPopupRepository.deleteByMember(member); + } } diff --git a/mashup-member/src/main/java/kr/mashup/branding/facade/popup/MemberPopupFacadeService.java b/mashup-member/src/main/java/kr/mashup/branding/facade/popup/MemberPopupFacadeService.java index 8eaa75d7..eb4413e6 100644 --- a/mashup-member/src/main/java/kr/mashup/branding/facade/popup/MemberPopupFacadeService.java +++ b/mashup-member/src/main/java/kr/mashup/branding/facade/popup/MemberPopupFacadeService.java @@ -1,9 +1,11 @@ package kr.mashup.branding.facade.popup; +import kr.mashup.branding.domain.member.Member; import kr.mashup.branding.domain.member.MemberGeneration; import kr.mashup.branding.domain.member.exception.InactiveGenerationException; import kr.mashup.branding.domain.popup.MemberPopup; import kr.mashup.branding.domain.popup.PopupType; +import kr.mashup.branding.repository.member.MemberRepository; import kr.mashup.branding.security.MemberAuth; import kr.mashup.branding.service.danggn.DanggnRankingRoundService; import kr.mashup.branding.service.member.MemberProfileService; @@ -27,6 +29,7 @@ public class MemberPopupFacadeService { private final MemberService memberService; private final DanggnRankingRoundService danggnRankingRoundService; private final MemberProfileService memberProfileService; + private final MemberRepository memberRepository; public List getEnabledPopupTypes( MemberAuth memberAuth @@ -91,4 +94,10 @@ private MemberPopup getUpdatableByMemberGenerationAndType( return memberPopupService.findOrSaveMemberPopupByMemberAndType(memberGeneration.getMember(), popupType); } + + @Transactional + public void deleteMemberPopup(Long memberId) { + Member member = memberService.findMemberById(memberId); + memberPopupService.deleteMemberPopup(member); + } } diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/popup/MemberPopupController.java b/mashup-member/src/main/java/kr/mashup/branding/ui/popup/MemberPopupController.java index 87ee5d25..c1b87546 100644 --- a/mashup-member/src/main/java/kr/mashup/branding/ui/popup/MemberPopupController.java +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/popup/MemberPopupController.java @@ -7,6 +7,7 @@ import kr.mashup.branding.ui.ApiResponse; import kr.mashup.branding.ui.EmptyResponse; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; @@ -17,62 +18,74 @@ @RequiredArgsConstructor public class MemberPopupController { - private final MemberPopupFacadeService memberPopupFacadeService; + private final MemberPopupFacadeService memberPopupFacadeService; - @ApiOperation( - value = "멤버가 볼 수 있는 팝업 조회", - notes = - "

Error Code

" + - "

" + - "MEMBER_GENERATION_NOT_FOUND
" + - "STORAGE_NOT_FOUND
" + - "

" + @ApiOperation( + value = "멤버가 볼 수 있는 팝업 조회", + notes = + "

Error Code

" + + "

" + + "MEMBER_GENERATION_NOT_FOUND
" + + "STORAGE_NOT_FOUND
" + + "

" - ) - @GetMapping - public ApiResponse> getEnabledPopupTypes( - @ApiIgnore MemberAuth memberAuth - ) { - return ApiResponse.success(memberPopupFacadeService.getEnabledPopupTypes(memberAuth)); - } + ) + @GetMapping + public ApiResponse> getEnabledPopupTypes( + @ApiIgnore MemberAuth memberAuth + ) { + return ApiResponse.success(memberPopupFacadeService.getEnabledPopupTypes(memberAuth)); + } - @ApiOperation( - value = "팝업 비활성화", - notes = - "

Error Code

" + - "

" + - "MEMBER_GENERATION_NOT_FOUND
" + - "STORAGE_NOT_FOUND
" + - "INACTIVE_GENERATION
" + - "

" + @ApiOperation( + value = "팝업 비활성화", + notes = + "

Error Code

" + + "

" + + "MEMBER_GENERATION_NOT_FOUND
" + + "STORAGE_NOT_FOUND
" + + "INACTIVE_GENERATION
" + + "

" - ) - @PatchMapping("/{popupType}/disabled") - public ApiResponse updateDisabled( - @ApiIgnore MemberAuth memberAuth, - @PathVariable PopupType popupType - ) { - memberPopupFacadeService.updateDisabled(memberAuth.getMemberGenerationId(), popupType); - return ApiResponse.success(); - } + ) + @PatchMapping("/{popupType}/disabled") + public ApiResponse updateDisabled( + @ApiIgnore MemberAuth memberAuth, + @PathVariable PopupType popupType + ) { + memberPopupFacadeService.updateDisabled(memberAuth.getMemberGenerationId(), popupType); + return ApiResponse.success(); + } - @ApiOperation( - value = "팝업 마지막 본 시간 업데이트", - notes = - "

Error Code

" + - "

" + - "MEMBER_GENERATION_NOT_FOUND
" + - "STORAGE_NOT_FOUND
" + - "INACTIVE_GENERATION
" + - "

" + @ApiOperation( + value = "팝업 마지막 본 시간 업데이트", + notes = + "

Error Code

" + + "

" + + "MEMBER_GENERATION_NOT_FOUND
" + + "STORAGE_NOT_FOUND
" + + "INACTIVE_GENERATION
" + + "

" - ) - @PatchMapping("/{popupType}/last-viewed") - public ApiResponse updateLastViewedAt( - @ApiIgnore MemberAuth memberAuth, - @PathVariable PopupType popupType - ) { - memberPopupFacadeService.updateLastViewedAt(memberAuth.getMemberGenerationId(), popupType); - return ApiResponse.success(); - } + ) + @PatchMapping("/{popupType}/last-viewed") + public ApiResponse updateLastViewedAt( + @ApiIgnore MemberAuth memberAuth, + @PathVariable PopupType popupType + ) { + memberPopupFacadeService.updateLastViewedAt(memberAuth.getMemberGenerationId(), popupType); + return ApiResponse.success(); + } + + @ApiOperation(value = "팝업 초기화(개발용)") + @DeleteMapping + public ApiResponse delete( + @ApiIgnore MemberAuth memberAuth, + @Value("${spring.profiles.active}") String activeProfile + ) { + if (!activeProfile.equals("production")) { + memberPopupFacadeService.deleteMemberPopup(memberAuth.getMemberId()); + } + return ApiResponse.success(); + } }