Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.wafflestudio.csereal.core.member.api.req

import com.wafflestudio.csereal.core.member.database.ProfessorDepartment
import com.wafflestudio.csereal.core.member.database.ProfessorStatus
import java.time.LocalDate

data class CreateProfessorReqBody(
val name: String,
val status: ProfessorStatus,
val department: ProfessorDepartment?,
val academicRank: String,
val labId: Long?,
val startDate: LocalDate?,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.wafflestudio.csereal.core.member.api.req

import com.wafflestudio.csereal.core.member.database.ProfessorDepartment
import com.wafflestudio.csereal.core.member.database.ProfessorStatus
import java.time.LocalDate

data class ModifyProfessorReqBody(
val name: String,
val status: ProfessorStatus,
val department: ProfessorDepartment?,
val academicRank: String,
val labId: Long?,
val startDate: LocalDate?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class MemberSearchEntity(
val stringBuilder = StringBuilder()
stringBuilder.appendLine(professor.name)
stringBuilder.appendLine(professor.status.krValue)
professor.department?.let { stringBuilder.appendLine(it.searchName) }
stringBuilder.appendLine(professor.academicRank)
professor.lab?.let { stringBuilder.appendLine(it.name) }
professor.startDate?.let { stringBuilder.appendLine(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class ProfessorEntity(

var name: String,

@Enumerated(EnumType.STRING)
var department: ProfessorDepartment?,

@Enumerated(EnumType.STRING)
var status: ProfessorStatus,

Expand Down Expand Up @@ -60,6 +63,7 @@ class ProfessorEntity(
language = languageType,
name = professorDto.name,
status = professorDto.status,
department = professorDto.department,
academicRank = professorDto.academicRank,
startDate = professorDto.startDate,
endDate = professorDto.endDate,
Expand All @@ -86,3 +90,11 @@ enum class ProfessorStatus(
INACTIVE("역대 교수"),
VISITING("객원교수");
}

enum class ProfessorDepartment(
val searchName: String
) {
CSE("컴퓨터공학부"), // Computer Science and Engineering
TI("첨단융합학부"), // Transdisciplinary innovations
II("지능정보융합학과") // Intelligence and Information
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.wafflestudio.csereal.core.member.dto

import com.wafflestudio.csereal.common.enums.LanguageType
import com.wafflestudio.csereal.core.member.database.ProfessorDepartment
import com.wafflestudio.csereal.core.member.database.ProfessorEntity
import com.wafflestudio.csereal.core.member.database.ProfessorStatus
import java.time.LocalDate
Expand All @@ -10,6 +11,7 @@ data class ProfessorDto(
val language: String,
val name: String,
val status: ProfessorStatus,
val department: ProfessorDepartment?,
val academicRank: String,
val labId: Long?,
val labName: String?,
Expand All @@ -32,6 +34,7 @@ data class ProfessorDto(
language = LanguageType.makeLowercase(professorEntity.language),
name = professorEntity.name,
status = professorEntity.status,
department = professorEntity.department,
academicRank = professorEntity.academicRank,
labId = professorEntity.lab?.id,
labName = professorEntity.lab?.name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.wafflestudio.csereal.core.member.dto

import com.wafflestudio.csereal.core.member.database.ProfessorDepartment
import com.wafflestudio.csereal.core.member.database.ProfessorEntity

data class SimpleProfessorDto(
val id: Long,
val name: String,
val department: ProfessorDepartment?,
val academicRank: String,
val status: String,
val labId: Long?,
Expand All @@ -18,6 +20,7 @@ data class SimpleProfessorDto(
return SimpleProfessorDto(
id = professorEntity.id,
name = professorEntity.name,
department = professorEntity.department,
academicRank = professorEntity.academicRank,
status = professorEntity.status.toString(),
labId = professorEntity.lab?.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ class ProfessorServiceImpl(
}.sortedWith { a, b ->

when {
a.department != b.department -> {
compareValues(a.department, b.department)
}
enumLanguageType == LanguageType.EN -> {
val lastNameA = a.name.split(" ").last()
val lastNameB = b.name.split(" ").last()
Expand All @@ -156,6 +159,9 @@ class ProfessorServiceImpl(
SimpleProfessorDto.of(it, imageURL)
}.sortedWith { a, b ->
when {
a.department != b.department -> {
compareValues(a.department, b.department)
}
enumLanguageType == LanguageType.EN -> {
val lastNameA = a.name.split(" ").last()
val lastNameB = b.name.split(" ").last()
Expand All @@ -179,6 +185,7 @@ class ProfessorServiceImpl(
language = language,
name = name,
status = status,
department = department,
academicRank = academicRank,
startDate = startDate,
endDate = endDate,
Expand Down Expand Up @@ -220,6 +227,10 @@ class ProfessorServiceImpl(
req: CreateProfessorLanguagesReqBody,
mainImage: MultipartFile?
): ProfessorLanguagesDto {
if (req.ko.department != req.en.department) {
throw CserealException.Csereal400("한국어와 영어 소속이 다릅니다.")
}

val koreanProfessorDto = createProfessor(LanguageType.KO, req.ko, mainImage)
val englishProfessorDto = createProfessor(LanguageType.EN, req.ko, mainImage)

Expand Down Expand Up @@ -257,6 +268,7 @@ class ProfessorServiceImpl(
professor.run {
name = it.name
status = it.status
department = it.department
academicRank = it.academicRank
startDate = it.startDate
endDate = it.endDate
Expand Down Expand Up @@ -302,14 +314,18 @@ class ProfessorServiceImpl(
req: ModifyProfessorLanguagesReqBody,
newImage: MultipartFile?
): ProfessorLanguagesDto {
if (req.ko.department != req.en.department) {
throw CserealException.Csereal400("한국어와 영어 소속이 다릅니다.")
}

// check given id is paired
if (!memberLanguageRepository.existsByKoreanIdAndEnglishIdAndType(
koProfessorId,
enProfessorId,
MemberType.PROFESSOR
)
) {
throw CserealException.Csereal404("해당 교수 쌍을 찾을 수 없스빈다. <$koProfessorId, $enProfessorId>")
throw CserealException.Csereal404("해당 교수 쌍을 찾을 수 없습니다. <$koProfessorId, $enProfessorId>")
}

val koProfessorDto = updateProfessor(koProfessorId, req.ko, newImage)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE professor
ADD COLUMN department enum('CSE', 'TI', 'II') default null
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.wafflestudio.csereal.core.admissions.type.AdmissionsMainType
import com.wafflestudio.csereal.core.admissions.type.AdmissionsPostType
import com.wafflestudio.csereal.core.member.api.req.CreateProfessorReqBody
import com.wafflestudio.csereal.core.member.api.req.CreateStaffReqBody
import com.wafflestudio.csereal.core.member.database.ProfessorDepartment
import com.wafflestudio.csereal.core.member.database.ProfessorStatus
import com.wafflestudio.csereal.core.member.service.MemberSearchService
import com.wafflestudio.csereal.core.member.service.ProfessorService
Expand Down Expand Up @@ -212,6 +213,7 @@ class TotalSearchTest(
name = "name",
email = "email",
status = ProfessorStatus.ACTIVE,
department = ProfessorDepartment.CSE,
academicRank = "academicRank",
labId = null,
startDate = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.wafflestudio.csereal.common.enums.LanguageType
import com.wafflestudio.csereal.core.member.api.req.CreateProfessorReqBody
import com.wafflestudio.csereal.core.member.api.req.ModifyProfessorReqBody
import com.wafflestudio.csereal.core.member.database.MemberSearchRepository
import com.wafflestudio.csereal.core.member.database.ProfessorDepartment
import com.wafflestudio.csereal.core.member.database.ProfessorRepository
import com.wafflestudio.csereal.core.member.database.ProfessorStatus
import com.wafflestudio.csereal.core.research.database.LabEntity
Expand Down Expand Up @@ -57,6 +58,7 @@ class ProfessorServiceTest(
name = "name",
email = "email",
status = ProfessorStatus.ACTIVE,
department = ProfessorDepartment.CSE,
academicRank = "academicRank",
labId = labEntity.id,
startDate = date,
Expand Down Expand Up @@ -84,6 +86,7 @@ class ProfessorServiceTest(
professorEntity.name shouldBe professorCreateReq.name
professorEntity.email shouldBe professorCreateReq.email
professorEntity.status shouldBe professorCreateReq.status
professorEntity.department shouldBe professorCreateReq.department
professorEntity.academicRank shouldBe professorCreateReq.academicRank
professorEntity.lab shouldBe labEntity
professorEntity.startDate shouldBe professorCreateReq.startDate
Expand All @@ -107,6 +110,7 @@ class ProfessorServiceTest(
val contentExpected = """
name
교수
컴퓨터공학부
academicRank
labName
$date
Expand Down Expand Up @@ -163,6 +167,7 @@ class ProfessorServiceTest(
name = "name",
email = "email",
status = ProfessorStatus.ACTIVE,
department = ProfessorDepartment.CSE,
academicRank = "academicRank",
labId = labEntity1.id,
startDate = date,
Expand All @@ -183,6 +188,7 @@ class ProfessorServiceTest(
name = "modifiedName",
email = "modifiedEmail",
status = ProfessorStatus.INACTIVE,
department = ProfessorDepartment.TI,
academicRank = "modifiedAcademicRank",
labId = labEntity2.id,
startDate = date.plusDays(1),
Expand Down Expand Up @@ -211,6 +217,7 @@ class ProfessorServiceTest(
professorEntity!!.name shouldBe modifyProfessorReq.name
professorEntity.email shouldBe modifyProfessorReq.email
professorEntity.status shouldBe modifyProfessorReq.status
professorEntity.department shouldBe modifyProfessorReq.department
professorEntity.academicRank shouldBe modifyProfessorReq.academicRank
professorEntity.lab shouldBe labEntity2
professorEntity.startDate shouldBe modifyProfessorReq.startDate
Expand All @@ -234,6 +241,7 @@ class ProfessorServiceTest(
memberSearchEntity?.content shouldBe """
modifiedName
역대 교수
첨단융합학부
modifiedAcademicRank
labName2
${date.plusDays(1)}
Expand All @@ -257,4 +265,74 @@ class ProfessorServiceTest(
}
}
}

Given("소속이 다른 여러 교수가 있을 때") {
val date = LocalDate.now()

val cseProfessorCreateReq = CreateProfessorReqBody(
name = "name1",
email = "email",
status = ProfessorStatus.ACTIVE,
department = ProfessorDepartment.CSE,
academicRank = "academicRank",
labId = null,
startDate = date,
endDate = date,
office = "office",
phone = "phone",
fax = "fax",
website = "website",
educations = listOf("education1", "education2 "),
researchAreas = listOf("researchArea1", "researchArea2 "),
careers = listOf("career1", "career2 ")
)

val iiProfessorCreateReq = CreateProfessorReqBody(
name = "name2",
email = "email",
status = ProfessorStatus.ACTIVE,
department = ProfessorDepartment.CSE,
academicRank = "academicRank",
labId = null,
startDate = date,
endDate = date,
office = "office",
phone = "phone",
fax = "fax",
website = "website",
educations = listOf("education1", "education2 "),
researchAreas = listOf("researchArea1", "researchArea2 "),
careers = listOf("career1", "career2 ")
)

val tiProfessorCreateReq = CreateProfessorReqBody(
name = "name3",
email = "email",
status = ProfessorStatus.ACTIVE,
department = ProfessorDepartment.CSE,
academicRank = "academicRank",
labId = null,
startDate = date,
endDate = date,
office = "office",
phone = "phone",
fax = "fax",
website = "website",
educations = listOf("education1", "education2 "),
researchAreas = listOf("researchArea1", "researchArea2 "),
careers = listOf("career1", "career2 ")
)

When("교수를 생성하고 검색하면") {
professorService.createProfessor(LanguageType.KO, iiProfessorCreateReq, null)
professorService.createProfessor(LanguageType.KO, cseProfessorCreateReq, null)
professorService.createProfessor(LanguageType.KO, tiProfessorCreateReq, null)

val professorPageDto = professorService.getActiveProfessors("ko")

Then("CSE 교수가 가장 앞에 나와야 한다") {
professorPageDto.professors[0].department shouldBe ProfessorDepartment.CSE
}
}
}
})
Loading