Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: research 패키지에 language 추가 #194

Merged
merged 10 commits into from
Feb 29, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ class AboutServiceImpl(

@Transactional
override fun migrateAbout(requestList: List<AboutRequest>): List<AboutDto> {
// Todo: add about migrate search
val list = mutableListOf<AboutDto>()

for (request in requestList) {
Expand Down Expand Up @@ -250,6 +251,7 @@ class AboutServiceImpl(

@Transactional
override fun migrateFutureCareers(request: FutureCareersRequest): FutureCareersPage {
// Todo: add about migrate search
val description = request.description
val language = request.language
val statList = mutableListOf<FutureCareersStatDto>()
Expand Down Expand Up @@ -312,6 +314,7 @@ class AboutServiceImpl(

@Transactional
override fun migrateStudentClubs(requestList: List<StudentClubDto>): List<StudentClubDto> {
// Todo: add about migrate search
val list = mutableListOf<StudentClubDto>()

for (request in requestList) {
Expand Down Expand Up @@ -343,6 +346,7 @@ class AboutServiceImpl(

@Transactional
override fun migrateFacilities(requestList: List<FacilityDto>): List<FacilityDto> =
// Todo: add about migrate search
requestList.map {
AboutDto(
id = null,
Expand Down Expand Up @@ -372,6 +376,7 @@ class AboutServiceImpl(

@Transactional
override fun migrateDirections(requestList: List<DirectionDto>): List<DirectionDto> {
// Todo: add about migrate search
val list = mutableListOf<DirectionDto>()

for (request in requestList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class AdmissionsServiceImpl(

@Transactional
override fun migrateAdmissions(requestList: List<AdmissionMigrateElem>) = requestList.map {
// Todo: add admission migrate search
val mainType = AdmissionsMainType.fromJsonValue(it.mainType)
val postType = AdmissionsPostType.fromJsonValue(it.postType)
val language = LanguageType.makeStringToLanguageType(it.language)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.wafflestudio.csereal.core.research.database

import com.wafflestudio.csereal.common.config.BaseTimeEntity
import com.wafflestudio.csereal.common.properties.LanguageType
import com.wafflestudio.csereal.core.member.database.ProfessorEntity
import com.wafflestudio.csereal.core.research.dto.LabDto
import com.wafflestudio.csereal.core.research.dto.LabUpdateRequest
Expand All @@ -9,6 +10,7 @@ import jakarta.persistence.*

@Entity(name = "lab")
class LabEntity(
var language: LanguageType,
var name: String,

@OneToMany(mappedBy = "lab")
Expand Down Expand Up @@ -36,8 +38,9 @@ class LabEntity(

) : BaseTimeEntity() {
companion object {
fun of(labDto: LabDto, researchGroup: ResearchEntity): LabEntity {
fun of(languageType: LanguageType, labDto: LabDto, researchGroup: ResearchEntity): LabEntity {
return LabEntity(
language = languageType,
name = labDto.name,
location = labDto.location,
tel = labDto.tel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.wafflestudio.csereal.core.research.database
import com.wafflestudio.csereal.common.config.BaseTimeEntity
import com.wafflestudio.csereal.common.controller.AttachmentContentEntityType
import com.wafflestudio.csereal.common.controller.MainImageContentEntityType
import com.wafflestudio.csereal.common.properties.LanguageType
import com.wafflestudio.csereal.core.research.dto.ResearchDto
import com.wafflestudio.csereal.core.resource.attachment.database.AttachmentEntity
import com.wafflestudio.csereal.core.resource.mainImage.database.MainImageEntity
Expand All @@ -13,6 +14,9 @@ class ResearchEntity(
@Enumerated(EnumType.STRING)
var postType: ResearchPostType,

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

var name: String,

@Column(columnDefinition = "mediumText")
Expand All @@ -34,9 +38,10 @@ class ResearchEntity(
override fun bringAttachments() = attachments

companion object {
fun of(researchDto: ResearchDto): ResearchEntity {
fun of(languageType: LanguageType, researchDto: ResearchDto): ResearchEntity {
return ResearchEntity(
postType = researchDto.postType,
language = languageType,
name = researchDto.name,
description = researchDto.description
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.wafflestudio.csereal.core.research.dto

import com.wafflestudio.csereal.common.properties.LanguageType
import com.wafflestudio.csereal.core.research.database.LabEntity

data class LabDto(
val id: Long,
val language: String,
val name: String,
val professors: List<LabProfessorResponse>?,
val location: String?,
Expand All @@ -19,6 +21,7 @@ data class LabDto(
fun of(entity: LabEntity, pdfURL: String): LabDto = entity.run {
LabDto(
id = this.id,
language = LanguageType.makeLowercase(entity.language),
name = this.name,
professors = this.professors.map { LabProfessorResponse(id = it.id, name = it.name) },
location = this.location,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wafflestudio.csereal.core.research.dto

import com.wafflestudio.csereal.common.properties.LanguageType
import com.wafflestudio.csereal.core.research.database.ResearchEntity
import com.wafflestudio.csereal.core.research.database.ResearchPostType
import com.wafflestudio.csereal.core.resource.attachment.dto.AttachmentResponse
Expand All @@ -8,6 +9,7 @@ import java.time.LocalDateTime
data class ResearchDto(
val id: Long,
val postType: ResearchPostType,
val language: String,
val name: String,
val description: String?,
val createdAt: LocalDateTime?,
Expand All @@ -21,6 +23,7 @@ data class ResearchDto(
ResearchDto(
id = this.id,
postType = this.postType,
language = LanguageType.makeLowercase(entity.language),
name = this.name,
description = this.description,
createdAt = this.createdAt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.wafflestudio.csereal.core.research.service

import com.wafflestudio.csereal.common.CserealException
import com.wafflestudio.csereal.common.properties.EndpointProperties
import com.wafflestudio.csereal.common.properties.LanguageType
import com.wafflestudio.csereal.core.member.database.ProfessorRepository
import com.wafflestudio.csereal.core.research.database.*
import com.wafflestudio.csereal.core.research.dto.*
Expand Down Expand Up @@ -58,7 +59,8 @@ class ResearchServiceImpl(
mainImage: MultipartFile?,
attachments: List<MultipartFile>?
): ResearchDto {
val newResearch = ResearchEntity.of(request)
val enumLanguageType = LanguageType.makeStringToLanguageType(request.language)
val newResearch = ResearchEntity.of(enumLanguageType, request)

if (request.labs != null) {
for (lab in request.labs) {
Expand Down Expand Up @@ -182,7 +184,8 @@ class ResearchServiceImpl(
throw CserealException.Csereal404("해당 게시글은 연구그룹이어야 합니다.")
}

val newLab = LabEntity.of(request, researchGroup)
val enumLanguageType = LanguageType.makeStringToLanguageType(request.language)
val newLab = LabEntity.of(enumLanguageType, request, researchGroup)

if (request.professors != null) {
for (professor in request.professors) {
Expand Down Expand Up @@ -292,7 +295,8 @@ class ResearchServiceImpl(
override fun migrateResearchDetail(requestList: List<ResearchDto>): List<ResearchDto> {
val list = mutableListOf<ResearchDto>()
for (request in requestList) {
val newResearch = ResearchEntity.of(request)
val enumLanguageType = LanguageType.makeStringToLanguageType(request.language)
val newResearch = ResearchEntity.of(enumLanguageType, request)

newResearch.researchSearch = ResearchSearchEntity.create(newResearch)

Expand All @@ -315,7 +319,8 @@ class ResearchServiceImpl(
throw CserealException.Csereal404("해당 게시글은 연구그룹이어야 합니다.")
}

val newLab = LabEntity.of(request, researchGroup)
val enumLanguageType = LanguageType.makeStringToLanguageType(request.language)
val newLab = LabEntity.of(enumLanguageType, request, researchGroup)

newLab.researchSearch = ResearchSearchEntity.create(newLab)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wafflestudio.csereal.core.member.service

import com.wafflestudio.csereal.common.properties.LanguageType
import com.wafflestudio.csereal.core.member.database.MemberSearchRepository
import com.wafflestudio.csereal.core.member.database.ProfessorRepository
import com.wafflestudio.csereal.core.member.database.ProfessorStatus
Expand Down Expand Up @@ -35,11 +36,13 @@ class ProfessorServiceTest(
val date = LocalDate.now()

val researchEntity = ResearchEntity(
language = LanguageType.KO,
name = "researchName",
description = null,
postType = ResearchPostType.LABS
)
var labEntity = LabEntity(
language = LanguageType.KO,
name = "labName",
location = null,
tel = null,
Expand Down Expand Up @@ -134,11 +137,13 @@ class ProfessorServiceTest(
Given("생성되어 있는 간단한 교수에 대하여") {
val date = LocalDate.now()
val researchEntity = ResearchEntity(
language = LanguageType.KO,
name = "researchName",
description = null,
postType = ResearchPostType.LABS
)
val labEntity1 = LabEntity(
language = LanguageType.KO,
name = "labName1",
location = null,
tel = null,
Expand All @@ -149,6 +154,7 @@ class ProfessorServiceTest(
research = researchEntity
)
val labEntity2 = LabEntity(
language = LanguageType.KO,
name = "labName2",
location = null,
tel = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wafflestudio.csereal.core.reseach.service

import com.wafflestudio.csereal.common.properties.LanguageType
import com.wafflestudio.csereal.core.member.database.ProfessorRepository
import com.wafflestudio.csereal.core.member.database.ProfessorStatus
import com.wafflestudio.csereal.core.member.dto.ProfessorDto
Expand Down Expand Up @@ -94,6 +95,7 @@ class ResearchSearchServiceTest(
// Save research
val research = researchRepository.save(
ResearchEntity(
language = LanguageType.KO,
name = "research",
postType = ResearchPostType.GROUPS,
description = null
Expand All @@ -103,6 +105,7 @@ class ResearchSearchServiceTest(
// Save lab
val labDto = LabDto(
id = -1,
language = "ko",
name = "name",
professors = listOf(
LabProfessorResponse(professor1.id, professor1.name),
Expand All @@ -120,6 +123,7 @@ class ResearchSearchServiceTest(

val emptyLabDto = LabDto(
id = -1,
language = "ko",
name = "nameE",
professors = listOf(),
acronym = "acronymE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ResearchServiceTest(
Given("간단한 Research를 생성하려고 할 때") {
val researchDto = ResearchDto(
id = -1,
language = "ko",
name = "name",
postType = ResearchPostType.CENTERS,
description = "description",
Expand Down Expand Up @@ -93,6 +94,7 @@ class ResearchServiceTest(
Given("간단한 Research를 수정하려고 할 때") {
val researchDto = ResearchDto(
id = -1,
language = "ko",
name = "name",
postType = ResearchPostType.CENTERS,
description = "description",
Expand All @@ -112,6 +114,7 @@ class ResearchServiceTest(
When("Research를 수정한다면") {
val researchUpdateRequest = ResearchDto(
id = createdResearchDto.id,
language = "ko",
name = "name2",
postType = ResearchPostType.GROUPS,
description = "description2",
Expand Down Expand Up @@ -189,6 +192,7 @@ class ResearchServiceTest(
// Save research
val research = researchRepository.save(
ResearchEntity(
language = LanguageType.KO,
name = "research",
postType = ResearchPostType.GROUPS,
description = null
Expand All @@ -197,6 +201,7 @@ class ResearchServiceTest(

val labDto = LabDto(
id = -1,
language = "ko",
name = "name",
professors = listOf(
LabProfessorResponse(professor1.id, professor1.name),
Expand Down Expand Up @@ -293,6 +298,7 @@ class ResearchServiceTest(
// Save research
val research = researchRepository.save(
ResearchEntity(
language = LanguageType.KO,
name = "research",
postType = ResearchPostType.GROUPS,
description = null
Expand All @@ -302,6 +308,7 @@ class ResearchServiceTest(
// Save lab
val labDto = LabDto(
id = -1,
language = "ko",
name = "name",
professors = listOf(
LabProfessorResponse(professor1.id, professor1.name),
Expand Down
Loading