diff --git a/src/main/kotlin/andreas311/miso/domain/environment/application/port/input/dto/DetailEnvironmentDto.kt b/src/main/kotlin/andreas311/miso/domain/environment/application/port/input/dto/DetailEnvironmentDto.kt index 802431f9..569fd66a 100644 --- a/src/main/kotlin/andreas311/miso/domain/environment/application/port/input/dto/DetailEnvironmentDto.kt +++ b/src/main/kotlin/andreas311/miso/domain/environment/application/port/input/dto/DetailEnvironmentDto.kt @@ -3,13 +3,19 @@ package andreas311.miso.domain.environment.application.port.input.dto import andreas311.miso.domain.environment.domain.TodayEnvironment data class DetailEnvironmentDto( - val title: String = "", - val content: String = "", - val imageUrl: String? = "" + val title: String, + val content: String, + val imageUrl: String? ) { - constructor(todayEnvironment: TodayEnvironment): this( + constructor(todayEnvironment: TodayEnvironment) : this( title = todayEnvironment.title, content = todayEnvironment.content, imageUrl = todayEnvironment.imageUrl ) + + constructor() : this( + title = "", + content = "", + imageUrl = null + ) } diff --git a/src/main/kotlin/andreas311/miso/domain/item/application/port/input/dto/DetailItemDto.kt b/src/main/kotlin/andreas311/miso/domain/item/application/port/input/dto/DetailItemDto.kt index 8be7a0be..bfc1527b 100644 --- a/src/main/kotlin/andreas311/miso/domain/item/application/port/input/dto/DetailItemDto.kt +++ b/src/main/kotlin/andreas311/miso/domain/item/application/port/input/dto/DetailItemDto.kt @@ -3,12 +3,12 @@ package andreas311.miso.domain.item.application.port.input.dto import andreas311.miso.domain.item.domain.Item data class DetailItemDto( - val id: Long = 0L, - val price: Int = 0, - val amount: Int = 0, - val name: String = "", - val content: String = "", - val imageUrl: String? = "" + val id: Long, + val price: Int, + val amount: Int, + val name: String, + val content: String, + val imageUrl: String? ) { constructor(item: Item) : this( id = item.id, @@ -18,4 +18,13 @@ data class DetailItemDto( content = item.content, imageUrl = item.imageUrl ) + + constructor() : this( + id = 0, + price = 0, + amount = 0, + name = "", + content = "", + imageUrl = null + ) } diff --git a/src/main/kotlin/andreas311/miso/domain/item/application/port/input/dto/ItemDto.kt b/src/main/kotlin/andreas311/miso/domain/item/application/port/input/dto/ItemDto.kt index ce758fb1..ec0b0b9f 100644 --- a/src/main/kotlin/andreas311/miso/domain/item/application/port/input/dto/ItemDto.kt +++ b/src/main/kotlin/andreas311/miso/domain/item/application/port/input/dto/ItemDto.kt @@ -3,11 +3,11 @@ package andreas311.miso.domain.item.application.port.input.dto import andreas311.miso.domain.item.domain.Item data class ItemDto( - val id: Long = 0L, - val price: Int = 0, - val amount: Int = 0, - val name: String = "", - val imageUrl: String? = "" + val id: Long, + val price: Int, + val amount: Int, + val name: String, + val imageUrl: String? ) { constructor(item: Item) : this( id = item.id, @@ -16,4 +16,12 @@ data class ItemDto( name = item.name, imageUrl = item.imageUrl ) + + constructor() : this( + id = 0L, + price = 0, + amount = 0, + name = "", + imageUrl = null + ) } diff --git a/src/main/kotlin/andreas311/miso/domain/item/application/port/input/dto/ListItemDto.kt b/src/main/kotlin/andreas311/miso/domain/item/application/port/input/dto/ListItemDto.kt index 5f0c36c7..c50dacf7 100644 --- a/src/main/kotlin/andreas311/miso/domain/item/application/port/input/dto/ListItemDto.kt +++ b/src/main/kotlin/andreas311/miso/domain/item/application/port/input/dto/ListItemDto.kt @@ -2,4 +2,6 @@ package andreas311.miso.domain.item.application.port.input.dto data class ListItemDto( val itemList: List -) +) { + constructor() : this(emptyList()) +} diff --git a/src/main/kotlin/andreas311/miso/domain/item/application/service/CreateItemService.kt b/src/main/kotlin/andreas311/miso/domain/item/application/service/CreateItemService.kt index 18535ed5..fb0323fd 100644 --- a/src/main/kotlin/andreas311/miso/domain/item/application/service/CreateItemService.kt +++ b/src/main/kotlin/andreas311/miso/domain/item/application/service/CreateItemService.kt @@ -6,6 +6,7 @@ import andreas311.miso.domain.item.application.port.input.dto.CreateItemDto import andreas311.miso.domain.item.application.port.output.CommandItemPort import andreas311.miso.domain.item.domain.Item import andreas311.miso.thirdparty.aws.s3.util.S3Util +import org.springframework.cache.annotation.CacheEvict import org.springframework.web.multipart.MultipartFile @RollbackService @@ -13,6 +14,7 @@ class CreateItemService( private val s3Util: S3Util, private val commandItemPort: CommandItemPort ) : CreateItemUseCase { + @CacheEvict(cacheNames = ["itemList"], key = "'itemList'", cacheManager = "redisCacheManager") override fun execute(createItemDto: CreateItemDto, multipartFile: MultipartFile?) { val imageUrl = if (multipartFile != null) { diff --git a/src/main/kotlin/andreas311/miso/domain/item/application/service/DeleteItemService.kt b/src/main/kotlin/andreas311/miso/domain/item/application/service/DeleteItemService.kt index 9a2d5b9f..26a3b152 100644 --- a/src/main/kotlin/andreas311/miso/domain/item/application/service/DeleteItemService.kt +++ b/src/main/kotlin/andreas311/miso/domain/item/application/service/DeleteItemService.kt @@ -6,13 +6,17 @@ import andreas311.miso.domain.item.application.port.input.DeleteItemUseCase import andreas311.miso.domain.item.application.port.output.CommandItemPort import andreas311.miso.domain.item.application.port.output.QueryItemPort import org.springframework.cache.annotation.CacheEvict +import org.springframework.cache.annotation.Caching @RollbackService class DeleteItemService( private val queryItemPort: QueryItemPort, private val commandItemPort: CommandItemPort ) : DeleteItemUseCase { - @CacheEvict(cacheNames = ["item"], key = "#id", cacheManager = "redisCacheManager") + @Caching(evict = [ + CacheEvict(cacheNames = ["item"], key = "#id", cacheManager = "redisCacheManager"), + CacheEvict(cacheNames = ["itemList"], key = "'itemList'", cacheManager = "redisCacheManager") + ]) override fun execute(id: Long) { val itemEntity = queryItemPort.findByIdOrNull(id) ?: throw ItemNotFoundException() diff --git a/src/main/kotlin/andreas311/miso/domain/item/application/service/EditItemService.kt b/src/main/kotlin/andreas311/miso/domain/item/application/service/EditItemService.kt index bfe1f044..7d7748c1 100644 --- a/src/main/kotlin/andreas311/miso/domain/item/application/service/EditItemService.kt +++ b/src/main/kotlin/andreas311/miso/domain/item/application/service/EditItemService.kt @@ -8,6 +8,7 @@ import andreas311.miso.domain.item.application.port.output.QueryItemPort import andreas311.miso.domain.item.domain.Item import andreas311.miso.thirdparty.aws.s3.util.S3Util import org.springframework.cache.annotation.CacheEvict +import org.springframework.cache.annotation.Caching import org.springframework.stereotype.Component import org.springframework.web.multipart.MultipartFile @@ -17,7 +18,10 @@ class EditItemService( private val queryItemPort: QueryItemPort, private val commandItemPort: CommandItemPort ) : EditItemUseCase { - @CacheEvict(cacheNames = ["item"], key = "#id", cacheManager = "redisCacheManager") + @Caching(evict = [ + CacheEvict(cacheNames = ["item"], key = "#id", cacheManager = "redisCacheManager"), + CacheEvict(cacheNames = ["itemList"], key = "'itemList'", cacheManager = "redisCacheManager") + ]) override fun execute(id: Long, editItemDto: EditItemDto, multipartFile: MultipartFile?) { val item = queryItemPort.findByIdOrNull(id) ?: throw ItemNotFoundException() diff --git a/src/main/kotlin/andreas311/miso/domain/item/application/service/ListItemService.kt b/src/main/kotlin/andreas311/miso/domain/item/application/service/ListItemService.kt index a6d64a77..779bba4c 100644 --- a/src/main/kotlin/andreas311/miso/domain/item/application/service/ListItemService.kt +++ b/src/main/kotlin/andreas311/miso/domain/item/application/service/ListItemService.kt @@ -5,11 +5,13 @@ import andreas311.miso.domain.item.application.port.input.ListItemUseCase import andreas311.miso.domain.item.application.port.input.dto.ItemDto import andreas311.miso.domain.item.application.port.input.dto.ListItemDto import andreas311.miso.domain.item.application.port.output.QueryItemPort +import org.springframework.cache.annotation.Cacheable @ReadOnlyRollbackService class ListItemService( private val queryItemPort: QueryItemPort ) : ListItemUseCase { + @Cacheable(cacheNames = ["itemList"], key = "'itemList'", cacheManager = "redisCacheManager") override fun execute(): ListItemDto { return ListItemDto( itemList = queryItemPort.findAll() diff --git a/src/main/kotlin/andreas311/miso/domain/notification/application/port/input/dto/DetailNotificationDto.kt b/src/main/kotlin/andreas311/miso/domain/notification/application/port/input/dto/DetailNotificationDto.kt index e3e7888e..be5d725a 100644 --- a/src/main/kotlin/andreas311/miso/domain/notification/application/port/input/dto/DetailNotificationDto.kt +++ b/src/main/kotlin/andreas311/miso/domain/notification/application/port/input/dto/DetailNotificationDto.kt @@ -3,9 +3,13 @@ package andreas311.miso.domain.notification.application.port.input.dto import andreas311.miso.domain.notification.domain.Notification data class DetailNotificationDto( - val answer: String = "" + val answer: String ) { constructor(notification: Notification) : this( answer = notification.answer ) + + constructor() : this( + answer = "" + ) } diff --git a/src/main/kotlin/andreas311/miso/domain/recyclables/application/port/input/dto/DetailRecyclablesDto.kt b/src/main/kotlin/andreas311/miso/domain/recyclables/application/port/input/dto/DetailRecyclablesDto.kt index 0917b078..8eeed59f 100644 --- a/src/main/kotlin/andreas311/miso/domain/recyclables/application/port/input/dto/DetailRecyclablesDto.kt +++ b/src/main/kotlin/andreas311/miso/domain/recyclables/application/port/input/dto/DetailRecyclablesDto.kt @@ -4,15 +4,15 @@ import andreas311.miso.domain.recyclables.domain.Recyclables import andreas311.miso.domain.recyclables.domain.RecyclablesType data class DetailRecyclablesDto( - val id: Long = 0L, - val title: String = "", - val subTitle: String = "", - val recycleMethod: String = "", - val recycleTip: String = "", - val recycleCaution: String = "", - val imageUrl: String? = "", - val recyclablesType: RecyclablesType = RecyclablesType.BAG, - val recycleMark: String = "" + val id: Long, + val title: String, + val subTitle: String, + val recycleMethod: String, + val recycleTip: String, + val recycleCaution: String, + val imageUrl: String?, + val recyclablesType: RecyclablesType, + val recycleMark: String ) { constructor(recyclables: Recyclables) : this( id = recyclables.id, @@ -25,4 +25,16 @@ data class DetailRecyclablesDto( recyclablesType = recyclables.recyclablesType, recycleMark = recyclables.recycleMark ) + + constructor() : this( + id = 0L, + title = "", + subTitle = "", + recycleMethod = "", + recycleTip = "", + recycleCaution = "", + imageUrl = null, + recyclablesType = RecyclablesType.BAG, + recycleMark = "" + ) } diff --git a/src/main/kotlin/andreas311/miso/domain/recyclables/application/port/input/dto/ListRecyclablesDto.kt b/src/main/kotlin/andreas311/miso/domain/recyclables/application/port/input/dto/ListRecyclablesDto.kt index 17b5e611..59df3071 100644 --- a/src/main/kotlin/andreas311/miso/domain/recyclables/application/port/input/dto/ListRecyclablesDto.kt +++ b/src/main/kotlin/andreas311/miso/domain/recyclables/application/port/input/dto/ListRecyclablesDto.kt @@ -2,4 +2,6 @@ package andreas311.miso.domain.recyclables.application.port.input.dto data class ListRecyclablesDto( val recyclablesList: List -) +) { + constructor() : this(emptyList()) +} diff --git a/src/main/kotlin/andreas311/miso/domain/recyclables/application/port/input/dto/RecyclablesDto.kt b/src/main/kotlin/andreas311/miso/domain/recyclables/application/port/input/dto/RecyclablesDto.kt index eb4d58ee..6b8308b2 100644 --- a/src/main/kotlin/andreas311/miso/domain/recyclables/application/port/input/dto/RecyclablesDto.kt +++ b/src/main/kotlin/andreas311/miso/domain/recyclables/application/port/input/dto/RecyclablesDto.kt @@ -15,4 +15,11 @@ data class RecyclablesDto( recycleMethod = recyclables.recycleMethod, recyclablesType = recyclables.recyclablesType ) + + constructor() : this( + title = "", + imageUrl = null, + recycleMethod = "", + recyclablesType = RecyclablesType.BAG + ) } diff --git a/src/main/kotlin/andreas311/miso/domain/recyclables/application/service/CreateRecyclablesService.kt b/src/main/kotlin/andreas311/miso/domain/recyclables/application/service/CreateRecyclablesService.kt index f6f18676..74457411 100644 --- a/src/main/kotlin/andreas311/miso/domain/recyclables/application/service/CreateRecyclablesService.kt +++ b/src/main/kotlin/andreas311/miso/domain/recyclables/application/service/CreateRecyclablesService.kt @@ -6,6 +6,7 @@ import andreas311.miso.domain.recyclables.application.port.input.dto.CreateRecyc import andreas311.miso.domain.recyclables.application.port.output.CommandRecyclablesPort import andreas311.miso.domain.recyclables.domain.Recyclables import andreas311.miso.thirdparty.aws.s3.util.S3Util +import org.springframework.cache.annotation.CacheEvict import org.springframework.web.multipart.MultipartFile @RollbackService @@ -13,6 +14,7 @@ class CreateRecyclablesService( private val s3Util: S3Util, private val commandRecyclablesPort: CommandRecyclablesPort ) : CreateRecyclablesUseCase { + @CacheEvict(cacheNames = ["recyclablesList"], key = "'recyclablesList'", cacheManager = "redisCacheManager") override fun execute(createRecyclablesDto: CreateRecyclablesDto, multipartFile: MultipartFile?) { val imageUrl = if (multipartFile != null) { diff --git a/src/main/kotlin/andreas311/miso/domain/recyclables/application/service/DeleteRecyclablesService.kt b/src/main/kotlin/andreas311/miso/domain/recyclables/application/service/DeleteRecyclablesService.kt index de8b397c..6400ecbc 100644 --- a/src/main/kotlin/andreas311/miso/domain/recyclables/application/service/DeleteRecyclablesService.kt +++ b/src/main/kotlin/andreas311/miso/domain/recyclables/application/service/DeleteRecyclablesService.kt @@ -12,7 +12,7 @@ class DeleteRecyclablesService( private val queryRecyclablesPort: QueryRecyclablesPort, private val commandRecyclablesPort: CommandRecyclablesPort ) : DeleteRecyclablesUseCase { - @CacheEvict(cacheNames = ["recyclables"], key = "#id", cacheManager = "redisCacheManager") + @CacheEvict(cacheNames = ["recyclablesList"], key = "'recyclablesList'", cacheManager = "redisCacheManager") override fun execute(id: Long) { val recyclablesEntity = queryRecyclablesPort.findByIdOrNull(id) ?: throw RecyclablesNotFoundException() diff --git a/src/main/kotlin/andreas311/miso/domain/recyclables/application/service/EditRecyclablesService.kt b/src/main/kotlin/andreas311/miso/domain/recyclables/application/service/EditRecyclablesService.kt index b6c0f126..e238e6d5 100644 --- a/src/main/kotlin/andreas311/miso/domain/recyclables/application/service/EditRecyclablesService.kt +++ b/src/main/kotlin/andreas311/miso/domain/recyclables/application/service/EditRecyclablesService.kt @@ -9,6 +9,7 @@ import andreas311.miso.domain.recyclables.application.port.output.QueryRecyclabl import andreas311.miso.domain.recyclables.domain.Recyclables import andreas311.miso.thirdparty.aws.s3.util.S3Util import org.springframework.cache.annotation.CacheEvict +import org.springframework.cache.annotation.Caching import org.springframework.web.multipart.MultipartFile @RollbackService @@ -17,7 +18,10 @@ class EditRecyclablesService( private val queryRecyclablesPort: QueryRecyclablesPort, private val commandRecyclablesPort: CommandRecyclablesPort ) : EditRecyclablesUseCase { - @CacheEvict(cacheNames = ["recyclables"], key = "#editRecyclablesDto.recyclablesType", cacheManager = "redisCacheManager") + @Caching(evict = [ + CacheEvict(cacheNames = ["recyclables"], key = "#editRecyclablesDto.recyclablesType", cacheManager = "redisCacheManager"), + CacheEvict(cacheNames = ["recyclablesList"], key = "'recyclablesList'", cacheManager = "redisCacheManager") + ]) override fun execute(id: Long, editRecyclablesDto: EditRecyclablesDto, multipartFile: MultipartFile?) { val recyclables = queryRecyclablesPort.findByIdOrNull(id) ?: throw RecyclablesNotFoundException() diff --git a/src/main/kotlin/andreas311/miso/domain/recyclables/application/service/ListRecyclablesService.kt b/src/main/kotlin/andreas311/miso/domain/recyclables/application/service/ListRecyclablesService.kt index 8a747453..40303375 100644 --- a/src/main/kotlin/andreas311/miso/domain/recyclables/application/service/ListRecyclablesService.kt +++ b/src/main/kotlin/andreas311/miso/domain/recyclables/application/service/ListRecyclablesService.kt @@ -5,11 +5,13 @@ import andreas311.miso.domain.recyclables.application.port.input.ListRecyclables import andreas311.miso.domain.recyclables.application.port.input.dto.ListRecyclablesDto import andreas311.miso.domain.recyclables.application.port.input.dto.RecyclablesDto import andreas311.miso.domain.recyclables.application.port.output.QueryRecyclablesPort +import org.springframework.cache.annotation.Cacheable @ReadOnlyRollbackService class ListRecyclablesService( private val queryRecyclablesPort: QueryRecyclablesPort ) : ListRecyclablesUseCase { + @Cacheable(cacheNames = ["recyclablesList"], key = "'recyclablesList'", cacheManager = "redisCacheManager") override fun execute(): ListRecyclablesDto { return ListRecyclablesDto( recyclablesList = queryRecyclablesPort.findAll() diff --git a/src/main/kotlin/andreas311/miso/domain/user/application/port/input/dto/PointDto.kt b/src/main/kotlin/andreas311/miso/domain/user/application/port/input/dto/PointDto.kt index dd21f99f..a7ca3f7c 100644 --- a/src/main/kotlin/andreas311/miso/domain/user/application/port/input/dto/PointDto.kt +++ b/src/main/kotlin/andreas311/miso/domain/user/application/port/input/dto/PointDto.kt @@ -3,9 +3,13 @@ package andreas311.miso.domain.user.application.port.input.dto import andreas311.miso.domain.user.domain.User data class PointDto( - val point: Int = 0 + val point: Int ) { constructor(user: User) : this( point = user.point ) + + constructor() : this( + point = 0 + ) } diff --git a/src/main/kotlin/andreas311/miso/domain/user/application/port/input/dto/UserInfoDto.kt b/src/main/kotlin/andreas311/miso/domain/user/application/port/input/dto/UserInfoDto.kt index 20fe5fa3..637f6ca9 100644 --- a/src/main/kotlin/andreas311/miso/domain/user/application/port/input/dto/UserInfoDto.kt +++ b/src/main/kotlin/andreas311/miso/domain/user/application/port/input/dto/UserInfoDto.kt @@ -5,13 +5,19 @@ import andreas311.miso.domain.user.domain.User import java.util.* data class UserInfoDto( - val id: UUID = UUID.randomUUID(), - val email: String = "", - val role: Role = Role.ROLE_USER + val id: UUID, + val email: String, + val role: Role ) { constructor(user: User) : this( id = user.id, email = user.email, role = user.role ) + + constructor() : this( + id = UUID.randomUUID(), + email = "", + role = Role.ROLE_USER + ) } diff --git a/src/main/kotlin/andreas311/miso/global/security/filter/JwtExceptionFilter.kt b/src/main/kotlin/andreas311/miso/global/security/filter/JwtExceptionFilter.kt index 0fca3696..d9eeb551 100644 --- a/src/main/kotlin/andreas311/miso/global/security/filter/JwtExceptionFilter.kt +++ b/src/main/kotlin/andreas311/miso/global/security/filter/JwtExceptionFilter.kt @@ -26,7 +26,7 @@ class JwtExceptionFilter : OncePerRequestFilter() { val errorCode = when (exception) { is ExpiredJwtException -> ErrorCode.TOKEN_IS_EXPIRED is JwtException, is IllegalArgumentException -> ErrorCode.TOKEN_NOT_VALID - else -> ErrorCode.UNKNOWN_ERROR + else -> ErrorCode.UNKNOWN_ERROR.also { exception.printStackTrace() } } setErrorResponse(errorCode, response) @@ -38,9 +38,6 @@ class JwtExceptionFilter : OncePerRequestFilter() { else -> "Exception" } log.debug("================= [ ExceptionHandlerFilter ] 에서 $debugMessage 발생 ===================") - if (exception is IllegalArgumentException) { - exception.printStackTrace() - } } } }