From 6fb01e86060e2ac90e2bab5c840ec19205b3f41b Mon Sep 17 00:00:00 2001 From: GiJung <101462387+GiJungPark@users.noreply.github.com> Date: Tue, 12 Nov 2024 01:47:33 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B5=AC=EB=B2=84=EC=A0=84=20API=20Reqe?= =?UTF-8?q?ust=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/old/OldSubscribeController.kt | 2 +- .../request/OldKeywordsSubscribeRequest.kt | 4 +-- .../request/OldRegisterSubscribeRequest.kt | 9 ++++-- .../api/controller/old/request/Topic.kt | 30 +++++++++++++++++++ .../old/OldSubscribeControllerTest.kt | 9 ++---- 5 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 dmforu-api/src/main/kotlin/com/dmforu/api/controller/old/request/Topic.kt diff --git a/dmforu-api/src/main/kotlin/com/dmforu/api/controller/old/OldSubscribeController.kt b/dmforu-api/src/main/kotlin/com/dmforu/api/controller/old/OldSubscribeController.kt index 4576ae1..8365566 100644 --- a/dmforu-api/src/main/kotlin/com/dmforu/api/controller/old/OldSubscribeController.kt +++ b/dmforu-api/src/main/kotlin/com/dmforu/api/controller/old/OldSubscribeController.kt @@ -43,7 +43,7 @@ class OldSubscribeController( @Operation(summary = "[구버전] 키워드 알림 구독", description = "키워드 알림을 받도록 설정한다.") @PostMapping("/token/v1/dmu/updateTopic") fun oldKeywordsSubscribe(@RequestBody keywordsRequest: OldKeywordsSubscribeRequest): ResponseEntity { - oldSubscribeUpdater.subscribeKeywords(token = keywordsRequest.token, keywords = keywordsRequest.topics) + oldSubscribeUpdater.subscribeKeywords(token = keywordsRequest.token, keywords = keywordsRequest.topics.map { it.korean }) return ResponseEntity.ok().build() } diff --git a/dmforu-api/src/main/kotlin/com/dmforu/api/controller/old/request/OldKeywordsSubscribeRequest.kt b/dmforu-api/src/main/kotlin/com/dmforu/api/controller/old/request/OldKeywordsSubscribeRequest.kt index 69809ef..114f85e 100644 --- a/dmforu-api/src/main/kotlin/com/dmforu/api/controller/old/request/OldKeywordsSubscribeRequest.kt +++ b/dmforu-api/src/main/kotlin/com/dmforu/api/controller/old/request/OldKeywordsSubscribeRequest.kt @@ -1,7 +1,7 @@ package com.dmforu.api.controller.old.request @Deprecated("구버전 사용자를 위해 남겨둔 DTO 입니다.") -data class OldKeywordsSubscribeRequest ( +data class OldKeywordsSubscribeRequest( val token: String, - val topics: List + val topics: List, ) \ No newline at end of file diff --git a/dmforu-api/src/main/kotlin/com/dmforu/api/controller/old/request/OldRegisterSubscribeRequest.kt b/dmforu-api/src/main/kotlin/com/dmforu/api/controller/old/request/OldRegisterSubscribeRequest.kt index 2e4e6ea..07d7d86 100644 --- a/dmforu-api/src/main/kotlin/com/dmforu/api/controller/old/request/OldRegisterSubscribeRequest.kt +++ b/dmforu-api/src/main/kotlin/com/dmforu/api/controller/old/request/OldRegisterSubscribeRequest.kt @@ -2,11 +2,12 @@ package com.dmforu.api.controller.old.request import com.dmforu.domain.subscribe.Subscribe + @Deprecated("구버전 사용자를 위해 남겨둔 DTO 입니다.") data class OldRegisterSubscribeRequest( val token: String, val department: String, - val topic: List? + val topic: List?, ) { fun toSubscribe(): Subscribe { val isDepartmentSubscribed = department.isNotBlank() @@ -15,9 +16,13 @@ data class OldRegisterSubscribeRequest( return Subscribe.of( token = token, department = department, - keywords = topic ?: listOf(), + keywords = if (topic != null) convertToKeywords(topic) else listOf(), isDepartmentSubscribed = isDepartmentSubscribed, isKeywordSubscribed = areKeywordsSubscribed ) } + + private fun convertToKeywords(topics: List): List { + return topics.map { it.korean } + } } \ No newline at end of file diff --git a/dmforu-api/src/main/kotlin/com/dmforu/api/controller/old/request/Topic.kt b/dmforu-api/src/main/kotlin/com/dmforu/api/controller/old/request/Topic.kt new file mode 100644 index 0000000..1f02e0c --- /dev/null +++ b/dmforu-api/src/main/kotlin/com/dmforu/api/controller/old/request/Topic.kt @@ -0,0 +1,30 @@ +package com.dmforu.api.controller.old.request + +import com.dmforu.domain.Generated + +@Generated +enum class Topic (val korean: String){ + exam("시험"), + sign_up("수강"), + special_lecture("특강"), + seasonal_semester("계절학기"), + leave_of_absence("휴학"), + return_to_school("복학"), + graduate("졸업"), + switch_majors("전과"), + giving_up_the_semester("학기포기"), + scholarship("장학"), + national_scholarship("국가장학"), + registration("등록금"), + employment("채용"), + contest("공모전"), + competition("대회"), + field_training("현장실습"), + volunteer("봉사"), + dormitory("기숙사"), + group("동아리"), + student_council("학생회"), + overseas_training("해외연수"), + reserve_forces("예비군"), + work("근로"); +} \ No newline at end of file diff --git a/dmforu-api/src/test/kotlin/com/dmforu/api/controller/old/OldSubscribeControllerTest.kt b/dmforu-api/src/test/kotlin/com/dmforu/api/controller/old/OldSubscribeControllerTest.kt index e9dfa6a..3833a8c 100644 --- a/dmforu-api/src/test/kotlin/com/dmforu/api/controller/old/OldSubscribeControllerTest.kt +++ b/dmforu-api/src/test/kotlin/com/dmforu/api/controller/old/OldSubscribeControllerTest.kt @@ -1,10 +1,7 @@ package com.dmforu.api.controller.old import com.dmforu.api.ControllerTestSupport -import com.dmforu.api.controller.old.request.OldDepartmentRequest -import com.dmforu.api.controller.old.request.OldKeywordsSubscribeRequest -import com.dmforu.api.controller.old.request.OldRegisterSubscribeRequest -import com.dmforu.api.controller.old.request.OldTokenRequest +import com.dmforu.api.controller.old.request.* import org.junit.jupiter.api.Test import org.junit.jupiter.api.Assertions.* @@ -22,7 +19,7 @@ class OldSubscribeControllerTest : ControllerTestSupport() { val request = OldRegisterSubscribeRequest( token = "0001", department = "컴퓨터소프트웨어공학과", - topic = listOf("학사") + topic = listOf(Topic.exam, Topic.work) ) // when // then @@ -75,7 +72,7 @@ class OldSubscribeControllerTest : ControllerTestSupport() { // given val request = OldKeywordsSubscribeRequest( token = "0001", - topics = listOf("학사") + topics = listOf(Topic.exam, Topic.work) ) // when // then