From 81e03ca9159fe16eed0c75694868d665ba93fe4b Mon Sep 17 00:00:00 2001 From: "DESKTOP-USQPRVG\\gram" Date: Wed, 28 Feb 2024 20:43:56 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20conference,=20scholarship=20language=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/academics/database/ScholarshipEntity.kt | 11 ++++++++++- .../csereal/core/academics/dto/ScholarshipDto.kt | 3 +++ .../core/academics/service/AcademicsService.kt | 3 ++- .../core/conference/database/ConferenceEntity.kt | 6 ++++++ .../csereal/core/conference/dto/ConferenceDto.kt | 3 +++ .../core/conference/service/ConferenceService.kt | 10 ++++++++-- .../core/conference/service/ConferenceServiceTest.kt | 6 ++++++ 7 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/academics/database/ScholarshipEntity.kt b/src/main/kotlin/com/wafflestudio/csereal/core/academics/database/ScholarshipEntity.kt index 6aee54fd..64ab6098 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/academics/database/ScholarshipEntity.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/academics/database/ScholarshipEntity.kt @@ -1,6 +1,7 @@ package com.wafflestudio.csereal.core.academics.database import com.wafflestudio.csereal.common.config.BaseTimeEntity +import com.wafflestudio.csereal.common.properties.LanguageType import com.wafflestudio.csereal.core.academics.dto.ScholarshipDto import jakarta.persistence.* @@ -9,6 +10,9 @@ class ScholarshipEntity( @Enumerated(EnumType.STRING) var studentType: AcademicsStudentType, + @Enumerated(EnumType.STRING) + var language: LanguageType, + val name: String, @Column(columnDefinition = "text") @@ -20,8 +24,13 @@ class ScholarshipEntity( ) : BaseTimeEntity() { companion object { - fun of(studentType: AcademicsStudentType, scholarshipDto: ScholarshipDto): ScholarshipEntity { + fun of( + languageType: LanguageType, + studentType: AcademicsStudentType, + scholarshipDto: ScholarshipDto + ): ScholarshipEntity { return ScholarshipEntity( + language = languageType, studentType = studentType, name = scholarshipDto.name, description = scholarshipDto.description diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/academics/dto/ScholarshipDto.kt b/src/main/kotlin/com/wafflestudio/csereal/core/academics/dto/ScholarshipDto.kt index 533f9395..0312e296 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/academics/dto/ScholarshipDto.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/academics/dto/ScholarshipDto.kt @@ -1,9 +1,11 @@ package com.wafflestudio.csereal.core.academics.dto +import com.wafflestudio.csereal.common.properties.LanguageType import com.wafflestudio.csereal.core.academics.database.ScholarshipEntity data class ScholarshipDto( val id: Long, + val language: String, val name: String, val description: String ) { @@ -11,6 +13,7 @@ data class ScholarshipDto( fun of(scholarshipEntity: ScholarshipEntity): ScholarshipDto { return ScholarshipDto( id = scholarshipEntity.id, + language = LanguageType.makeLowercase(scholarshipEntity.language), name = scholarshipEntity.name, description = scholarshipEntity.description ) diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/academics/service/AcademicsService.kt b/src/main/kotlin/com/wafflestudio/csereal/core/academics/service/AcademicsService.kt index c754e0f2..44b07156 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/academics/service/AcademicsService.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/academics/service/AcademicsService.kt @@ -157,8 +157,9 @@ class AcademicsServiceImpl( @Transactional override fun createScholarshipDetail(studentType: String, request: ScholarshipDto): ScholarshipDto { + val enumLanguageType = LanguageType.makeStringToLanguageType(request.language) val enumStudentType = makeStringToAcademicsStudentType(studentType) - var newScholarship = ScholarshipEntity.of(enumStudentType, request) + var newScholarship = ScholarshipEntity.of(enumLanguageType, enumStudentType, request) // create search data newScholarship.apply { diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/conference/database/ConferenceEntity.kt b/src/main/kotlin/com/wafflestudio/csereal/core/conference/database/ConferenceEntity.kt index a90e6313..5a5f03dc 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/conference/database/ConferenceEntity.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/conference/database/ConferenceEntity.kt @@ -1,12 +1,16 @@ package com.wafflestudio.csereal.core.conference.database import com.wafflestudio.csereal.common.config.BaseTimeEntity +import com.wafflestudio.csereal.common.properties.LanguageType import com.wafflestudio.csereal.core.conference.dto.ConferenceDto import com.wafflestudio.csereal.core.research.database.ResearchSearchEntity import jakarta.persistence.* @Entity(name = "conference") class ConferenceEntity( + @Enumerated(EnumType.STRING) + var language: LanguageType, + var isDeleted: Boolean = false, var code: String, var abbreviation: String, @@ -21,9 +25,11 @@ class ConferenceEntity( ) : BaseTimeEntity() { companion object { fun of( + languageType: LanguageType, conferenceDto: ConferenceDto, conferencePage: ConferencePageEntity ) = ConferenceEntity( + language = languageType, code = conferenceDto.code, abbreviation = conferenceDto.abbreviation, name = conferenceDto.name, diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/conference/dto/ConferenceDto.kt b/src/main/kotlin/com/wafflestudio/csereal/core/conference/dto/ConferenceDto.kt index ca427e78..d6e95c59 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/conference/dto/ConferenceDto.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/conference/dto/ConferenceDto.kt @@ -1,11 +1,13 @@ package com.wafflestudio.csereal.core.conference.dto import com.fasterxml.jackson.annotation.JsonInclude +import com.wafflestudio.csereal.common.properties.LanguageType import com.wafflestudio.csereal.core.conference.database.ConferenceEntity data class ConferenceDto( @JsonInclude(JsonInclude.Include.NON_NULL) val id: Long? = null, + val language: String, val code: String, val abbreviation: String, val name: String @@ -14,6 +16,7 @@ data class ConferenceDto( fun of(conferenceEntity: ConferenceEntity): ConferenceDto { return ConferenceDto( id = conferenceEntity.id, + language = LanguageType.makeLowercase(conferenceEntity.language), code = conferenceEntity.code, abbreviation = conferenceEntity.abbreviation, name = conferenceEntity.name diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/conference/service/ConferenceService.kt b/src/main/kotlin/com/wafflestudio/csereal/core/conference/service/ConferenceService.kt index 6cbe1e4d..9fe38d23 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/conference/service/ConferenceService.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/conference/service/ConferenceService.kt @@ -1,6 +1,7 @@ package com.wafflestudio.csereal.core.conference.service import com.wafflestudio.csereal.common.CserealException +import com.wafflestudio.csereal.common.properties.LanguageType import com.wafflestudio.csereal.core.conference.database.ConferenceEntity import com.wafflestudio.csereal.core.conference.database.ConferencePageEntity import com.wafflestudio.csereal.core.conference.database.ConferencePageRepository @@ -40,7 +41,9 @@ class ConferenceServiceImpl( } @Transactional - override fun modifyConferences(conferenceModifyRequest: ConferenceModifyRequest): ConferencePage { + override fun modifyConferences( + conferenceModifyRequest: ConferenceModifyRequest + ): ConferencePage { val user = RequestContextHolder.getRequestAttributes()?.getAttribute( "loggedInUser", RequestAttributes.SCOPE_REQUEST @@ -76,7 +79,8 @@ class ConferenceServiceImpl( val conferencePage = ConferencePageEntity.of(user) conferencePageRepository.save(conferencePage) for (request in requestList) { - val conference = ConferenceEntity.of(request, conferencePage) + val enumLanguageType = LanguageType.makeStringToLanguageType(request.language) + val conference = ConferenceEntity.of(enumLanguageType, request, conferencePage) conferenceRepository.save(conference) @@ -94,7 +98,9 @@ class ConferenceServiceImpl( conferenceDto: ConferenceDto, conferencePage: ConferencePageEntity ): ConferenceEntity { + val enumLanguageType = LanguageType.makeStringToLanguageType(conferenceDto.language) val newConference = ConferenceEntity.of( + enumLanguageType, conferenceDto, conferencePage ) diff --git a/src/test/kotlin/com/wafflestudio/csereal/core/conference/service/ConferenceServiceTest.kt b/src/test/kotlin/com/wafflestudio/csereal/core/conference/service/ConferenceServiceTest.kt index 206cf76d..2b6a87f0 100644 --- a/src/test/kotlin/com/wafflestudio/csereal/core/conference/service/ConferenceServiceTest.kt +++ b/src/test/kotlin/com/wafflestudio/csereal/core/conference/service/ConferenceServiceTest.kt @@ -1,5 +1,6 @@ package com.wafflestudio.csereal.core.conference.service +import com.wafflestudio.csereal.common.properties.LanguageType import com.wafflestudio.csereal.core.conference.database.ConferenceEntity import com.wafflestudio.csereal.core.conference.database.ConferencePageEntity import com.wafflestudio.csereal.core.conference.database.ConferencePageRepository @@ -76,18 +77,21 @@ class ConferenceServiceTest( val conferences = conferenceRepository.saveAll( listOf( ConferenceEntity( + language = LanguageType.KO, code = "code1", name = "name1", abbreviation = "abbreviation1", conferencePage = conferencePage ), ConferenceEntity( + language = LanguageType.KO, code = "code2", name = "name2", abbreviation = "abbreviation2", conferencePage = conferencePage ), ConferenceEntity( + language = LanguageType.KO, code = "code3", name = "name3", abbreviation = "abbreviation3", @@ -105,11 +109,13 @@ class ConferenceServiceTest( val deleteConferenceId = conferences[1].id val modifiedConference = ConferenceDto( id = conferences.first().id, + language = "ko", code = "code0", name = "modifiedName", abbreviation = "modifiedAbbreviation" ) val newConference = ConferenceDto( + language = "ko", code = "code9", name = "newName", abbreviation = "newAbbreviation"