From 4651de4e11e4a5f7ca6aea791d38e7e116f456a9 Mon Sep 17 00:00:00 2001 From: enbraining Date: Thu, 24 Oct 2024 20:52:02 +0900 Subject: [PATCH] =?UTF-8?q?:recycle:=20=EC=A0=9C=EC=B6=9C=EB=90=9C=20?= =?UTF-8?q?=EC=9D=B8=EC=A6=9D=EC=A0=9C=20=EB=AA=A9=EB=A1=9D=EC=9D=84=20?= =?UTF-8?q?=EA=B0=81=20=EB=8B=B4=EC=9E=84=20=EC=84=A0=EC=83=9D=EB=8B=98=20?= =?UTF-8?q?=EB=B0=98=EC=9D=98=20=ED=95=99=EC=83=9D=EB=93=A4=EB=A7=8C=20?= =?UTF-8?q?=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84=EB=A1=9D=20=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/QueryStudentFormListUseCase.kt | 14 ++++++++++++-- .../domain/student/service/GetStudentService.kt | 2 ++ .../student/service/impl/GetStudentServiceImpl.kt | 3 +++ .../msg/sms/domain/student/spi/QueryStudentPort.kt | 1 + .../student/StudentPersistenceAdapter.kt | 10 ++++++++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryStudentFormListUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryStudentFormListUseCase.kt index 4c4edb18..a8e842d8 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryStudentFormListUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryStudentFormListUseCase.kt @@ -6,15 +6,25 @@ import team.msg.sms.domain.authentication.model.MarkingBoardType import team.msg.sms.domain.authentication.service.AuthenticationFormService import team.msg.sms.domain.authentication.service.MarkingBoardService import team.msg.sms.domain.student.service.StudentService +import team.msg.sms.domain.teacher.service.HomeroomTeacherService +import team.msg.sms.domain.teacher.service.TeacherService +import team.msg.sms.domain.user.service.UserService @ReadOnlyUseCase class QueryStudentFormListUseCase( private val studentService: StudentService, + private val userService: UserService, private val markingBoardService: MarkingBoardService, - private val authenticationFormService: AuthenticationFormService + private val authenticationFormService: AuthenticationFormService, + private val homeroomTeacherService: HomeroomTeacherService ) { fun execute(page: Int, size: Int, type: List?): UserBoardPageResponseData { - val studentIds = studentService.getStudentIds() + val currentUser = userService.getCurrentUser() + val currentHomeroomTeacher = homeroomTeacherService.getHomeroomTeacherByUserId(currentUser.id) + + val grade = currentHomeroomTeacher.grade + val classNum = currentHomeroomTeacher.classNum + val studentIds = studentService.getStudentIdsByGradeAndClassNum(grade, classNum) val authenticationFormId = authenticationFormService.getActiveAuthenticationFormId() diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/GetStudentService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/GetStudentService.kt index edeae38f..81f68387 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/GetStudentService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/GetStudentService.kt @@ -27,4 +27,6 @@ interface GetStudentService { fun currentStudent(): Student.StudentWithUserInfo fun getStudentIds(): List + + fun getStudentIdsByGradeAndClassNum(grade: Int, classNum: Int): List } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/GetStudentServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/GetStudentServiceImpl.kt index da4bac52..ee45dec5 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/GetStudentServiceImpl.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/GetStudentServiceImpl.kt @@ -63,4 +63,7 @@ class GetStudentServiceImpl( override fun getStudentIds(): List = studentPort.queryStudentIds() + + override fun getStudentIdsByGradeAndClassNum(grade: Int, classNum: Int): List = + studentPort.queryStudentIdsByGradeAndClassNum(grade, classNum) } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentPort.kt index ce727f18..93a3db15 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentPort.kt @@ -9,6 +9,7 @@ interface QueryStudentPort { fun queryStudentById(uuid: UUID): Student? fun queryStudentsWithPage(page: Int, size: Int): Student.StudentWithPageInfo fun queryStudentIds(): List + fun queryStudentIdsByGradeAndClassNum(grade: Int, classNum: Int): List fun queryStudentByUserId(userId: UUID): Student fun queryStudentUserInfoByUserId(userId: UUID): Student.StudentWithUserInfo? fun queryStudentByUser(user: User): Student diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentPersistenceAdapter.kt index 4933f4f0..416abc91 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentPersistenceAdapter.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentPersistenceAdapter.kt @@ -53,6 +53,16 @@ class StudentPersistenceAdapter( .fetch() } + override fun queryStudentIdsByGradeAndClassNum(grade: Int, classNum: Int): List { + val qStudent = QStudentJpaEntity.studentJpaEntity + + return queryFactory + .select(qStudent.id) + .from(qStudent) + .where(qStudent.user.stuNum.startsWith("${grade}${classNum}")) + .fetch() + } + override fun queryStudentByUserId(userId: UUID): Student = studentJpaRepository.findByUserId(userId)!!.toDomain()