Skip to content

Commit

Permalink
fix: admissions 패키지 프론트에 맞게 협의 (#76)
Browse files Browse the repository at this point in the history
* fix: admissions 프론트에 맞게 협의

* fix: seminarEntity time 삭제

* fix: admissionsEntity pageName 추가

* fix: 불필요한 파일 삭제

* 커밋
  • Loading branch information
skfotakf authored Sep 8, 2023
1 parent 9f406af commit 0ce4199
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class SubjectChangesDto(
val description: String,
) {
companion object {

fun of(entity: AcademicsEntity) = entity.run {
SubjectChangesDto(
time = this.time!!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import org.springframework.web.bind.annotation.RestController
class AdmissionsController(
private val admissionsService: AdmissionsService
) {
@PostMapping("/undergraduate")
@PostMapping("/undergraduate/{postType}")
fun createUndergraduateAdmissions(
@RequestParam postType: String,
@PathVariable postType: String,
@Valid @RequestBody request: AdmissionsDto
) : AdmissionsDto {
return admissionsService.createUndergraduateAdmissions(postType, request)
Expand All @@ -32,9 +32,9 @@ class AdmissionsController(
return admissionsService.createGraduateAdmissions(request)
}

@GetMapping("/undergraduate")
@GetMapping("/undergraduate/{postType}")
fun readUndergraduateAdmissions(
@RequestParam postType: String
@PathVariable postType: String
) : ResponseEntity<AdmissionsDto> {
return ResponseEntity.ok(admissionsService.readUndergraduateAdmissions(postType))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import jakarta.persistence.Enumerated
class AdmissionsEntity(
@Enumerated(EnumType.STRING)
val postType: AdmissionsPostType,
val title: String,
val pageName: String,
val description: String,
): BaseTimeEntity() {
companion object {
fun of(postType: AdmissionsPostType, admissionsDto: AdmissionsDto) : AdmissionsEntity {
fun of(postType: AdmissionsPostType, pageName: String, admissionsDto: AdmissionsDto) : AdmissionsEntity {
return AdmissionsEntity(
postType = postType,
title = admissionsDto.title,
pageName = pageName,
description = admissionsDto.description,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import java.time.LocalDateTime

data class AdmissionsDto(
val id: Long,
val title: String,
val description: String,
val createdAt: LocalDateTime?,
val modifiedAt: LocalDateTime?,
Expand All @@ -14,7 +13,6 @@ data class AdmissionsDto(
fun of(entity: AdmissionsEntity) : AdmissionsDto = entity.run {
AdmissionsDto(
id = this.id,
title = this.title,
description = this.description,
createdAt = this.createdAt,
modifiedAt = this.modifiedAt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ class AdmissionsServiceImpl(
override fun createUndergraduateAdmissions(postType: String, request: AdmissionsDto): AdmissionsDto {
val enumPostType = makeStringToAdmissionsPostType(postType)

val newAdmissions = AdmissionsEntity.of(enumPostType, request)
val pageName = when(enumPostType) {
AdmissionsPostType.UNDERGRADUATE_EARLY_ADMISSION -> "수시 모집"
AdmissionsPostType.UNDERGRADUATE_REGULAR_ADMISSION -> "정시 모집"
else -> throw CserealException.Csereal404("해당하는 페이지를 찾을 수 없습니다.")
}

val newAdmissions = AdmissionsEntity.of(enumPostType, pageName, request)

admissionsRepository.save(newAdmissions)

Expand All @@ -33,7 +39,7 @@ class AdmissionsServiceImpl(

@Transactional
override fun createGraduateAdmissions(request: AdmissionsDto): AdmissionsDto {
val newAdmissions: AdmissionsEntity = AdmissionsEntity.of(AdmissionsPostType.GRADUATE, request)
val newAdmissions: AdmissionsEntity = AdmissionsEntity.of(AdmissionsPostType.GRADUATE, "전기/후기 모집", request)

admissionsRepository.save(newAdmissions)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ class SeminarEntity(
var affiliationURL: String?,

var startDate: String?,
var startTime: String?,
var endDate: String?,
var endTime: String?,

var location: String,

Expand Down Expand Up @@ -65,9 +63,7 @@ class SeminarEntity(
affiliation = seminarDto.affiliation,
affiliationURL = seminarDto.affiliationURL,
startDate = seminarDto.startDate,
startTime = seminarDto.startTime,
endDate = seminarDto.endDate,
endTime = seminarDto.endTime,
location = seminarDto.location,
host = seminarDto.host,
isPublic = seminarDto.isPublic,
Expand All @@ -87,9 +83,7 @@ class SeminarEntity(
affiliation = updateSeminarRequest.affiliation
affiliationURL = updateSeminarRequest.affiliationURL
startDate = updateSeminarRequest.startDate
startTime = updateSeminarRequest.startTime
endDate = updateSeminarRequest.endDate
endTime = updateSeminarRequest.endTime
location = updateSeminarRequest.location
host = updateSeminarRequest.host
isPublic = updateSeminarRequest.isPublic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ data class SeminarDto(
val affiliation: String,
val affiliationURL: String?,
val startDate: String?,
val startTime: String?,
val endDate: String?,
val endTime: String?,
val location: String,
val host: String?,
val additionalNote: String?,
Expand Down Expand Up @@ -47,9 +45,7 @@ data class SeminarDto(
affiliation = this.affiliation,
affiliationURL = this.affiliationURL,
startDate = this.startDate,
startTime = this.startTime,
endDate = this.endDate,
endTime = this.endTime,
location = this.location,
host = this.host,
additionalNote = this.additionalNote,
Expand Down

0 comments on commit 0ce4199

Please sign in to comment.