Skip to content

Commit

Permalink
feat: staff 읽기, 수정에서 language 속성 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
skfotakf committed Feb 11, 2024
1 parent 4f9ff8a commit 8b35727
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ class StaffController(
}

@GetMapping
fun getAllStaff(): ResponseEntity<List<SimpleStaffDto>> {
return ResponseEntity.ok(staffService.getAllStaff())
fun getAllStaff(
@RequestParam(required = false, defaultValue = "ko") language: String
): ResponseEntity<List<SimpleStaffDto>> {
return ResponseEntity.ok(staffService.getAllStaff(language))
}

@AuthenticatedStaff
Expand Down
Original file line number Diff line number Diff line change
@@ -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<StaffEntity, Long>
interface StaffRepository : JpaRepository<StaffEntity, Long> {
fun findAllByLanguage(languageType: LanguageType): List<StaffEntity>
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<SimpleStaffDto>
fun getAllStaff(language: String): List<SimpleStaffDto>
fun updateStaff(staffId: Long, updateStaffRequest: StaffDto, mainImage: MultipartFile?): StaffDto
fun deleteStaff(staffId: Long)
fun migrateStaff(requestList: List<StaffDto>): List<StaffDto>
Expand Down Expand Up @@ -61,8 +61,10 @@ class StaffServiceImpl(
}

@Transactional(readOnly = true)
override fun getAllStaff(): List<SimpleStaffDto> {
return staffRepository.findAll().map {
override fun getAllStaff(language: String): List<SimpleStaffDto> {
val enumLanguageType = LanguageType.makeStringToLanguageType(language)

return staffRepository.findAllByLanguage(enumLanguageType).map {
val imageURL = mainImageService.createImageURL(it.mainImage)
SimpleStaffDto.of(it, imageURL)
}.sortedBy { it.name }
Expand Down

0 comments on commit 8b35727

Please sign in to comment.