diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/student/service/GetStudentService.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/student/service/GetStudentService.kt index 08132180e..894b6379a 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/student/service/GetStudentService.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/student/service/GetStudentService.kt @@ -38,8 +38,6 @@ interface GetStudentService { fun getStudentsBySchoolId(schoolId: UUID): List - fun getAllStudentWithMinusPoint(): List> - fun getAllStudentsByIdsIn(studentIds: List): List fun getGcnUpdatedStudent( @@ -53,7 +51,7 @@ interface GetStudentService { studentVOs: List, ): List - fun getAllStudentsByName(name: String?): List + fun getAllStudentsByName(name: String?, schoolId: UUID): List fun isApplicant(studentId: UUID): Boolean } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/student/service/GetStudentServiceImpl.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/student/service/GetStudentServiceImpl.kt index 5dcb5b49e..d9e66f4c8 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/student/service/GetStudentServiceImpl.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/student/service/GetStudentServiceImpl.kt @@ -20,7 +20,6 @@ import java.util.function.Function class GetStudentServiceImpl( private val securityPort: SecurityPort, private val queryStudentPort: QueryStudentPort, - private val queryPointHistoryPort: QueryPointHistoryPort, private val queryOutingApplicationPort: QueryOutingApplicationPort, ) : GetStudentService { @@ -69,15 +68,6 @@ class GetStudentServiceImpl( override fun getStudentsBySchoolId(schoolId: UUID) = queryStudentPort.queryStudentsBySchoolId(schoolId) - override fun getAllStudentWithMinusPoint(): List> = - queryStudentPort.queryAllStudentsByName("").map { student -> - val minusTotalPoint = queryPointHistoryPort.queryBonusAndMinusTotalPointByStudentGcnAndName( - gcn = student.gcn, - studentName = student.name - ).second - Pair(student.id, minusTotalPoint) - } - override fun getAllStudentsByIdsIn(studentIds: List) = queryStudentPort.queryAllStudentsByIdsIn(studentIds) .also { students -> @@ -105,8 +95,8 @@ class GetStudentServiceImpl( ) } - override fun getAllStudentsByName(name: String?) = - queryStudentPort.queryAllStudentsByName(name) + override fun getAllStudentsByName(name: String?, schoolId: UUID) = + queryStudentPort.queryAllStudentsByName(name, schoolId) override fun getGcnUpdatedStudent( studentMap: Map, Student>, diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/student/spi/QueryStudentPort.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/student/spi/QueryStudentPort.kt index 1683aff89..07c6afd3f 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/student/spi/QueryStudentPort.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/student/spi/QueryStudentPort.kt @@ -40,5 +40,5 @@ interface QueryStudentPort { fun queryAllStudentsByIdsIn(studentIds: List): List - fun queryAllStudentsByName(name: String?): List + fun queryAllStudentsByName(name: String?, schoolId: UUID): List } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/student/usecase/StudentGetAllStudentsUseCase.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/student/usecase/StudentGetAllStudentsUseCase.kt index dc8859def..ae0b31ae3 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/student/usecase/StudentGetAllStudentsUseCase.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/student/usecase/StudentGetAllStudentsUseCase.kt @@ -3,14 +3,17 @@ package team.aliens.dms.domain.student.usecase import team.aliens.dms.common.annotation.ReadOnlyUseCase import team.aliens.dms.domain.student.dto.StudentsResponse import team.aliens.dms.domain.student.service.StudentService +import team.aliens.dms.domain.user.service.UserService @ReadOnlyUseCase class StudentGetAllStudentsUseCase( - private val studentService: StudentService + private val studentService: StudentService, + private val userService: UserService ) { fun execute(name: String?): StudentsResponse { - val students = studentService.getAllStudentsByName(name) + val user = userService.getCurrentUser() + val students = studentService.getAllStudentsByName(name, user.schoolId) return StudentsResponse.of(students) } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/service/CommandTagService.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/service/CommandTagService.kt index b39a77554..8fd7463a5 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/service/CommandTagService.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/service/CommandTagService.kt @@ -14,7 +14,5 @@ interface CommandTagService { fun saveTag(tag: Tag): Tag - fun saveStudentTag(studentTag: StudentTag): StudentTag - fun saveAllStudentTags(studentTags: List) } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/service/CommandTagServiceImpl.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/service/CommandTagServiceImpl.kt index 96b0c49d7..e0d8be719 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/service/CommandTagServiceImpl.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/service/CommandTagServiceImpl.kt @@ -30,9 +30,6 @@ class CommandTagServiceImpl( return commandTagPort.saveTag(tag) } - override fun saveStudentTag(studentTag: StudentTag): StudentTag = - commandStudentTagPort.saveStudentTag(studentTag) - override fun saveAllStudentTags(studentTags: List) { commandStudentTagPort.saveAllStudentTags(studentTags) } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/service/GetTagService.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/service/GetTagService.kt index 45419ab76..04ec3c138 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/service/GetTagService.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/service/GetTagService.kt @@ -1,22 +1,15 @@ package team.aliens.dms.domain.tag.service -import team.aliens.dms.domain.tag.model.StudentTag import team.aliens.dms.domain.tag.model.Tag import team.aliens.dms.domain.tag.spi.vo.StudentTagDetailVO import java.util.UUID interface GetTagService { - fun getStudentTagsByTagNameIn(names: List): List - - fun getStudentTagsByStudentId(studentId: UUID): List - fun getAllStudentTagDetails(): List fun getTagsByTagNameIn(names: List): List - fun getTagByName(name: String): Tag - fun getTagById(tagId: UUID): Tag fun getTagsBySchoolId(schoolId: UUID): List diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/service/GetTagServiceImpl.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/service/GetTagServiceImpl.kt index d6fd5ba5f..e35ef24ee 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/service/GetTagServiceImpl.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/service/GetTagServiceImpl.kt @@ -2,7 +2,6 @@ package team.aliens.dms.domain.tag.service import team.aliens.dms.common.annotation.Service import team.aliens.dms.domain.tag.exception.TagNotFoundException -import team.aliens.dms.domain.tag.model.StudentTag import team.aliens.dms.domain.tag.model.Tag import team.aliens.dms.domain.tag.spi.QueryStudentTagPort import team.aliens.dms.domain.tag.spi.QueryTagPort @@ -15,21 +14,12 @@ class GetTagServiceImpl( private val queryStudentTagPort: QueryStudentTagPort ) : GetTagService { - override fun getStudentTagsByTagNameIn(names: List): List = - queryStudentTagPort.queryStudentTagsByTagNameIn(names) - - override fun getStudentTagsByStudentId(studentId: UUID): List = - queryStudentTagPort.queryStudentTagsByStudentId(studentId) - override fun getAllStudentTagDetails(): List = queryStudentTagPort.queryAllStudentTagDetails() override fun getTagsByTagNameIn(names: List): List = queryTagPort.queryTagsByTagNameIn(names) - override fun getTagByName(name: String) = - queryTagPort.queryTagByName(name) ?: throw TagNotFoundException - override fun getTagById(tagId: UUID) = queryTagPort.queryTagById(tagId) ?: throw TagNotFoundException diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/spi/CommandStudentTagPort.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/spi/CommandStudentTagPort.kt index 1233c4344..1df8d3623 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/spi/CommandStudentTagPort.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/spi/CommandStudentTagPort.kt @@ -11,7 +11,5 @@ interface CommandStudentTagPort { fun deleteStudentTagByTagId(tagId: UUID) - fun saveStudentTag(studentTag: StudentTag): StudentTag - fun saveAllStudentTags(studentTags: List) } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/spi/QueryStudentTagPort.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/spi/QueryStudentTagPort.kt index 1c5807a99..7d0b4763b 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/spi/QueryStudentTagPort.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/spi/QueryStudentTagPort.kt @@ -1,14 +1,8 @@ package team.aliens.dms.domain.tag.spi -import team.aliens.dms.domain.tag.model.StudentTag import team.aliens.dms.domain.tag.spi.vo.StudentTagDetailVO -import java.util.UUID interface QueryStudentTagPort { - fun queryStudentTagsByTagNameIn(names: List): List - - fun queryStudentTagsByStudentId(studentId: UUID): List - fun queryAllStudentTagDetails(): List } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/spi/QueryTagPort.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/spi/QueryTagPort.kt index 4e27f62b0..8d5d9ca68 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/spi/QueryTagPort.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/spi/QueryTagPort.kt @@ -11,8 +11,6 @@ interface QueryTagPort { fun queryTagById(tagId: UUID): Tag? - fun queryTagByName(name: String): Tag? - fun existsByNameAndSchoolId(name: String, schoolId: UUID): Boolean fun queryTagsByStudentId(studentId: UUID): List diff --git a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/student/StudentPersistenceAdapter.kt b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/student/StudentPersistenceAdapter.kt index ba0c2a21e..f8497c2cc 100644 --- a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/student/StudentPersistenceAdapter.kt +++ b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/student/StudentPersistenceAdapter.kt @@ -361,7 +361,7 @@ class StudentPersistenceAdapter( studentMapper.toDomain(it)!! } - override fun queryAllStudentsByName(name: String?): List { + override fun queryAllStudentsByName(name: String?, schoolId: UUID): List { return queryFactory .select( QQueryAllStudentsVO( @@ -374,7 +374,10 @@ class StudentPersistenceAdapter( ) ) .from(studentJpaEntity) - .where(name?.let { studentJpaEntity.name.contains(it) }) + .where( + studentJpaEntity.user.school.id.eq(schoolId) + .and(name?.let { studentJpaEntity.name.contains(it) }) + ) .fetch() } } diff --git a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/tag/StudentTagPersistenceAdapter.kt b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/tag/StudentTagPersistenceAdapter.kt index 408565db9..08896f0bc 100644 --- a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/tag/StudentTagPersistenceAdapter.kt +++ b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/tag/StudentTagPersistenceAdapter.kt @@ -1,6 +1,5 @@ package team.aliens.dms.persistence.tag -import com.querydsl.jpa.JPAExpressions.selectFrom import com.querydsl.jpa.impl.JPAQueryFactory import org.springframework.stereotype.Component import team.aliens.dms.domain.tag.model.StudentTag @@ -22,11 +21,6 @@ class StudentTagPersistenceAdapter( private val queryFactory: JPAQueryFactory ) : StudentTagPort { - override fun queryStudentTagsByStudentId(studentId: UUID): List { - return studentTagRepository.findAllByStudentId(studentId) - .map { studentTagMapper.toDomain(it)!! } - } - override fun queryAllStudentTagDetails(): List { return queryFactory.select( QQueryStudentTagDetailVO( @@ -42,16 +36,6 @@ class StudentTagPersistenceAdapter( .fetch() } - override fun queryStudentTagsByTagNameIn(names: List): List { - return queryFactory.selectFrom(studentTagJpaEntity) - .join(tagJpaEntity).on(tagJpaEntity.id.eq(studentTagJpaEntity.tag.id)) - .where(tagJpaEntity.name.`in`(names)) - .fetch() - .map { - studentTagMapper.toDomain(it)!! - } - } - override fun deleteAllStudentTagsByStudentIdIn(studentIds: List) { queryFactory.delete(studentTagJpaEntity) .where(studentTagJpaEntity.student.id.`in`(studentIds)) @@ -71,12 +55,6 @@ class StudentTagPersistenceAdapter( studentTagRepository.deleteByTagId(tagId) } - override fun saveStudentTag(studentTag: StudentTag) = studentTagMapper.toDomain( - studentTagRepository.save( - studentTagMapper.toEntity(studentTag) - ) - )!! - override fun saveAllStudentTags(studentTags: List) { studentTagRepository.saveAll( studentTags.map { diff --git a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/tag/TagPersistenceAdapter.kt b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/tag/TagPersistenceAdapter.kt index 1bd929d6f..d29415135 100644 --- a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/tag/TagPersistenceAdapter.kt +++ b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/tag/TagPersistenceAdapter.kt @@ -41,12 +41,6 @@ class TagPersistenceAdapter( ) } - override fun queryTagByName(name: String): Tag? { - return tagMapper.toDomain( - tagRepository.findByName(name) - ) - } - override fun deleteTagById(tagId: UUID) { tagRepository.deleteById(tagId) }