Skip to content

Commit

Permalink
feat: staffEntity에 language 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
skfotakf committed Feb 10, 2024
1 parent 48edba4 commit e98e4ff
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -107,7 +109,8 @@ class StaffServiceImpl(
val list = mutableListOf<StaffDto>()

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)
Expand Down

0 comments on commit e98e4ff

Please sign in to comment.