Skip to content

Commit

Permalink
fix: StudentClubDto에 engName 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
skfotakf committed Mar 10, 2024
1 parent 34d6ade commit 179e035
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AboutController(
@GetMapping("/student-clubs")
fun readAllClubs(
@RequestParam(required = false, defaultValue = "ko") language: String
): ResponseEntity<List<AboutDto>> {
): ResponseEntity<List<StudentClubDto>> {
return ResponseEntity.ok(aboutService.readAllClubs(language))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,43 @@ package com.wafflestudio.csereal.core.about.dto
import com.fasterxml.jackson.annotation.JsonInclude
import com.wafflestudio.csereal.common.properties.LanguageType
import com.wafflestudio.csereal.core.about.database.AboutEntity
import com.wafflestudio.csereal.core.resource.attachment.dto.AttachmentResponse
import java.time.LocalDateTime

data class StudentClubDto(
@JsonInclude(JsonInclude.Include.NON_NULL)
val id: Long? = null,
val language: String,
val name: String,
val description: String
val engName: String,
val description: String,
val year: Int?,
val createdAt: LocalDateTime?,
val modifiedAt: LocalDateTime?,
val locations: List<String>?,
val imageURL: String?,
val attachments: List<AttachmentResponse>?
) {
companion object {
fun of(entity: AboutEntity): StudentClubDto = entity.run {
fun of(
entity: AboutEntity,
name: String,
engName: String,
imageURL: String?,
attachmentResponses: List<AttachmentResponse>
): StudentClubDto = entity.run {
StudentClubDto(
id = this.id,
language = LanguageType.makeLowercase(this.language),
name = this.name!!,
description = this.description
name = name,
engName = engName,
description = this.description,
year = this.year,
createdAt = this.createdAt,
modifiedAt = this.modifiedAt,
locations = this.locations,
imageURL = imageURL,
attachments = attachmentResponses
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface AboutService {
): AboutDto

fun readAbout(language: String, postType: String): AboutDto
fun readAllClubs(language: String): List<AboutDto>
fun readAllClubs(language: String): List<StudentClubDto>
fun readAllFacilities(language: String): List<AboutDto>
fun readAllDirections(language: String): List<AboutDto>
fun readFutureCareers(): FutureCareersPage
Expand Down Expand Up @@ -104,17 +104,19 @@ class AboutServiceImpl(
}

@Transactional(readOnly = true)
override fun readAllClubs(language: String): List<AboutDto> {
override fun readAllClubs(language: String): List<StudentClubDto> {
val languageType = LanguageType.makeStringToLanguageType(language)
val clubs =
aboutRepository.findAllByLanguageAndPostTypeOrderByName(
languageType,
AboutPostType.STUDENT_CLUBS
).map {
val name = it.name!!.split("(")[0]
val engName = it.name!!.split("(")[1].replaceFirst(")", "")
val imageURL = mainImageService.createImageURL(it.mainImage)
val attachmentResponses =
attachmentService.createAttachmentResponses(it.attachments)
AboutDto.of(it, imageURL, attachmentResponses)
StudentClubDto.of(it, name, engName, imageURL, attachmentResponses)
}

return clubs
Expand Down Expand Up @@ -342,7 +344,8 @@ class AboutServiceImpl(

for (request in requestList) {
val language = request.language
val name = request.name
val name = request.name.split("(")[0]
val engName = request.name.split("(")[1].replaceFirst(")", "")

val aboutDto = AboutDto(
id = null,
Expand All @@ -363,7 +366,7 @@ class AboutServiceImpl(
syncSearchOfAbout(newAbout)
newAbout = aboutRepository.save(newAbout)

list.add(StudentClubDto.of(newAbout))
list.add(StudentClubDto.of(newAbout, name, engName, null, listOf()))
}
return list
}
Expand Down

0 comments on commit 179e035

Please sign in to comment.