Skip to content

Commit

Permalink
๐Ÿ”€ :: (#171) ๋‹ด๋‹น ๋ฐ˜ ์กฐํšŒ API (#118)
Browse files Browse the repository at this point in the history
๐Ÿ”€ :: (#171) ๋‹ด๋‹น ๋ฐ˜ ์กฐํšŒ API (#118)
  • Loading branch information
alsco39 authored Jul 8, 2023
1 parent f6bdc99 commit de9c807
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ interface ApplicationApi {

fun queryPicnicStudentListByToday(): QueryPicnicStudentList

fun getAllStudentStatusByClassroomId(classroomId: UUID): QueryStudentStatusList
fun queryAllStudentStatusByClassroomId(classroomId: UUID): QueryStudentStatusList

fun savePicnicPass(request: DomainPicnicPassRequest)

fun savePicnicAcceptOrRefuse(request: DomainPicnicAcceptOrRefuseRequest)

fun getMyPicnicEndTime(): QueryMyPicnicEndTimeResponse
fun queryMyPicnicEndTime(): QueryMyPicnicEndTimeResponse

fun getMyPicnicInfo(): QueryMyPicnicInfoResponse
fun queryMyPicnicInfo(): QueryMyPicnicInfoResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ class ApplicationUseCase(
return QueryPicnicStudentList(outing)
}

override fun getAllStudentStatusByClassroomId(classroomId: UUID): QueryStudentStatusList {
override fun queryAllStudentStatusByClassroomId(classroomId: UUID): QueryStudentStatusList {
val dateType = queryTypeSpi.queryDirectorTypeByDate(LocalDate.now()) ?: DirectorType.SELF_STUDY
val todayStudentStatusList = queryStatusSpi.queryStatusListByToday()
val classroom = queryClassroomSpi.queryClassroomById(classroomId) ?: throw ClassroomNotFoundException
Expand Down Expand Up @@ -505,7 +505,7 @@ class ApplicationUseCase(
}
}

override fun getMyPicnicEndTime(): QueryMyPicnicEndTimeResponse {
override fun queryMyPicnicEndTime(): QueryMyPicnicEndTimeResponse {
val userInfo = userSpi.queryUserInfoByUserId(userSpi.getCurrentUserId())
val picnicUserStatus = queryStatusSpi.queryPicnicStudentByStudentIdAndToday(userInfo.id)
?: throw StatusNotFoundException
Expand All @@ -521,7 +521,7 @@ class ApplicationUseCase(
)
}

override fun getMyPicnicInfo(): QueryMyPicnicInfoResponse {
override fun queryMyPicnicInfo(): QueryMyPicnicInfoResponse {
val userInfo = userSpi.queryUserInfoByUserId(userSpi.getCurrentUserId())
val picnicUserStatus = queryStatusSpi.queryPicnicStudentByStudentIdAndToday(userInfo.id)
?: throw StatusNotFoundException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ package com.pickdsm.pickserverspring.domain.teacher.api
import com.pickdsm.pickserverspring.domain.teacher.api.dto.request.DomainComebackStudentRequest
import com.pickdsm.pickserverspring.domain.teacher.api.dto.request.DomainUpdateStudentStatusRequest
import com.pickdsm.pickserverspring.domain.teacher.api.dto.response.QueryMovementStudentList
import com.pickdsm.pickserverspring.domain.teacher.api.dto.response.QueryMyBuckGradeAndClassNumResponse
import com.pickdsm.pickserverspring.domain.teacher.api.dto.response.QueryStudentStatusCountResponse
import java.util.UUID

interface TeacherApi {

fun updateStudentStatus(request: DomainUpdateStudentStatusRequest)

fun getStudentStatusCount(): QueryStudentStatusCountResponse
fun queryStudentStatusCount(): QueryStudentStatusCountResponse

fun comebackStudent(request: DomainComebackStudentRequest)

fun getMovementStudents(classroomId: UUID): QueryMovementStudentList
fun queryMovementStudents(classroomId: UUID): QueryMovementStudentList

fun queryMyBuckGradeAndClassNum(): QueryMyBuckGradeAndClassNumResponse
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.pickdsm.pickserverspring.domain.teacher.api.dto.response

data class QueryMyBuckGradeAndClassNumResponse(
val grade: Int,
val classNum: Int,
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import com.pickdsm.pickserverspring.domain.application.spi.CommandApplicationSpi
import com.pickdsm.pickserverspring.domain.application.spi.QueryApplicationSpi
import com.pickdsm.pickserverspring.domain.application.spi.QueryStatusSpi
import com.pickdsm.pickserverspring.domain.classroom.exception.ClassroomNotFoundException
import com.pickdsm.pickserverspring.domain.classroom.exception.FloorNotFoundException
import com.pickdsm.pickserverspring.domain.classroom.spi.QueryClassroomSpi
import com.pickdsm.pickserverspring.domain.selfstudydirector.spi.QuerySelfStudyDirectorSpi
import com.pickdsm.pickserverspring.domain.selfstudydirector.spi.QueryTypeSpi
import com.pickdsm.pickserverspring.domain.teacher.api.TeacherApi
import com.pickdsm.pickserverspring.domain.teacher.api.dto.request.DomainComebackStudentRequest
import com.pickdsm.pickserverspring.domain.teacher.api.dto.request.DomainUpdateStudentStatusRequest
import com.pickdsm.pickserverspring.domain.teacher.api.dto.response.QueryMovementStudentList
import com.pickdsm.pickserverspring.domain.teacher.api.dto.response.QueryMovementStudentList.MovementStudent
import com.pickdsm.pickserverspring.domain.teacher.api.dto.response.QueryMyBuckGradeAndClassNumResponse
import com.pickdsm.pickserverspring.domain.teacher.api.dto.response.QueryStudentStatusCountResponse
import com.pickdsm.pickserverspring.domain.teacher.spi.StatusCommandTeacherSpi
import com.pickdsm.pickserverspring.domain.teacher.spi.TimeQueryTeacherSpi
Expand Down Expand Up @@ -64,7 +63,7 @@ class TeacherUseCase(
statusCommandTeacherSpi.saveStatus(saveOrUpdateStatus)
}

override fun getStudentStatusCount(): QueryStudentStatusCountResponse {
override fun queryStudentStatusCount(): QueryStudentStatusCountResponse {
val teacherResponsibleFloor = querySelfStudyDirectorSpi.queryResponsibleFloorByTeacherIdAndToday(userSpi.getCurrentUserId())
return QueryStudentStatusCountResponse(
picnic = queryStatusSpi.queryPicnicStatusSizeByToday(),
Expand Down Expand Up @@ -93,7 +92,7 @@ class TeacherUseCase(
)
}

override fun getMovementStudents(classroomId: UUID): QueryMovementStudentList {
override fun queryMovementStudents(classroomId: UUID): QueryMovementStudentList {
val classroom = queryClassroomSpi.queryClassroomById(classroomId)
?: throw ClassroomNotFoundException
val movementStatusList = queryStatusSpi.queryMovementStatusListByTodayAndClassroomId(classroomId)
Expand All @@ -117,6 +116,13 @@ class TeacherUseCase(
return QueryMovementStudentList(movementList.sortedBy { it.studentNumber })
}

override fun queryMyBuckGradeAndClassNum(): QueryMyBuckGradeAndClassNumResponse {
val userId = userSpi.getCurrentUserId()
val userInfo = userSpi.queryUserInfoByUserId(userId)

return QueryMyBuckGradeAndClassNumResponse(userInfo.grade, userInfo.classNum)
}

private fun User.paddedUserNum(): String =
this.num.toString().padStart(2, '0')
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class AdminWebAdapter(

@GetMapping("/students/count")
fun getStudentStatusCount(): QueryStudentStatusCountResponse {
return teacherApi.getStudentStatusCount()
return teacherApi.queryStudentStatusCount()
}

@GetMapping("/afterSchool/{after-school-id}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,17 @@ class ApplicationWebAdapter(

@GetMapping("/return")
fun getMyPicnicEndTime(): QueryMyPicnicEndTimeResponse {
return applicationApi.getMyPicnicEndTime()
return applicationApi.queryMyPicnicEndTime()
}

@GetMapping("/picnic")
fun getMyPicnicInfo(): QueryMyPicnicInfoResponse {
return applicationApi.getMyPicnicInfo()
return applicationApi.queryMyPicnicInfo()
}

@ResponseStatus(HttpStatus.NO_CONTENT)
@DeleteMapping
fun returnClassroom() = classroomMovementApi.returnClassroomMovement()
fun returnClassroom() {
classroomMovementApi.returnClassroomMovement()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.pickdsm.pickserverspring.domain.teacher.api.TeacherApi
import com.pickdsm.pickserverspring.domain.teacher.api.dto.request.DomainComebackStudentRequest
import com.pickdsm.pickserverspring.domain.teacher.api.dto.request.DomainUpdateStudentStatusRequest
import com.pickdsm.pickserverspring.domain.teacher.api.dto.response.QueryMovementStudentList
import com.pickdsm.pickserverspring.domain.teacher.api.dto.response.QueryMyBuckGradeAndClassNumResponse
import com.pickdsm.pickserverspring.domain.teacher.presentation.dto.request.ComebackStudentRequest
import com.pickdsm.pickserverspring.domain.teacher.presentation.dto.request.PicnicAcceptOrRefuseRequest
import com.pickdsm.pickserverspring.domain.teacher.presentation.dto.request.UpdateStudentStatusRequest
Expand Down Expand Up @@ -97,13 +98,18 @@ class TeacherWebAdapter(
fun queryStudentStatusByToday(
@PathVariable("classroom-id") classroomId: UUID,
): QueryStudentStatusList {
return applicationApi.getAllStudentStatusByClassroomId(classroomId)
return applicationApi.queryAllStudentStatusByClassroomId(classroomId)
}

@GetMapping("/{classroom-id}")
fun getMovementStatus(
fun queryMovementStatus(
@PathVariable("classroom-id") classroomId: UUID,
): QueryMovementStudentList {
return teacherApi.getMovementStudents(classroomId)
return teacherApi.queryMovementStudents(classroomId)
}

@GetMapping("/buck")
fun queryMyBuckGradeAndClassNum(): QueryMyBuckGradeAndClassNumResponse {
return teacherApi.queryMyBuckGradeAndClassNum()
}
}

0 comments on commit de9c807

Please sign in to comment.