From 6d8146734511a962c0815ec0c3a878f7276a3f7f Mon Sep 17 00:00:00 2001 From: "tae.y" <0211ilyoil@gmail.com> Date: Sun, 22 Sep 2024 11:31:53 +0900 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20(#761)=20=EC=BA=90=EC=8B=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/aliens/dms/domain/student/StudentWebAdapter.kt | 9 --------- 1 file changed, 9 deletions(-) diff --git a/dms-presentation/src/main/kotlin/team/aliens/dms/domain/student/StudentWebAdapter.kt b/dms-presentation/src/main/kotlin/team/aliens/dms/domain/student/StudentWebAdapter.kt index fd48f0e75..293b45b41 100644 --- a/dms-presentation/src/main/kotlin/team/aliens/dms/domain/student/StudentWebAdapter.kt +++ b/dms-presentation/src/main/kotlin/team/aliens/dms/domain/student/StudentWebAdapter.kt @@ -59,7 +59,6 @@ import team.aliens.dms.domain.student.usecase.UpdateStudentProfileUseCase import team.aliens.dms.domain.student.usecase.UpdateStudentRoomByFileUseCase import java.util.UUID -@CacheConfig(cacheNames = ["student"]) @Validated @RequestMapping("/students") @RestController @@ -161,7 +160,6 @@ class StudentWebAdapter( return checkStudentGcnUseCase.execute(request) } - @CacheEvict(allEntries = true) @ResponseStatus(HttpStatus.NO_CONTENT) @PatchMapping("/profile") fun updateProfile(@RequestBody @Valid webRequest: UpdateStudentProfileWebRequest) { @@ -173,7 +171,6 @@ class StudentWebAdapter( return studentMyPageUseCase.execute() } - @CacheEvict(allEntries = true) @ResponseStatus(HttpStatus.NO_CONTENT) @DeleteMapping fun withdrawal() { @@ -187,7 +184,6 @@ class StudentWebAdapter( return response.file } - @Cacheable @GetMapping("/manager") fun managerGetAllStudents( @RequestParam(required = false) name: String?, @@ -209,34 +205,29 @@ class StudentWebAdapter( ) } - @Cacheable @GetMapping("/{student-id}") fun getStudentDetails(@PathVariable("student-id") @NotNull studentId: UUID): StudentDetailsResponse { return queryStudentDetailsUseCase.execute(studentId) } - @CacheEvict(allEntries = true) @ResponseStatus(HttpStatus.NO_CONTENT) @DeleteMapping("/{student-id}") fun deleteStudent(@PathVariable("student-id") @NotNull studentId: UUID) { removeStudentUseCase.execute(studentId) } - @CacheEvict(allEntries = true) @ResponseStatus(HttpStatus.NO_CONTENT) @PostMapping("/file/room") fun updateStudentRoomByFile(@RequestPart @NotNull file: MultipartFile?) { updateStudentRoomByFileUseCase.execute(file!!.toFile()) } - @CacheEvict(allEntries = true) @ResponseStatus(HttpStatus.NO_CONTENT) @PostMapping("/file/gcn") fun updateStudentGcnByFile(@RequestPart @NotNull file: MultipartFile?) { updateStudentGcnByFileUseCase.execute(file!!.toFile()) } - @CacheEvict(allEntries = true) @ResponseStatus(HttpStatus.CREATED) @PostMapping("/verified-student") fun importVerifiedStudentFromExcel(@RequestPart @NotNull file: MultipartFile?) { From c47bc986fcb56f7ba2e599a316904ac960e9a70f Mon Sep 17 00:00:00 2001 From: 4mjeo <4mj.eo@dsm.hs.kr> Date: Sun, 22 Sep 2024 12:36:53 +0900 Subject: [PATCH 2/4] =?UTF-8?q?refactor:=20(#763)=20json=20=EC=97=AD?= =?UTF-8?q?=EC=A7=81=EB=A0=AC=ED=99=94=20=EB=AC=B8=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/aliens/dms/domain/tag/dto/TagResponse.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/dto/TagResponse.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/dto/TagResponse.kt index 12f19d5bb..7b55e1ba0 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/dto/TagResponse.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/dto/TagResponse.kt @@ -1,12 +1,15 @@ package team.aliens.dms.domain.tag.dto +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty import team.aliens.dms.domain.tag.model.Tag import java.util.UUID -data class TagResponse( - val id: UUID, - val name: String?, - val color: String? + +data class TagResponse @JsonCreator constructor( + @JsonProperty("id") val id: UUID, + @JsonProperty("name") val name: String?, + @JsonProperty("color") val color: String? ) { companion object { fun of(tag: Tag): TagResponse { From c3a20862bdea2fcb5fe54b958e07c901d86a18eb Mon Sep 17 00:00:00 2001 From: "tae.y" <0211ilyoil@gmail.com> Date: Sun, 22 Sep 2024 12:41:51 +0900 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20(#763)=20=EC=BA=90=EC=8B=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildSrc/src/main/kotlin/Dependencies.kt | 2 - dms-infrastructure/build.gradle.kts | 2 - .../aliens/dms/global/config/CacheConfig.kt | 46 ------------------- .../dms/global/config/CustomKeyGenerator.kt | 21 --------- .../dms/domain/student/StudentWebAdapter.kt | 3 -- 5 files changed, 74 deletions(-) delete mode 100644 dms-persistence/src/main/kotlin/team/aliens/dms/global/config/CacheConfig.kt delete mode 100644 dms-persistence/src/main/kotlin/team/aliens/dms/global/config/CustomKeyGenerator.kt diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index b8c182a73..4cd81d9b8 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -85,6 +85,4 @@ object Dependencies { // slack const val SLACK = "com.slack.api:slack-api-client:${DependencyVersions.SLACK_VERSION}" - - const val CACHE = "org.springframework.boot:spring-boot-starter-cache" } \ No newline at end of file diff --git a/dms-infrastructure/build.gradle.kts b/dms-infrastructure/build.gradle.kts index 51d9cba50..d35e27a98 100644 --- a/dms-infrastructure/build.gradle.kts +++ b/dms-infrastructure/build.gradle.kts @@ -60,8 +60,6 @@ dependencies { // notification implementation(Dependencies.FCM) - //cache - implementation(Dependencies.CACHE) } tasks.getByName("jar") { diff --git a/dms-persistence/src/main/kotlin/team/aliens/dms/global/config/CacheConfig.kt b/dms-persistence/src/main/kotlin/team/aliens/dms/global/config/CacheConfig.kt deleted file mode 100644 index c120cb843..000000000 --- a/dms-persistence/src/main/kotlin/team/aliens/dms/global/config/CacheConfig.kt +++ /dev/null @@ -1,46 +0,0 @@ -package team.aliens.dms.global.config - -import org.springframework.boot.autoconfigure.cache.RedisCacheManagerBuilderCustomizer -import org.springframework.cache.CacheManager -import org.springframework.cache.annotation.EnableCaching -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.data.redis.cache.RedisCacheConfiguration -import org.springframework.data.redis.cache.RedisCacheManager -import org.springframework.data.redis.connection.RedisConnectionFactory -import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer -import org.springframework.data.redis.serializer.RedisSerializationContext -import org.springframework.data.redis.serializer.StringRedisSerializer -import java.time.Duration - -@Configuration -@EnableCaching -class CacheConfig { - @Bean - fun cacheManager(redisConnectionFactory: RedisConnectionFactory): CacheManager { - val redisCacheConfiguration: RedisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig() - .entryTtl(Duration.ofMinutes(30)) - .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(StringRedisSerializer())) - .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(GenericJackson2JsonRedisSerializer())) - - return RedisCacheManager.RedisCacheManagerBuilder - .fromConnectionFactory(redisConnectionFactory) - .cacheDefaults(redisCacheConfiguration) - .build() - } - - // 캐시를 구분하기 위해 존재함 - @Bean - fun redisCacheManagerBuilderCustomizer(): RedisCacheManagerBuilderCustomizer { - return RedisCacheManagerBuilderCustomizer { builder: RedisCacheManager.RedisCacheManagerBuilder -> - builder - .withCacheConfiguration( - "student", - RedisCacheConfiguration.defaultCacheConfig() - .entryTtl(Duration.ofMinutes(10)) - .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(StringRedisSerializer())) - .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(GenericJackson2JsonRedisSerializer())) - ) - } - } -} diff --git a/dms-persistence/src/main/kotlin/team/aliens/dms/global/config/CustomKeyGenerator.kt b/dms-persistence/src/main/kotlin/team/aliens/dms/global/config/CustomKeyGenerator.kt deleted file mode 100644 index 30264b212..000000000 --- a/dms-persistence/src/main/kotlin/team/aliens/dms/global/config/CustomKeyGenerator.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.aliens.dms.global.config - -import org.springframework.cache.interceptor.KeyGenerator -import org.springframework.cache.interceptor.SimpleKeyGenerator -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import java.lang.reflect.Method - -@Configuration -class CustomKeyGenerator : KeyGenerator { - - // 메서드 명을 사용해 key를 만들어준다. - override fun generate(target: Any, method: Method, vararg params: Any): Any { - return method.name + SimpleKeyGenerator.generateKey(*params) - } - - @Bean - fun keyGenerator(): KeyGenerator { - return CustomKeyGenerator() - } -} diff --git a/dms-presentation/src/main/kotlin/team/aliens/dms/domain/student/StudentWebAdapter.kt b/dms-presentation/src/main/kotlin/team/aliens/dms/domain/student/StudentWebAdapter.kt index 293b45b41..14a123e2a 100644 --- a/dms-presentation/src/main/kotlin/team/aliens/dms/domain/student/StudentWebAdapter.kt +++ b/dms-presentation/src/main/kotlin/team/aliens/dms/domain/student/StudentWebAdapter.kt @@ -5,9 +5,6 @@ import jakarta.validation.Valid import jakarta.validation.constraints.Email import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.NotNull -import org.springframework.cache.annotation.CacheConfig -import org.springframework.cache.annotation.CacheEvict -import org.springframework.cache.annotation.Cacheable import org.springframework.http.HttpStatus import org.springframework.validation.annotation.Validated import org.springframework.web.bind.annotation.DeleteMapping From dfbbf1b08530229e5f5620d9e16d974bd952b1ca Mon Sep 17 00:00:00 2001 From: 4mjeo <4mj.eo@dsm.hs.kr> Date: Sun, 22 Sep 2024 13:00:55 +0900 Subject: [PATCH 4/4] =?UTF-8?q?refactor:=20(#763)=20=EC=A7=81=EB=A0=AC?= =?UTF-8?q?=ED=99=94=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dms/domain/student/dto/StudentResponse.kt | 25 ++++++++----------- .../aliens/dms/domain/tag/dto/TagResponse.kt | 10 +++----- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/student/dto/StudentResponse.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/student/dto/StudentResponse.kt index 0cdde9a56..43167b2e6 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/student/dto/StudentResponse.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/student/dto/StudentResponse.kt @@ -1,8 +1,5 @@ package team.aliens.dms.domain.student.dto -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty import team.aliens.dms.domain.manager.spi.vo.StudentWithTag import team.aliens.dms.domain.student.model.Sex import team.aliens.dms.domain.student.model.Student @@ -49,17 +46,17 @@ data class StudentNameResponse( val name: String ) -data class StudentDetailsResponse @JsonCreator constructor( - @JsonProperty("id") val id: UUID, - @JsonProperty("name") val name: String, - @JsonProperty("gcn") val gcn: String, - @JsonProperty("profileImageUrl") val profileImageUrl: String, - @JsonProperty("sex") val sex: Sex? = null, - @JsonProperty("bonusPoint") val bonusPoint: Int? = null, - @JsonProperty("minusPoint") val minusPoint: Int? = null, - @JsonProperty("roomNumber") val roomNumber: String? = null, - @JsonProperty("roomMates") val roomMates: List? = null, - @JsonProperty("tags") val tags: List? = null +data class StudentDetailsResponse( + val id: UUID, + val name: String, + val gcn: String, + val profileImageUrl: String, + val sex: Sex? = null, + val bonusPoint: Int? = null, + val minusPoint: Int? = null, + val roomNumber: String? = null, + val roomMates: List? = null, + val tags: List? = null ) { data class RoomMate( val id: UUID, diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/dto/TagResponse.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/dto/TagResponse.kt index 7b55e1ba0..829ff7cd9 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/dto/TagResponse.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/dto/TagResponse.kt @@ -1,15 +1,13 @@ package team.aliens.dms.domain.tag.dto -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty import team.aliens.dms.domain.tag.model.Tag import java.util.UUID -data class TagResponse @JsonCreator constructor( - @JsonProperty("id") val id: UUID, - @JsonProperty("name") val name: String?, - @JsonProperty("color") val color: String? +data class TagResponse( + val id: UUID, + val name: String?, + val color: String? ) { companion object { fun of(tag: Tag): TagResponse {