Skip to content

Commit

Permalink
test: CommentController 캐시 기능 재구현
Browse files Browse the repository at this point in the history
  • Loading branch information
pandahwang committed Oct 8, 2024
1 parent a28a701 commit 3292058
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.TeamNull.LostArk.LostArk.controller;

import com.TeamNull.LostArk.LostArk.dto.CommentDto;
import com.TeamNull.LostArk.LostArk.entity.Comment;
import com.TeamNull.LostArk.LostArk.service.CommentService;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
Expand All @@ -24,7 +22,7 @@ public class CommentController {

private final CommentService commentService;

// @Cacheable(cacheNames = "getComments", key = "'comments:page:' + #page + ':searchText:' + #searchText", cacheManager = "commentCacheManager")
@Cacheable(cacheNames = "getComments", key = "'comments:page:' + #page + ':searchText:' + #searchText", cacheManager = "commentCacheManager")
@GetMapping("/{page}")
public Map<String, Object> commentPage(@PathVariable Integer page,
@RequestParam(required = false) String searchText,
Expand All @@ -34,7 +32,7 @@ public Map<String, Object> commentPage(@PathVariable Integer page,


@PostMapping("/{userID}")
// @CacheEvict(cacheNames = "getComments", allEntries = true, cacheManager = "commentCacheManager")
@CacheEvict(cacheNames = "getComments", allEntries = true, cacheManager = "commentCacheManager")
public void addComment(@PathVariable("userID") UUID userID, @RequestBody CommentDto commentDto)
{
commentService.getAddComment(commentDto.getContent(),
Expand All @@ -45,7 +43,7 @@ public void addComment(@PathVariable("userID") UUID userID, @RequestBody Comment
}

@DeleteMapping("/delete/{userID}/{commentId}")
// @CacheEvict(cacheNames = "getComments", allEntries = true, cacheManager = "commentCacheManager")
@CacheEvict(cacheNames = "getComments", allEntries = true, cacheManager = "commentCacheManager")
public ResponseEntity<String> commentDelete(@PathVariable("userID") UUID userID,
@PathVariable Integer commentId,
@RequestBody CommentDto dropComment)
Expand All @@ -54,7 +52,7 @@ public ResponseEntity<String> commentDelete(@PathVariable("userID") UUID userID,
}

@PutMapping("/update/{userID}/{commentId}")
// @CacheEvict(cacheNames = "getComments", allEntries = true, cacheManager = "commentCacheManager")
@CacheEvict(cacheNames = "getComments", allEntries = true, cacheManager = "commentCacheManager")
public ResponseEntity<String> commentUpdate(@PathVariable("userID") UUID userID,
@PathVariable int commentId,
@RequestBody CommentDto updatedComment) {
Expand Down

0 comments on commit 3292058

Please sign in to comment.