Skip to content

Commit

Permalink
feat: academics 패키지 이름에 맞게 변경 (#199)
Browse files Browse the repository at this point in the history
* feat: add readDegreeRequirements

* feat: readGeneralRequirements 삭제, readDegreeRequirements 추가

* feat: AcademicsEntity time 칼럼 삭제
  • Loading branch information
skfotakf authored Mar 2, 2024
1 parent 2f77143 commit f4e4ebf
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ class AcademicsController(
return ResponseEntity.ok(academicsService.readCourse(language, name))
}

@GetMapping("/undergraduate/general-studies-requirements")
fun readGeneralStudiesRequirements(
@GetMapping("/undergraduate/degree-requirements")
fun readDegreeRequirements(
@RequestParam(required = false, defaultValue = "ko") language: String
): ResponseEntity<GeneralStudiesPageResponse> {
return ResponseEntity.ok(academicsService.readGeneralStudies(language))
): ResponseEntity<DegreeRequirementsPageResponse> {
return ResponseEntity.ok(academicsService.readDegreeRequirements(language))
}

@AuthenticatedStaff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class AcademicsEntity(
@Column(columnDefinition = "mediumText")
var description: String,
var year: Int?,
var time: String?,

@OneToMany(mappedBy = "academics", cascade = [CascadeType.ALL], orphanRemoval = true)
var attachments: MutableList<AttachmentEntity> = mutableListOf(),
Expand All @@ -46,8 +45,7 @@ class AcademicsEntity(
language = languageType,
name = academicsDto.name,
description = academicsDto.description,
year = academicsDto.year,
time = academicsDto.time
year = academicsDto.year
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package com.wafflestudio.csereal.core.academics.database

enum class AcademicsPostType {
GUIDE, GENERAL_STUDIES_REQUIREMENTS, GENERAL_STUDIES_REQUIREMENTS_SUBJECT_CHANGES,
CURRICULUM, DEGREE_REQUIREMENTS, COURSE_CHANGES, SCHOLARSHIP;
CURRICULUM, DEGREE_REQUIREMENTS, DEGREE_REQUIREMENTS_YEAR_LIST, COURSE_CHANGES, SCHOLARSHIP;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,4 @@ interface AcademicsRepository : JpaRepository<AcademicsEntity, Long> {
studentType: AcademicsStudentType,
postType: AcademicsPostType
): List<AcademicsEntity>
fun findAllByLanguageAndStudentTypeAndPostTypeOrderByTimeDesc(
languageType: LanguageType,
studentType: AcademicsStudentType,
postType: AcademicsPostType
): List<AcademicsEntity>
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class AcademicsSearchEntity(
fun createContent(academics: AcademicsEntity): String {
val sb = StringBuilder()
academics.name.let { sb.appendLine(it) }
academics.time?.let { sb.appendLine(it) }
academics.year?.let { sb.appendLine(it) }
sb.appendLine(academics.studentType.value)
sb.appendLine(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ data class AcademicsDto(
val name: String,
val description: String,
val year: Int? = null,
val time: String? = null,
val createdAt: LocalDateTime? = null,
val modifiedAt: LocalDateTime? = null,
val attachments: List<AttachmentResponse>? = null
Expand All @@ -24,7 +23,6 @@ data class AcademicsDto(
name = this.name,
description = this.description,
year = this.year,
time = this.time,
createdAt = this.createdAt,
modifiedAt = this.modifiedAt,
attachments = attachmentResponses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package com.wafflestudio.csereal.core.academics.dto

import com.wafflestudio.csereal.core.academics.database.AcademicsEntity

class SubjectChangesDto(
val time: String,
class DegreeRequirementsDto(
val year: Int,
val description: String
) {
companion object {
fun of(entity: AcademicsEntity) = entity.run {
SubjectChangesDto(
time = this.time!!,
DegreeRequirementsDto(
year = this.year!!,
description = this.description
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.wafflestudio.csereal.core.academics.dto

import com.wafflestudio.csereal.core.academics.database.AcademicsEntity

class DegreeRequirementsPageResponse(
val description: String,
val yearList: List<DegreeRequirementsDto>
) {
companion object {
fun of(entity: AcademicsEntity, yearList: List<AcademicsEntity>) = entity.run {
DegreeRequirementsPageResponse(
description = this.description,
yearList = yearList.map { DegreeRequirementsDto.of(it) }
)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface AcademicsService {
studentType: String,
postType: String
): List<AcademicsYearResponse>
fun readGeneralStudies(language: String): GeneralStudiesPageResponse
fun readDegreeRequirements(language: String): DegreeRequirementsPageResponse
fun createCourse(
studentType: String,
request: CourseDto,
Expand Down Expand Up @@ -139,22 +139,23 @@ class AcademicsServiceImpl(
}

@Transactional(readOnly = true)
override fun readGeneralStudies(language: String): GeneralStudiesPageResponse {
override fun readDegreeRequirements(language: String): DegreeRequirementsPageResponse {
val enumLanguageType = LanguageType.makeStringToLanguageType(language)
val academicsEntity =
academicsRepository.findByLanguageAndStudentTypeAndPostType(
enumLanguageType,
AcademicsStudentType.UNDERGRADUATE,
AcademicsPostType.GENERAL_STUDIES_REQUIREMENTS
AcademicsPostType.DEGREE_REQUIREMENTS
)
val subjectChangesList =
academicsRepository.findAllByLanguageAndStudentTypeAndPostTypeOrderByTimeDesc(

val yearList =
academicsRepository.findAllByLanguageAndStudentTypeAndPostTypeOrderByYearDesc(
enumLanguageType,
AcademicsStudentType.UNDERGRADUATE,
AcademicsPostType.GENERAL_STUDIES_REQUIREMENTS_SUBJECT_CHANGES
AcademicsPostType.DEGREE_REQUIREMENTS_YEAR_LIST
)

return GeneralStudiesPageResponse.of(academicsEntity, subjectChangesList)
return DegreeRequirementsPageResponse.of(academicsEntity, yearList)
}

@Transactional
Expand Down

0 comments on commit f4e4ebf

Please sign in to comment.