diff --git a/src/main/kotlin/com/wafflestudio/csereal/common/properties/LanguageType.kt b/src/main/kotlin/com/wafflestudio/csereal/common/properties/LanguageType.kt index ec2e374e..28758a55 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/common/properties/LanguageType.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/common/properties/LanguageType.kt @@ -1,5 +1,5 @@ package com.wafflestudio.csereal.common.properties enum class LanguageType { - KOR, ENG + KO, EN } diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/about/api/AboutController.kt b/src/main/kotlin/com/wafflestudio/csereal/core/about/api/AboutController.kt index c028b641..f3cbf91d 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/about/api/AboutController.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/about/api/AboutController.kt @@ -34,26 +34,33 @@ class AboutController( } // read 목록이 하나 - @GetMapping("/{postType}") + @GetMapping("/{language}/{postType}") fun readAbout( + @PathVariable language: String, @PathVariable postType: String ): ResponseEntity { - return ResponseEntity.ok(aboutService.readAbout(postType)) + return ResponseEntity.ok(aboutService.readAbout(language, postType)) } - @GetMapping("/student-clubs") - fun readAllClubs(): ResponseEntity> { - return ResponseEntity.ok(aboutService.readAllClubs()) + @GetMapping("/{language}/student-clubs") + fun readAllClubs( + @PathVariable language: String + ): ResponseEntity> { + return ResponseEntity.ok(aboutService.readAllClubs(language)) } - @GetMapping("/facilities") - fun readAllFacilities(): ResponseEntity> { - return ResponseEntity.ok(aboutService.readAllFacilities()) + @GetMapping("/{language}/facilities") + fun readAllFacilities( + @PathVariable language: String + ): ResponseEntity> { + return ResponseEntity.ok(aboutService.readAllFacilities(language)) } - @GetMapping("/directions") - fun readAllDirections(): ResponseEntity> { - return ResponseEntity.ok(aboutService.readAllDirections()) + @GetMapping("/{language}/directions") + fun readAllDirections( + @PathVariable language: String + ): ResponseEntity> { + return ResponseEntity.ok(aboutService.readAllDirections(language)) } @GetMapping("/future-careers") diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/about/database/AboutRepository.kt b/src/main/kotlin/com/wafflestudio/csereal/core/about/database/AboutRepository.kt index 85d5331a..3790bce0 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/about/database/AboutRepository.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/about/database/AboutRepository.kt @@ -1,8 +1,9 @@ package com.wafflestudio.csereal.core.about.database +import com.wafflestudio.csereal.common.properties.LanguageType import org.springframework.data.jpa.repository.JpaRepository interface AboutRepository : JpaRepository { - fun findAllByPostTypeOrderByName(postType: AboutPostType): List - fun findByPostType(postType: AboutPostType): AboutEntity + fun findAllByLanguageAndPostTypeOrderByName(languageType: LanguageType, postType: AboutPostType): List + fun findByLanguageAndPostType(languageType: LanguageType, postType: AboutPostType): AboutEntity } diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/about/service/AboutService.kt b/src/main/kotlin/com/wafflestudio/csereal/core/about/service/AboutService.kt index e75419cf..731ced53 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/about/service/AboutService.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/about/service/AboutService.kt @@ -21,10 +21,10 @@ interface AboutService { attachments: List? ): AboutDto - fun readAbout(postType: String): AboutDto - fun readAllClubs(): List - fun readAllFacilities(): List - fun readAllDirections(): List + fun readAbout(language: String, postType: String): AboutDto + fun readAllClubs(language: String): List + fun readAllFacilities(language: String): List + fun readAllDirections(language: String): List fun readFutureCareers(): FutureCareersPage fun migrateAbout(requestList: List): List fun migrateFutureCareers(request: FutureCareersRequest): FutureCareersPage @@ -75,9 +75,10 @@ class AboutServiceImpl( } @Transactional(readOnly = true) - override fun readAbout(postType: String): AboutDto { + override fun readAbout(language: String, postType: String): AboutDto { + val languageType = languageRepository.makeStringToLanguageType(language) val enumPostType = makeStringToEnum(postType) - val about = aboutRepository.findByPostType(enumPostType) + val about = aboutRepository.findByLanguageAndPostType(languageType, enumPostType) val imageURL = mainImageService.createImageURL(about.mainImage) val attachmentResponses = attachmentService.createAttachmentResponses(about.attachments) @@ -85,8 +86,9 @@ class AboutServiceImpl( } @Transactional(readOnly = true) - override fun readAllClubs(): List { - val clubs = aboutRepository.findAllByPostTypeOrderByName(AboutPostType.STUDENT_CLUBS).map { + override fun readAllClubs(language: String): List { + val languageType = languageRepository.makeStringToLanguageType(language) + val clubs = aboutRepository.findAllByLanguageAndPostTypeOrderByName(languageType, AboutPostType.STUDENT_CLUBS).map { val imageURL = mainImageService.createImageURL(it.mainImage) val attachmentResponses = attachmentService.createAttachmentResponses(it.attachments) AboutDto.of(it, imageURL, attachmentResponses) @@ -96,8 +98,9 @@ class AboutServiceImpl( } @Transactional(readOnly = true) - override fun readAllFacilities(): List { - val facilities = aboutRepository.findAllByPostTypeOrderByName(AboutPostType.FACILITIES).map { + override fun readAllFacilities(language: String): List { + val languageType = languageRepository.makeStringToLanguageType(language) + val facilities = aboutRepository.findAllByLanguageAndPostTypeOrderByName(languageType, AboutPostType.FACILITIES).map { val imageURL = mainImageService.createImageURL(it.mainImage) val attachmentResponses = attachmentService.createAttachmentResponses(it.attachments) AboutDto.of(it, imageURL, attachmentResponses) @@ -107,8 +110,9 @@ class AboutServiceImpl( } @Transactional(readOnly = true) - override fun readAllDirections(): List { - val directions = aboutRepository.findAllByPostTypeOrderByName(AboutPostType.DIRECTIONS).map { + override fun readAllDirections(language: String): List { + val languageType = languageRepository.makeStringToLanguageType(language) + val directions = aboutRepository.findAllByLanguageAndPostTypeOrderByName(languageType, AboutPostType.DIRECTIONS).map { val imageURL = mainImageService.createImageURL(it.mainImage) val attachments = attachmentService.createAttachmentResponses(it.attachments) AboutDto.of(it, imageURL, attachments)