Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -11,6 +11,7 @@
import com.jiwon.mylog.global.common.error.exception.NotFoundException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
Expand All @@ -36,6 +37,7 @@ public ImageResponse getProfileImage(Long userId) {
return ImageResponse.create(null, profileImage.getFileKey(), IMAGE_PROFILE);
}

@CacheEvict(value = "blog::home", key = "#userId", condition = "#userId != null")
@Transactional
public ImageResponse uploadProfileImage(Long userId, String fileName) {

Expand All @@ -54,6 +56,7 @@ public ImageResponse uploadProfileImage(Long userId, String fileName) {
return ImageResponse.create(response.getPresignedUrl(), response.getKey(), IMAGE_PROFILE);
}

@CacheEvict(value = "blog::home", key = "#userId", condition = "#userId != null")
@Transactional
public void deleteProfileImage(Long userId) {
User user = userRepository.findUserWithProfileImage(userId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public class PostService {
@CacheEvict(value = "post::notice", allEntries = true, condition = "#postRequest.type.equals('공지')"),
@CacheEvict(value = "post::main", allEntries = true, condition = "#postRequest.type.equals('일반 글')"),
@CacheEvict(value = "post::list", allEntries = true, condition = "#postRequest.type.equals('일반 글')"),
@CacheEvict(value = "post::filter", allEntries = true, condition = "#postRequest.type.equals('일반 글')")
@CacheEvict(value = "post::filter", allEntries = true, condition = "#postRequest.type.equals('일반 글')"),

@CacheEvict(value = "blog::home", key = "#userId", condition = "#userId != null")
}
)
@Transactional
Expand All @@ -74,7 +76,9 @@ public PostDetailResponse createPost(Long userId, PostRequest postRequest) {
@CacheEvict(value = "post::notice", allEntries = true, condition = "#postRequest.type.equals('공지')"),
@CacheEvict(value = "post::main", allEntries = true, condition = "#postRequest.type.equals('일반 글')"),
@CacheEvict(value = "post::list", allEntries = true, condition = "#postRequest.type.equals('일반 글')"),
@CacheEvict(value = "post::filter", allEntries = true, condition = "#postRequest.type.equals('일반 글')")
@CacheEvict(value = "post::filter", allEntries = true, condition = "#postRequest.type.equals('일반 글')"),

@CacheEvict(value = "blog::home", key = "#userId", condition = "#userId != null")
}
)
@Transactional
Expand All @@ -95,7 +99,9 @@ public PostDetailResponse updatePost(Long userId, Long postId, PostRequest postR
@CacheEvict(value = "post::detail", key = "#postId"),
@CacheEvict(value = "post::main", allEntries = true),
@CacheEvict(value = "post::list", allEntries = true),
@CacheEvict(value = "post::filter", allEntries = true)
@CacheEvict(value = "post::filter", allEntries = true),

@CacheEvict(value = "blog::home", key = "#userId", condition = "#userId != null")
})
@Transactional
public void deletePost(Long userId, Long postId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.jiwon.mylog.global.common.error.ErrorCode;
import com.jiwon.mylog.global.common.error.exception.NotFoundException;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -19,6 +20,7 @@ public class ReadmeService {
private final UserRepository userRepository;
private final ReadmeRepository readmeRepository;

@CacheEvict(value = "blog::home", key = "#userId", condition = "#userId != null")
@Transactional
public ReadmeResponse editReadme(Long userId, ReadmeRequest request) {
Readme readme = readmeRepository.findByUserId(userId).orElse(null);
Expand All @@ -34,6 +36,7 @@ public ReadmeResponse editReadme(Long userId, ReadmeRequest request) {
return ReadmeResponse.from(readmeRepository.save(readme));
}

@CacheEvict(value = "blog::home", key = "#userId", condition = "#userId != null")
@Transactional
public void deleteReadme(Long userId) {
Readme readme = readmeRepository.findByUserId(userId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.jiwon.mylog.global.common.error.ErrorCode;
import com.jiwon.mylog.global.common.error.exception.NotFoundException;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -26,6 +27,7 @@ public class UserBlogService {
private final PostRepository postRepository;
private final ReadmeRepository readmeRepository;

@Cacheable(value = "blog::home", key = "#userId", condition = "#userId != null")
@Transactional(readOnly = true)
public UserMainResponse getUserMain(Long userId) {
User user = userRepository.findUserWithProfileImage(userId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.jiwon.mylog.global.common.error.exception.DuplicateException;
import com.jiwon.mylog.global.common.error.exception.NotFoundException;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
Expand All @@ -37,6 +38,7 @@ public UserResponse getUserProfile(Long userId) {
return UserResponse.fromUser(user);
}

@CacheEvict(value = "blog::home", key = "#userId", condition = "#userId != null")
@Transactional
public UserResponse updateUserProfile(Long userId, UserProfileRequest userProfileRequest) {
User user = userRepository.findById(userId)
Expand Down