Skip to content

Commit

Permalink
feat: 팝업 초기화 api 를 추가하라
Browse files Browse the repository at this point in the history
  • Loading branch information
hocaron committed Aug 17, 2024
1 parent cdac7f1 commit 7007c52
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<PopupType> getEnabledPopupTypes(
MemberAuth memberAuth
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -17,62 +18,74 @@
@RequiredArgsConstructor
public class MemberPopupController {

private final MemberPopupFacadeService memberPopupFacadeService;
private final MemberPopupFacadeService memberPopupFacadeService;

@ApiOperation(
value = "멤버가 볼 수 있는 팝업 조회",
notes =
"<h2>Error Code</h2>" +
"<p>" +
"MEMBER_GENERATION_NOT_FOUND</br>" +
"STORAGE_NOT_FOUND</br>" +
"</p>"
@ApiOperation(
value = "멤버가 볼 수 있는 팝업 조회",
notes =
"<h2>Error Code</h2>" +
"<p>" +
"MEMBER_GENERATION_NOT_FOUND</br>" +
"STORAGE_NOT_FOUND</br>" +
"</p>"

)
@GetMapping
public ApiResponse<List<PopupType>> getEnabledPopupTypes(
@ApiIgnore MemberAuth memberAuth
) {
return ApiResponse.success(memberPopupFacadeService.getEnabledPopupTypes(memberAuth));
}
)
@GetMapping
public ApiResponse<List<PopupType>> getEnabledPopupTypes(
@ApiIgnore MemberAuth memberAuth
) {
return ApiResponse.success(memberPopupFacadeService.getEnabledPopupTypes(memberAuth));
}

@ApiOperation(
value = "팝업 비활성화",
notes =
"<h2>Error Code</h2>" +
"<p>" +
"MEMBER_GENERATION_NOT_FOUND</br>" +
"STORAGE_NOT_FOUND</br>" +
"INACTIVE_GENERATION</br>" +
"</p>"
@ApiOperation(
value = "팝업 비활성화",
notes =
"<h2>Error Code</h2>" +
"<p>" +
"MEMBER_GENERATION_NOT_FOUND</br>" +
"STORAGE_NOT_FOUND</br>" +
"INACTIVE_GENERATION</br>" +
"</p>"

)
@PatchMapping("/{popupType}/disabled")
public ApiResponse<EmptyResponse> updateDisabled(
@ApiIgnore MemberAuth memberAuth,
@PathVariable PopupType popupType
) {
memberPopupFacadeService.updateDisabled(memberAuth.getMemberGenerationId(), popupType);
return ApiResponse.success();
}
)
@PatchMapping("/{popupType}/disabled")
public ApiResponse<EmptyResponse> updateDisabled(
@ApiIgnore MemberAuth memberAuth,
@PathVariable PopupType popupType
) {
memberPopupFacadeService.updateDisabled(memberAuth.getMemberGenerationId(), popupType);
return ApiResponse.success();
}

@ApiOperation(
value = "팝업 마지막 본 시간 업데이트",
notes =
"<h2>Error Code</h2>" +
"<p>" +
"MEMBER_GENERATION_NOT_FOUND</br>" +
"STORAGE_NOT_FOUND</br>" +
"INACTIVE_GENERATION</br>" +
"</p>"
@ApiOperation(
value = "팝업 마지막 본 시간 업데이트",
notes =
"<h2>Error Code</h2>" +
"<p>" +
"MEMBER_GENERATION_NOT_FOUND</br>" +
"STORAGE_NOT_FOUND</br>" +
"INACTIVE_GENERATION</br>" +
"</p>"

)
@PatchMapping("/{popupType}/last-viewed")
public ApiResponse<EmptyResponse> updateLastViewedAt(
@ApiIgnore MemberAuth memberAuth,
@PathVariable PopupType popupType
) {
memberPopupFacadeService.updateLastViewedAt(memberAuth.getMemberGenerationId(), popupType);
return ApiResponse.success();
}
)
@PatchMapping("/{popupType}/last-viewed")
public ApiResponse<EmptyResponse> updateLastViewedAt(
@ApiIgnore MemberAuth memberAuth,
@PathVariable PopupType popupType
) {
memberPopupFacadeService.updateLastViewedAt(memberAuth.getMemberGenerationId(), popupType);
return ApiResponse.success();
}

@ApiOperation(value = "팝업 초기화(개발용)")
@DeleteMapping
public ApiResponse<EmptyResponse> delete(
@ApiIgnore MemberAuth memberAuth,
@Value("${spring.profiles.active}") String activeProfile
) {
if (!activeProfile.equals("production")) {
memberPopupFacadeService.deleteMemberPopup(memberAuth.getMemberId());
}
return ApiResponse.success();
}
}

0 comments on commit 7007c52

Please sign in to comment.