Skip to content

Commit

Permalink
feat: read에 language 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
skfotakf committed Feb 7, 2024
1 parent 988ab56 commit a79d9a7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.wafflestudio.csereal.common.properties

enum class LanguageType {
KOR, ENG
KO, EN
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,33 @@ class AboutController(
}

// read 목록이 하나
@GetMapping("/{postType}")
@GetMapping("/{language}/{postType}")
fun readAbout(
@PathVariable language: String,
@PathVariable postType: String
): ResponseEntity<AboutDto> {
return ResponseEntity.ok(aboutService.readAbout(postType))
return ResponseEntity.ok(aboutService.readAbout(language, postType))
}

@GetMapping("/student-clubs")
fun readAllClubs(): ResponseEntity<List<AboutDto>> {
return ResponseEntity.ok(aboutService.readAllClubs())
@GetMapping("/{language}/student-clubs")
fun readAllClubs(
@PathVariable language: String
): ResponseEntity<List<AboutDto>> {
return ResponseEntity.ok(aboutService.readAllClubs(language))
}

@GetMapping("/facilities")
fun readAllFacilities(): ResponseEntity<List<AboutDto>> {
return ResponseEntity.ok(aboutService.readAllFacilities())
@GetMapping("/{language}/facilities")
fun readAllFacilities(
@PathVariable language: String
): ResponseEntity<List<AboutDto>> {
return ResponseEntity.ok(aboutService.readAllFacilities(language))
}

@GetMapping("/directions")
fun readAllDirections(): ResponseEntity<List<AboutDto>> {
return ResponseEntity.ok(aboutService.readAllDirections())
@GetMapping("/{language}/directions")
fun readAllDirections(
@PathVariable language: String
): ResponseEntity<List<AboutDto>> {
return ResponseEntity.ok(aboutService.readAllDirections(language))
}

@GetMapping("/future-careers")
Expand Down
Original file line number Diff line number Diff line change
@@ -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<AboutEntity, Long> {
fun findAllByPostTypeOrderByName(postType: AboutPostType): List<AboutEntity>
fun findByPostType(postType: AboutPostType): AboutEntity
fun findAllByLanguageAndPostTypeOrderByName(languageType: LanguageType, postType: AboutPostType): List<AboutEntity>
fun findByLanguageAndPostType(languageType: LanguageType, postType: AboutPostType): AboutEntity
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ interface AboutService {
attachments: List<MultipartFile>?
): AboutDto

fun readAbout(postType: String): AboutDto
fun readAllClubs(): List<AboutDto>
fun readAllFacilities(): List<AboutDto>
fun readAllDirections(): List<AboutDto>
fun readAbout(language: String, postType: String): AboutDto
fun readAllClubs(language: String): List<AboutDto>
fun readAllFacilities(language: String): List<AboutDto>
fun readAllDirections(language: String): List<AboutDto>
fun readFutureCareers(): FutureCareersPage
fun migrateAbout(requestList: List<AboutRequest>): List<AboutDto>
fun migrateFutureCareers(request: FutureCareersRequest): FutureCareersPage
Expand Down Expand Up @@ -75,18 +75,20 @@ 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)

return AboutDto.of(about, imageURL, attachmentResponses)
}

@Transactional(readOnly = true)
override fun readAllClubs(): List<AboutDto> {
val clubs = aboutRepository.findAllByPostTypeOrderByName(AboutPostType.STUDENT_CLUBS).map {
override fun readAllClubs(language: String): List<AboutDto> {
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)
Expand All @@ -96,8 +98,9 @@ class AboutServiceImpl(
}

@Transactional(readOnly = true)
override fun readAllFacilities(): List<AboutDto> {
val facilities = aboutRepository.findAllByPostTypeOrderByName(AboutPostType.FACILITIES).map {
override fun readAllFacilities(language: String): List<AboutDto> {
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)
Expand All @@ -107,8 +110,9 @@ class AboutServiceImpl(
}

@Transactional(readOnly = true)
override fun readAllDirections(): List<AboutDto> {
val directions = aboutRepository.findAllByPostTypeOrderByName(AboutPostType.DIRECTIONS).map {
override fun readAllDirections(language: String): List<AboutDto> {
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)
Expand Down

0 comments on commit a79d9a7

Please sign in to comment.