Skip to content

Commit

Permalink
Merge pull request #274 from team-haribo/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
KimGyeongsuuu authored Jul 3, 2024
2 parents e330fd6 + 33fb310 commit d5ad578
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.goms.v2.domain.account.resetProfileUrl
import com.goms.v2.domain.account.spi.S3UtilPort
import com.goms.v2.domain.auth.exception.AccountNotFoundException
import com.goms.v2.repository.account.AccountRepository
import org.springframework.cache.annotation.CacheEvict

@UseCaseWithTransaction
class DeleteImageUseCase(
Expand All @@ -15,6 +16,11 @@ class DeleteImageUseCase(
private val accountUtil: AccountUtil
) {

@CacheEvict(
value = ["userProfiles"],
key = "#root.target.generateCacheKey()",
cacheManager = "contentCacheManager"
)
fun execute() {
val accountIdx = accountUtil.getCurrentAccountIdx()
val account = accountRepository.findByIdOrNull(accountIdx) ?: throw AccountNotFoundException()
Expand All @@ -27,4 +33,8 @@ class DeleteImageUseCase(
accountRepository.save(account)
}

fun generateCacheKey(): String =
accountUtil.getCurrentAccountIdx().toString()


}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.goms.v2.repository.account.AccountRepository
import com.goms.v2.repository.outing.OutingBlackListRepository
import com.goms.v2.repository.outing.OutingRepository
import com.goms.v2.repository.studentCouncil.OutingUUIDRepository
import org.springframework.cache.annotation.CacheEvict
import java.time.LocalTime
import java.util.UUID

Expand All @@ -22,6 +23,11 @@ class OutingUseCase(
private val accountUtil: AccountUtil
) {

@CacheEvict(
value = ["userProfiles"],
key = "#root.target.generateCacheKey()",
cacheManager = "contentCacheManager"
)
fun execute(outingUUID: UUID) {
val accountIdx = accountUtil.getCurrentAccountIdx()
val account = accountRepository.findByIdOrNull(accountIdx) ?: throw AccountNotFoundException()
Expand All @@ -43,4 +49,8 @@ class OutingUseCase(
}
}

fun generateCacheKey(): String =
accountUtil.getCurrentAccountIdx().toString()


}

0 comments on commit d5ad578

Please sign in to comment.