From 8b357277d9e97c0bf71cb73c7a22c405b04aa850 Mon Sep 17 00:00:00 2001 From: "DESKTOP-USQPRVG\\gram" Date: Sun, 11 Feb 2024 10:03:37 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20staff=20=EC=9D=BD=EA=B8=B0,=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=EC=97=90=EC=84=9C=20language=20=EC=86=8D=EC=84=B1=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 --- .../csereal/core/member/api/StaffController.kt | 6 ++++-- .../csereal/core/member/database/StaffRepository.kt | 5 ++++- .../csereal/core/member/service/StaffService.kt | 8 +++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/member/api/StaffController.kt b/src/main/kotlin/com/wafflestudio/csereal/core/member/api/StaffController.kt index eed5164c..d1484d53 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/member/api/StaffController.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/member/api/StaffController.kt @@ -29,8 +29,10 @@ class StaffController( } @GetMapping - fun getAllStaff(): ResponseEntity> { - return ResponseEntity.ok(staffService.getAllStaff()) + fun getAllStaff( + @RequestParam(required = false, defaultValue = "ko") language: String + ): ResponseEntity> { + return ResponseEntity.ok(staffService.getAllStaff(language)) } @AuthenticatedStaff diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/member/database/StaffRepository.kt b/src/main/kotlin/com/wafflestudio/csereal/core/member/database/StaffRepository.kt index a293b642..6ce765aa 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/member/database/StaffRepository.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/member/database/StaffRepository.kt @@ -1,5 +1,8 @@ package com.wafflestudio.csereal.core.member.database +import com.wafflestudio.csereal.common.properties.LanguageType import org.springframework.data.jpa.repository.JpaRepository -interface StaffRepository : JpaRepository +interface StaffRepository : JpaRepository { + fun findAllByLanguage(languageType: LanguageType): List +} diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/member/service/StaffService.kt b/src/main/kotlin/com/wafflestudio/csereal/core/member/service/StaffService.kt index 260411ad..6f20cda4 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/member/service/StaffService.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/member/service/StaffService.kt @@ -17,7 +17,7 @@ import org.springframework.web.multipart.MultipartFile interface StaffService { fun createStaff(createStaffRequest: StaffDto, mainImage: MultipartFile?): StaffDto fun getStaff(staffId: Long): StaffDto - fun getAllStaff(): List + fun getAllStaff(language: String): List fun updateStaff(staffId: Long, updateStaffRequest: StaffDto, mainImage: MultipartFile?): StaffDto fun deleteStaff(staffId: Long) fun migrateStaff(requestList: List): List @@ -61,8 +61,10 @@ class StaffServiceImpl( } @Transactional(readOnly = true) - override fun getAllStaff(): List { - return staffRepository.findAll().map { + override fun getAllStaff(language: String): List { + val enumLanguageType = LanguageType.makeStringToLanguageType(language) + + return staffRepository.findAllByLanguage(enumLanguageType).map { val imageURL = mainImageService.createImageURL(it.mainImage) SimpleStaffDto.of(it, imageURL) }.sortedBy { it.name }