diff --git a/src/main/java/com/app/domain/categorizedproblem/service/CategorizedProblemService.java b/src/main/java/com/app/domain/categorizedproblem/service/CategorizedProblemService.java index a205b51..9308e16 100644 --- a/src/main/java/com/app/domain/categorizedproblem/service/CategorizedProblemService.java +++ b/src/main/java/com/app/domain/categorizedproblem/service/CategorizedProblemService.java @@ -230,7 +230,7 @@ public MemberSavedSummaryDto.pdfResponse createCategorizedProblemsPdf(Long categ } - @CacheEvict(value = "categorizedProblem", key = "#categoryId") + @CacheEvict(value = "categorizedProblem", key = "#result.getCategory().getCategoryId()") public CategorizedProblem updateCategorizedProblem(Long categorizedProblemId, MemberSavedProblemDto.Patch problemPatchDto) { CategorizedProblem categorizedProblem = findVerifiedCategorizedProblemByCategorizedProblemId(categorizedProblemId); problemService.updateProblem( @@ -247,16 +247,17 @@ public Page findCategorizedProblemsByCategoryId(Long categor return categorizedProblemRepository.findByCategoryCategoryId(categoryId, pageRequest); } - @CacheEvict(value = "categorizedProblem", key = "#categoryId") - public void deleteCategorizedProblem(Long categorizedProblemID){ + @CacheEvict(value = "categorizedProblem", key = "#result") + public Long deleteCategorizedProblem(Long categorizedProblemID) { CategorizedProblem categorizedProblem = findVerifiedCategorizedProblemByCategorizedProblemId(categorizedProblemID); - categorizedProblemRepository.deleteById(categorizedProblemID); + categorizedProblemRepository.deleteById(categorizedProblem.getCategorizedProblemId()); Problem problem = categorizedProblem.getProblem(); Long problemId = problem.getProblemId(); if (problem.isMemberSavedProblem() && !isProblemUsedInOtherCategorizedProblems(problemId)) { problemService.deleteProblem(problemId); } + return categorizedProblem.getCategory().getCategoryId(); } private boolean isProblemUsedInOtherCategorizedProblems(Long problemId) { diff --git a/src/main/java/com/app/domain/categorizedsummary/service/CategorizedSummaryService.java b/src/main/java/com/app/domain/categorizedsummary/service/CategorizedSummaryService.java index 54e068c..c3678bc 100644 --- a/src/main/java/com/app/domain/categorizedsummary/service/CategorizedSummaryService.java +++ b/src/main/java/com/app/domain/categorizedsummary/service/CategorizedSummaryService.java @@ -76,7 +76,7 @@ public SummaryDto.pdfResponse createSummaryPdf(Long categorizedSummaryId) throws return summaryService.createSummaryPdf(summaryId); } - @CacheEvict(value = "categorizedSummary", key = "#categoryId") + @CacheEvict(value = "categorizedSummary", key = "#result.getCategory().getCategoryId()") public CategorizedSummary updateCategorizedSummary(Long categorizedSummaryId, SummaryDto.Patch summaryPatchDto) { CategorizedSummary categorizedSummary = findVerifiedCategorizedSummaryByCategorizedSummaryId(categorizedSummaryId); summaryService.updateSummary( @@ -87,8 +87,8 @@ public CategorizedSummary updateCategorizedSummary(Long categorizedSummaryId, Su return categorizedSummaryRepository.save(categorizedSummary); } - @CacheEvict(value = "categorizedSummary", key = "#categoryId") - public void deleteCategorizedSummary(Long categorizedSummaryId) { + @CacheEvict(value = "categorizedSummary", key = "#result") + public Long deleteCategorizedSummary(Long categorizedSummaryId) { CategorizedSummary categorizedSummary = findVerifiedCategorizedSummaryByCategorizedSummaryId(categorizedSummaryId); categorizedSummaryRepository.deleteById(categorizedSummaryId); @@ -98,6 +98,8 @@ public void deleteCategorizedSummary(Long categorizedSummaryId) { if (summary.isMemberSavedSummary() && !isSummaryUsedInOtherCategorizedSummarys(summaryId)) { summaryRepository.deleteById(summaryId); } + Long categoryId = categorizedSummary.getCategory().getCategoryId(); + return categoryId; } private boolean isSummaryUsedInOtherCategorizedSummarys(Long summaryId){ diff --git a/src/main/java/com/app/fake/FakeLoginController.java b/src/main/java/com/app/fake/FakeLoginController.java new file mode 100644 index 0000000..ef57c48 --- /dev/null +++ b/src/main/java/com/app/fake/FakeLoginController.java @@ -0,0 +1,39 @@ +package com.app.fake; + +import com.app.domain.member.constant.MemberType; +import com.app.domain.member.constant.Role; +import com.app.domain.member.entity.Member; +import com.app.domain.member.service.MemberService; +import com.app.global.jwt.dto.JwtTokenDto; +import com.app.global.jwt.service.TokenManager; +import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Profile; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RequiredArgsConstructor +@Profile(value = {"local", "test"}) +@RestController +public class FakeLoginController { + + private final MemberService memberService; + private final TokenManager tokenManager; + + @PostMapping("/api/fake/login") + public ResponseEntity fakeSignUp(@RequestBody FakeSignUpRequest request) { + Member member = memberService.findMemberByEmail(request.getEmail()).orElseGet( + () -> memberService.registerMember(Member.builder() + .nickName(request.getNickname()) + .email(request.getEmail()) + .memberType(MemberType.KAKAO) + .role(Role.USER) + .build()) + ); + + JwtTokenDto jwtTokenDto = tokenManager.createJwtTokenDto(member.getMemberId(), member.getRole()); + member.updateRefreshToken(jwtTokenDto); + return ResponseEntity.ok(jwtTokenDto.getAccessToken()); + } +} diff --git a/src/main/java/com/app/fake/FakeSignUpRequest.java b/src/main/java/com/app/fake/FakeSignUpRequest.java new file mode 100644 index 0000000..087d383 --- /dev/null +++ b/src/main/java/com/app/fake/FakeSignUpRequest.java @@ -0,0 +1,17 @@ +package com.app.fake; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class FakeSignUpRequest { + + private String nickname; + private String email; + + public FakeSignUpRequest(String nickname, String email) { + this.nickname = nickname; + this.email = email; + } +}