Skip to content

Commit

Permalink
fix: research 패키지 get에 language 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
skfotakf committed Mar 1, 2024
1 parent ef2cd51 commit 8cc080b
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ class ResearchController(
}

@GetMapping("/groups")
fun readAllResearchGroups(): ResponseEntity<ResearchGroupResponse> {
return ResponseEntity.ok(researchService.readAllResearchGroups())
fun readAllResearchGroups(
@RequestParam(required = false, defaultValue = "ko") language: String
): ResponseEntity<ResearchGroupResponse> {
return ResponseEntity.ok(researchService.readAllResearchGroups(language))
}

@GetMapping("/centers")
fun readAllResearchCenters(): ResponseEntity<List<ResearchDto>> {
return ResponseEntity.ok(researchService.readAllResearchCenters())
fun readAllResearchCenters(
@RequestParam(required = false, defaultValue = "ko") language: String
): ResponseEntity<List<ResearchDto>> {
return ResponseEntity.ok(researchService.readAllResearchCenters(language))
}

@AuthenticatedStaff
Expand Down Expand Up @@ -62,8 +66,10 @@ class ResearchController(
}

@GetMapping("/labs")
fun readAllLabs(): ResponseEntity<List<LabDto>> {
return ResponseEntity.ok(researchService.readAllLabs())
fun readAllLabs(
@RequestParam(required = false, defaultValue = "ko") language: String
): ResponseEntity<List<LabDto>> {
return ResponseEntity.ok(researchService.readAllLabs(language))
}

@GetMapping("/lab/{labId}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.wafflestudio.csereal.core.research.database

import com.wafflestudio.csereal.common.properties.LanguageType
import org.springframework.data.jpa.repository.JpaRepository

interface LabRepository : JpaRepository<LabEntity, Long> {
fun findAllByOrderByName(): List<LabEntity>
fun findAllByLanguageOrderByName(languageType: LanguageType): List<LabEntity>
fun findByName(name: String): LabEntity?
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.wafflestudio.csereal.core.research.database

import com.wafflestudio.csereal.common.properties.LanguageType
import org.springframework.data.jpa.repository.JpaRepository

interface ResearchRepository : JpaRepository<ResearchEntity, Long> {
fun findByName(name: String): ResearchEntity?
fun findAllByPostTypeOrderByName(postType: ResearchPostType): List<ResearchEntity>
fun findAllByPostTypeAndLanguageOrderByName(
postType: ResearchPostType,
languageType: LanguageType
): List<ResearchEntity>
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ interface ResearchService {
attachments: List<MultipartFile>?
): ResearchDto

fun readAllResearchGroups(): ResearchGroupResponse
fun readAllResearchCenters(): List<ResearchDto>
fun readAllResearchGroups(language: String): ResearchGroupResponse
fun readAllResearchCenters(language: String): List<ResearchDto>
fun updateResearchDetail(
researchId: Long,
request: ResearchDto,
Expand All @@ -31,7 +31,7 @@ interface ResearchService {
): ResearchDto

fun createLab(request: LabDto, pdf: MultipartFile?): LabDto
fun readAllLabs(): List<LabDto>
fun readAllLabs(language: String): List<LabDto>
fun readLab(labId: Long): LabDto
fun updateLab(labId: Long, request: LabUpdateRequest, pdf: MultipartFile?): LabDto
fun migrateResearchDetail(requestList: List<ResearchDto>): List<ResearchDto>
Expand Down Expand Up @@ -84,37 +84,49 @@ class ResearchServiceImpl(
researchRepository.save(newResearch)

val imageURL = mainImageService.createImageURL(newResearch.mainImage)
val attachmentResponses = attachmentService.createAttachmentResponses(newResearch.attachments)
val attachmentResponses =
attachmentService.createAttachmentResponses(newResearch.attachments)

return ResearchDto.of(newResearch, imageURL, attachmentResponses)
}

@Transactional(readOnly = true)
override fun readAllResearchGroups(): ResearchGroupResponse {
override fun readAllResearchGroups(language: String): ResearchGroupResponse {
// Todo: description 수정 필요
val description = "세계가 주목하는 컴퓨터공학부의 많은 교수들은 ACM, IEEE 등 " +
"세계적인 컴퓨터관련 주요 학회에서 국제학술지 편집위원, 국제학술회의 위원장, 기조연설자 등으로 활발하게 활동하고 있습니다. " +
"정부 지원과제, 민간 산업체 지원 연구과제 등도 성공적으로 수행, 우수한 성과들을 내놓고 있으며, " +
"오늘도 인류가 꿈꾸는 행복하고 편리한 세상을 위해 변화와 혁신, 연구와 도전을 계속하고 있습니다."

val researchGroups = researchRepository.findAllByPostTypeOrderByName(ResearchPostType.GROUPS).map {
val imageURL = mainImageService.createImageURL(it.mainImage)
val attachmentResponses = attachmentService.createAttachmentResponses(it.attachments)

ResearchDto.of(it, imageURL, attachmentResponses)
}
"세계적인 컴퓨터관련 주요 학회에서 국제학술지 편집위원, 국제학술회의 위원장, " +
"기조연설자 등으로 활발하게 활동하고 있습니다. 정부 지원과제, 민간 산업체 지원 " +
"연구과제 등도 성공적으로 수행, 우수한 성과들을 내놓고 있으며, 오늘도 인류가 " +
"꿈꾸는 행복하고 편리한 세상을 위해 변화와 혁신, 연구와 도전을 계속하고 있습니다."

val enumLanguageType = LanguageType.makeStringToLanguageType(language)
val researchGroups =
researchRepository.findAllByPostTypeAndLanguageOrderByName(
ResearchPostType.GROUPS,
enumLanguageType
).map {
val imageURL = mainImageService.createImageURL(it.mainImage)
val attachmentResponses = attachmentService.createAttachmentResponses(it.attachments)

ResearchDto.of(it, imageURL, attachmentResponses)
}

return ResearchGroupResponse(description, researchGroups)
}

@Transactional(readOnly = true)
override fun readAllResearchCenters(): List<ResearchDto> {
val researchCenters = researchRepository.findAllByPostTypeOrderByName(ResearchPostType.CENTERS).map {
val imageURL = mainImageService.createImageURL(it.mainImage)
val attachmentResponses = attachmentService.createAttachmentResponses(it.attachments)

ResearchDto.of(it, imageURL, attachmentResponses)
}
override fun readAllResearchCenters(language: String): List<ResearchDto> {
val enumLanguageType = LanguageType.makeStringToLanguageType(language)
val researchCenters =
researchRepository.findAllByPostTypeAndLanguageOrderByName(
ResearchPostType.CENTERS,
enumLanguageType
).map {
val imageURL = mainImageService.createImageURL(it.mainImage)
val attachmentResponses = attachmentService.createAttachmentResponses(it.attachments)

ResearchDto.of(it, imageURL, attachmentResponses)
}

return researchCenters
}
Expand Down Expand Up @@ -211,8 +223,9 @@ class ResearchServiceImpl(
}

@Transactional(readOnly = true)
override fun readAllLabs(): List<LabDto> {
val labs = labRepository.findAllByOrderByName().map {
override fun readAllLabs(language: String): List<LabDto> {
val enumLanguageType = LanguageType.makeStringToLanguageType(language)
val labs = labRepository.findAllByLanguageOrderByName(enumLanguageType).map {
var pdfURL = ""
if (it.pdf != null) {
pdfURL = createPdfURL(it.pdf!!)
Expand Down

0 comments on commit 8cc080b

Please sign in to comment.