From e98e4ff44726e6e728738dd6ebe44b7a80981a86 Mon Sep 17 00:00:00 2001 From: "DESKTOP-USQPRVG\\gram" Date: Sat, 10 Feb 2024 11:46:04 +0900 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20staffEntity=EC=97=90=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 --- .../csereal/core/member/database/StaffEntity.kt | 12 +++++++----- .../wafflestudio/csereal/core/member/dto/StaffDto.kt | 3 +++ .../csereal/core/member/service/StaffService.kt | 7 +++++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/member/database/StaffEntity.kt b/src/main/kotlin/com/wafflestudio/csereal/core/member/database/StaffEntity.kt index c9b704f6..60fc24b6 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/member/database/StaffEntity.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/member/database/StaffEntity.kt @@ -2,15 +2,16 @@ package com.wafflestudio.csereal.core.member.database import com.wafflestudio.csereal.common.config.BaseTimeEntity import com.wafflestudio.csereal.common.controller.MainImageContentEntityType +import com.wafflestudio.csereal.common.properties.LanguageType import com.wafflestudio.csereal.core.member.dto.StaffDto import com.wafflestudio.csereal.core.resource.mainImage.database.MainImageEntity -import jakarta.persistence.CascadeType -import jakarta.persistence.Entity -import jakarta.persistence.OneToMany -import jakarta.persistence.OneToOne +import jakarta.persistence.* @Entity(name = "staff") class StaffEntity( + @Enumerated(EnumType.STRING) + var language: LanguageType, + var name: String, var role: String, @@ -30,8 +31,9 @@ class StaffEntity( override fun bringMainImage(): MainImageEntity? = mainImage companion object { - fun of(staffDto: StaffDto): StaffEntity { + fun of(languageType: LanguageType, staffDto: StaffDto): StaffEntity { return StaffEntity( + language = languageType, name = staffDto.name, role = staffDto.role, office = staffDto.office, diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/member/dto/StaffDto.kt b/src/main/kotlin/com/wafflestudio/csereal/core/member/dto/StaffDto.kt index bf75f902..1c16482a 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/member/dto/StaffDto.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/member/dto/StaffDto.kt @@ -1,11 +1,13 @@ package com.wafflestudio.csereal.core.member.dto import com.fasterxml.jackson.annotation.JsonInclude +import com.wafflestudio.csereal.common.properties.LanguageType import com.wafflestudio.csereal.core.member.database.StaffEntity data class StaffDto( @JsonInclude(JsonInclude.Include.NON_NULL) var id: Long? = null, + val language: String, val name: String, val role: String, val office: String, @@ -19,6 +21,7 @@ data class StaffDto( fun of(staffEntity: StaffEntity, imageURL: String?): StaffDto { return StaffDto( id = staffEntity.id, + language = LanguageType.makeLowercase(staffEntity.language), name = staffEntity.name, role = staffEntity.role, office = staffEntity.office, 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 90a527c9..260411ad 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 @@ -1,6 +1,7 @@ package com.wafflestudio.csereal.core.member.service import com.wafflestudio.csereal.common.CserealException +import com.wafflestudio.csereal.common.properties.LanguageType import com.wafflestudio.csereal.core.member.database.MemberSearchEntity import com.wafflestudio.csereal.core.member.database.StaffEntity import com.wafflestudio.csereal.core.member.database.StaffRepository @@ -29,7 +30,8 @@ class StaffServiceImpl( private val mainImageService: MainImageService ) : StaffService { override fun createStaff(createStaffRequest: StaffDto, mainImage: MultipartFile?): StaffDto { - val staff = StaffEntity.of(createStaffRequest) + val enumLanguageType = LanguageType.makeStringToLanguageType(createStaffRequest.language) + val staff = StaffEntity.of(enumLanguageType, createStaffRequest) for (task in createStaffRequest.tasks) { TaskEntity.create(task, staff) @@ -107,7 +109,8 @@ class StaffServiceImpl( val list = mutableListOf() for (request in requestList) { - val staff = StaffEntity.of(request) + val enumLanguageType = LanguageType.makeStringToLanguageType(request.language) + val staff = StaffEntity.of(enumLanguageType, request) for (task in request.tasks) { TaskEntity.create(task, staff) From ff6baf258cab047f99aab8e23fd2cbe1b6cecea4 Mon Sep 17 00:00:00 2001 From: "DESKTOP-USQPRVG\\gram" Date: Sat, 10 Feb 2024 11:56:56 +0900 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20branch=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wafflestudio/csereal/core/member/service/StaffService.kt | 2 -- 1 file changed, 2 deletions(-) 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..a69827c4 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 @@ -117,9 +117,7 @@ class StaffServiceImpl( } staff.memberSearch = MemberSearchEntity.create(staff) - staffRepository.save(staff) - list.add(StaffDto.of(staff, null)) } From 4f9ff8a4ddc0cc85ab0886039619b3d38738cc09 Mon Sep 17 00:00:00 2001 From: "DESKTOP-USQPRVG\\gram" Date: Sat, 10 Feb 2024 12:00:54 +0900 Subject: [PATCH 3/6] =?UTF-8?q?fix:=20branch=20origin=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wafflestudio/csereal/core/member/service/StaffService.kt | 2 ++ 1 file changed, 2 insertions(+) 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 a69827c4..260411ad 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 @@ -117,7 +117,9 @@ class StaffServiceImpl( } staff.memberSearch = MemberSearchEntity.create(staff) + staffRepository.save(staff) + list.add(StaffDto.of(staff, null)) } From 8b357277d9e97c0bf71cb73c7a22c405b04aa850 Mon Sep 17 00:00:00 2001 From: "DESKTOP-USQPRVG\\gram" Date: Sun, 11 Feb 2024 10:03:37 +0900 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20staff=20=EC=9D=BD=EA=B8=B0,=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=EC=97=90=EC=84=9C=20language=20=EC=86=8D?= =?UTF-8?q?=EC=84=B1=20=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 } From b4a7ee2a05ff91206abfd97f0b43d8745c56174c Mon Sep 17 00:00:00 2001 From: "DESKTOP-USQPRVG\\gram" Date: Sun, 11 Feb 2024 10:49:39 +0900 Subject: [PATCH 5/6] =?UTF-8?q?feat:=20migrateStaffImage=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../csereal/core/member/api/StaffController.kt | 8 ++++++++ .../csereal/core/member/service/StaffService.kt | 13 +++++++++++++ 2 files changed, 21 insertions(+) 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 d1484d53..6f298f94 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 @@ -57,4 +57,12 @@ class StaffController( ): ResponseEntity> { return ResponseEntity.ok(staffService.migrateStaff(requestList)) } + + @PatchMapping("/migrateImage/{staffId}") + fun migrateStaffImage( + @PathVariable staffId: Long, + @RequestPart("mainImage") mainImage: MultipartFile + ): ResponseEntity { + return ResponseEntity.ok(staffService.migrateStaffImage(staffId, mainImage)) + } } 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 6f20cda4..32d5f9a4 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 @@ -21,6 +21,7 @@ interface StaffService { fun updateStaff(staffId: Long, updateStaffRequest: StaffDto, mainImage: MultipartFile?): StaffDto fun deleteStaff(staffId: Long) fun migrateStaff(requestList: List): List + fun migrateStaffImage(staffId: Long, mainImage: MultipartFile): StaffDto } @Service @@ -127,4 +128,16 @@ class StaffServiceImpl( return list } + + @Transactional + override fun migrateStaffImage(staffId: Long, mainImage: MultipartFile): StaffDto { + val staff = staffRepository.findByIdOrNull(staffId) + ?: throw CserealException.Csereal404("해당 행정직원을 찾을 수 없습니다. staffId: $staffId") + + mainImageService.uploadMainImage(staff, mainImage) + + val imageURL = mainImageService.createImageURL(staff.mainImage) + + return StaffDto.of(staff, imageURL) + } } From f11b3ace5f4f155956fb629f2a7fd3534a4d0bfb Mon Sep 17 00:00:00 2001 From: "DESKTOP-USQPRVG\\gram" Date: Sun, 11 Feb 2024 13:03:50 +0900 Subject: [PATCH 6/6] =?UTF-8?q?fix:=20StaffServiceTest=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../csereal/core/member/service/StaffServiceTest.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/kotlin/com/wafflestudio/csereal/core/member/service/StaffServiceTest.kt b/src/test/kotlin/com/wafflestudio/csereal/core/member/service/StaffServiceTest.kt index c0d61496..37043fad 100644 --- a/src/test/kotlin/com/wafflestudio/csereal/core/member/service/StaffServiceTest.kt +++ b/src/test/kotlin/com/wafflestudio/csereal/core/member/service/StaffServiceTest.kt @@ -27,6 +27,7 @@ class StaffServiceTest( Given("이미지 없는 행정직원을 생성하려고 할 떄") { val staffDto = StaffDto( + language = "ko", name = "name", role = "role", office = "office", @@ -75,6 +76,7 @@ class StaffServiceTest( Given("이미지 없는 행정직원을 수정할 때") { val staffDto = StaffDto( + language = "ko", name = "name", role = "role", office = "office", @@ -87,6 +89,7 @@ class StaffServiceTest( When("행정직원을 수정하면") { val updateStaffDto = StaffDto( + language = "ko", name = "name2", role = "role2", office = "office2",