Skip to content

Commit

Permalink
fix: conference, scholarship language 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
skfotakf committed Feb 28, 2024
1 parent 161ac75 commit 81e03ca
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.wafflestudio.csereal.core.academics.database

import com.wafflestudio.csereal.common.config.BaseTimeEntity
import com.wafflestudio.csereal.common.properties.LanguageType
import com.wafflestudio.csereal.core.academics.dto.ScholarshipDto
import jakarta.persistence.*

Expand All @@ -9,6 +10,9 @@ class ScholarshipEntity(
@Enumerated(EnumType.STRING)
var studentType: AcademicsStudentType,

@Enumerated(EnumType.STRING)
var language: LanguageType,

val name: String,

@Column(columnDefinition = "text")
Expand All @@ -20,8 +24,13 @@ class ScholarshipEntity(
) : BaseTimeEntity() {

companion object {
fun of(studentType: AcademicsStudentType, scholarshipDto: ScholarshipDto): ScholarshipEntity {
fun of(
languageType: LanguageType,
studentType: AcademicsStudentType,
scholarshipDto: ScholarshipDto
): ScholarshipEntity {
return ScholarshipEntity(
language = languageType,
studentType = studentType,
name = scholarshipDto.name,
description = scholarshipDto.description
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package com.wafflestudio.csereal.core.academics.dto

import com.wafflestudio.csereal.common.properties.LanguageType
import com.wafflestudio.csereal.core.academics.database.ScholarshipEntity

data class ScholarshipDto(
val id: Long,
val language: String,
val name: String,
val description: String
) {
companion object {
fun of(scholarshipEntity: ScholarshipEntity): ScholarshipDto {
return ScholarshipDto(
id = scholarshipEntity.id,
language = LanguageType.makeLowercase(scholarshipEntity.language),
name = scholarshipEntity.name,
description = scholarshipEntity.description
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ class AcademicsServiceImpl(

@Transactional
override fun createScholarshipDetail(studentType: String, request: ScholarshipDto): ScholarshipDto {
val enumLanguageType = LanguageType.makeStringToLanguageType(request.language)
val enumStudentType = makeStringToAcademicsStudentType(studentType)
var newScholarship = ScholarshipEntity.of(enumStudentType, request)
var newScholarship = ScholarshipEntity.of(enumLanguageType, enumStudentType, request)

// create search data
newScholarship.apply {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.wafflestudio.csereal.core.conference.database

import com.wafflestudio.csereal.common.config.BaseTimeEntity
import com.wafflestudio.csereal.common.properties.LanguageType
import com.wafflestudio.csereal.core.conference.dto.ConferenceDto
import com.wafflestudio.csereal.core.research.database.ResearchSearchEntity
import jakarta.persistence.*

@Entity(name = "conference")
class ConferenceEntity(
@Enumerated(EnumType.STRING)
var language: LanguageType,

var isDeleted: Boolean = false,
var code: String,
var abbreviation: String,
Expand All @@ -21,9 +25,11 @@ class ConferenceEntity(
) : BaseTimeEntity() {
companion object {
fun of(
languageType: LanguageType,
conferenceDto: ConferenceDto,
conferencePage: ConferencePageEntity
) = ConferenceEntity(
language = languageType,
code = conferenceDto.code,
abbreviation = conferenceDto.abbreviation,
name = conferenceDto.name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.wafflestudio.csereal.core.conference.dto

import com.fasterxml.jackson.annotation.JsonInclude
import com.wafflestudio.csereal.common.properties.LanguageType
import com.wafflestudio.csereal.core.conference.database.ConferenceEntity

data class ConferenceDto(
@JsonInclude(JsonInclude.Include.NON_NULL)
val id: Long? = null,
val language: String,
val code: String,
val abbreviation: String,
val name: String
Expand All @@ -14,6 +16,7 @@ data class ConferenceDto(
fun of(conferenceEntity: ConferenceEntity): ConferenceDto {
return ConferenceDto(
id = conferenceEntity.id,
language = LanguageType.makeLowercase(conferenceEntity.language),
code = conferenceEntity.code,
abbreviation = conferenceEntity.abbreviation,
name = conferenceEntity.name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.wafflestudio.csereal.core.conference.service

import com.wafflestudio.csereal.common.CserealException
import com.wafflestudio.csereal.common.properties.LanguageType
import com.wafflestudio.csereal.core.conference.database.ConferenceEntity
import com.wafflestudio.csereal.core.conference.database.ConferencePageEntity
import com.wafflestudio.csereal.core.conference.database.ConferencePageRepository
Expand Down Expand Up @@ -40,7 +41,9 @@ class ConferenceServiceImpl(
}

@Transactional
override fun modifyConferences(conferenceModifyRequest: ConferenceModifyRequest): ConferencePage {
override fun modifyConferences(
conferenceModifyRequest: ConferenceModifyRequest
): ConferencePage {
val user = RequestContextHolder.getRequestAttributes()?.getAttribute(
"loggedInUser",
RequestAttributes.SCOPE_REQUEST
Expand Down Expand Up @@ -76,7 +79,8 @@ class ConferenceServiceImpl(
val conferencePage = ConferencePageEntity.of(user)
conferencePageRepository.save(conferencePage)
for (request in requestList) {
val conference = ConferenceEntity.of(request, conferencePage)
val enumLanguageType = LanguageType.makeStringToLanguageType(request.language)
val conference = ConferenceEntity.of(enumLanguageType, request, conferencePage)

conferenceRepository.save(conference)

Expand All @@ -94,7 +98,9 @@ class ConferenceServiceImpl(
conferenceDto: ConferenceDto,
conferencePage: ConferencePageEntity
): ConferenceEntity {
val enumLanguageType = LanguageType.makeStringToLanguageType(conferenceDto.language)
val newConference = ConferenceEntity.of(
enumLanguageType,
conferenceDto,
conferencePage
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wafflestudio.csereal.core.conference.service

import com.wafflestudio.csereal.common.properties.LanguageType
import com.wafflestudio.csereal.core.conference.database.ConferenceEntity
import com.wafflestudio.csereal.core.conference.database.ConferencePageEntity
import com.wafflestudio.csereal.core.conference.database.ConferencePageRepository
Expand Down Expand Up @@ -76,18 +77,21 @@ class ConferenceServiceTest(
val conferences = conferenceRepository.saveAll(
listOf(
ConferenceEntity(
language = LanguageType.KO,
code = "code1",
name = "name1",
abbreviation = "abbreviation1",
conferencePage = conferencePage
),
ConferenceEntity(
language = LanguageType.KO,
code = "code2",
name = "name2",
abbreviation = "abbreviation2",
conferencePage = conferencePage
),
ConferenceEntity(
language = LanguageType.KO,
code = "code3",
name = "name3",
abbreviation = "abbreviation3",
Expand All @@ -105,11 +109,13 @@ class ConferenceServiceTest(
val deleteConferenceId = conferences[1].id
val modifiedConference = ConferenceDto(
id = conferences.first().id,
language = "ko",
code = "code0",
name = "modifiedName",
abbreviation = "modifiedAbbreviation"
)
val newConference = ConferenceDto(
language = "ko",
code = "code9",
name = "newName",
abbreviation = "newAbbreviation"
Expand Down

0 comments on commit 81e03ca

Please sign in to comment.