Skip to content

Commit

Permalink
οΏ½ πŸ”€ :: (#9) μžμŠ΅κ°λ… μ„ μƒλ‹˜ μ‚­μ œ API κ΅¬ν˜„
Browse files Browse the repository at this point in the history
 πŸ”€ :: (#9) μžμŠ΅κ°λ… μ„ μƒλ‹˜ μ‚­μ œ API κ΅¬ν˜„
  • Loading branch information
lilseongwon authored Apr 24, 2023
2 parents f26709c + 6ea6b2a commit fa01563
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.pickdsm.pickserverspring.domain.selfstudydirector.api

import com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.request.DomainChangeSelfStudyDirectorRequest
import com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.request.DomainDeleteSelfStudyDirectorRequest
import com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.request.DomainRegisterSelfStudyDirectorRequest
import com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.response.SelfStudyListResponse
import com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.response.SelfStudyStateResponse
Expand All @@ -21,4 +22,6 @@ interface SelfStudyDirectorApi {
fun blockUnlockMoveClassroom()

fun registerSelfStudyDirector(request: DomainRegisterSelfStudyDirectorRequest)

fun deleteSelfStudyDirector(request: DomainDeleteSelfStudyDirectorRequest)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.request

import java.time.LocalDate
import java.util.*

data class DomainDeleteSelfStudyDirectorRequest(
val teacherId: UUID,
val floor: Int,
val date: LocalDate,
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ interface CommandSelfStudyDirectorSpi {
fun setRestrictionMovementTrue(selfStudyDirector: SelfStudyDirector)

fun saveSelfStudyDirector(selfStudyDirector: SelfStudyDirector)

fun deleteSelfStudyDirector(selfStudyDirector: SelfStudyDirector)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.pickdsm.pickserverspring.domain.selfstudydirector.DirectorType
import com.pickdsm.pickserverspring.domain.selfstudydirector.SelfStudyDirector
import com.pickdsm.pickserverspring.domain.selfstudydirector.api.SelfStudyDirectorApi
import com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.request.DomainChangeSelfStudyDirectorRequest
import com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.request.DomainDeleteSelfStudyDirectorRequest
import com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.request.DomainRegisterSelfStudyDirectorRequest
import com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.response.SelfStudyElement
import com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.response.SelfStudyListResponse
Expand Down Expand Up @@ -123,4 +124,14 @@ class SelfStudyDirectorUseCase(
selfStudyDirector,
)
}

override fun deleteSelfStudyDirector(request: DomainDeleteSelfStudyDirectorRequest) {
val selfStudyDirector =
querySelfStudyDirectorSpi.querySelfStudyDirectorByDateAndFloor(request.date, request.floor)
?: throw SelfStudyDirectorNotFoundException

commandSelfStudyDirectorSpi.deleteSelfStudyDirector(
selfStudyDirector,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.pickdsm.pickserverspring.domain.admin.presentation.dto.request.Delete
import com.pickdsm.pickserverspring.domain.admin.presentation.dto.request.RegisterSelfStudyDirectorRequest
import com.pickdsm.pickserverspring.domain.admin.presentation.dto.request.ChangeClubHeadRequest
import com.pickdsm.pickserverspring.domain.admin.presentation.dto.request.ChangeSelfStudyDirectorRequest
import com.pickdsm.pickserverspring.domain.admin.presentation.dto.request.DeleteSelfStudyDirectorRequest
import com.pickdsm.pickserverspring.domain.afterschool.api.AfterSchoolApi
import com.pickdsm.pickserverspring.domain.afterschool.api.dto.request.DomainCreateAfterSchoolStudentRequest
import com.pickdsm.pickserverspring.domain.afterschool.api.dto.request.DomainDeleteAfterSchoolStudentRequest
Expand All @@ -28,6 +29,7 @@ import com.pickdsm.pickserverspring.domain.club.api.dto.DomainChangeClubStudentR
import com.pickdsm.pickserverspring.domain.selfstudydirector.DirectorType
import com.pickdsm.pickserverspring.domain.selfstudydirector.api.SelfStudyDirectorApi
import com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.request.DomainChangeSelfStudyDirectorRequest
import com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.request.DomainDeleteSelfStudyDirectorRequest
import com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.request.DomainRegisterSelfStudyDirectorRequest
import com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.response.SelfStudyListResponse
import com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.response.SelfStudyStateResponse
Expand Down Expand Up @@ -287,4 +289,19 @@ class AdminWebAdapter(
fun blockUnlockMoveClassroom() {
selfStudyDirectorApi.blockUnlockMoveClassroom()
}

@ResponseStatus(HttpStatus.NO_CONTENT)
@DeleteMapping("/director")
fun deleteSelfStudyDirector(
@RequestBody
@Valid
request: DeleteSelfStudyDirectorRequest,
) {
val domainRequest = DomainDeleteSelfStudyDirectorRequest(
teacherId = request.teacherId,
floor = request.floor,
date = request.date,
)
selfStudyDirectorApi.deleteSelfStudyDirector(domainRequest)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.pickdsm.pickserverspring.domain.admin.presentation.dto.request

import java.time.LocalDate
import java.util.*

data class DeleteSelfStudyDirectorRequest(
val teacherId: UUID,
val floor: Int,
val date: LocalDate,
)

Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,8 @@ class SelfStudyDirectorPersistenceAdapter(
override fun saveSelfStudyDirector(selfStudyDirector: SelfStudyDirector) {
selfStudyDirectorRepository.save(selfStudyDirectorMapper.domainToEntity(selfStudyDirector))
}

override fun deleteSelfStudyDirector(selfStudyDirector: SelfStudyDirector) {
selfStudyDirectorRepository.delete(selfStudyDirectorMapper.domainToEntity(selfStudyDirector))
}
}

0 comments on commit fa01563

Please sign in to comment.