Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge: (#716) 학생 조회 api 에 schoolId 추가 #717

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ interface GetStudentService {

fun getStudentsBySchoolId(schoolId: UUID): List<Student>

fun getAllStudentWithMinusPoint(): List<Pair<UUID, Int>>

fun getAllStudentsByIdsIn(studentIds: List<UUID>): List<Student>

fun getGcnUpdatedStudent(
Expand All @@ -53,7 +51,7 @@ interface GetStudentService {
studentVOs: List<ExcelStudentVO>,
): List<Student>

fun getAllStudentsByName(name: String?): List<AllStudentsVO>
fun getAllStudentsByName(name: String?, schoolId: UUID): List<AllStudentsVO>

fun isApplicant(studentId: UUID): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -69,15 +68,6 @@ class GetStudentServiceImpl(
override fun getStudentsBySchoolId(schoolId: UUID) =
queryStudentPort.queryStudentsBySchoolId(schoolId)

override fun getAllStudentWithMinusPoint(): List<Pair<UUID, Int>> =
queryStudentPort.queryAllStudentsByName("").map { student ->
val minusTotalPoint = queryPointHistoryPort.queryBonusAndMinusTotalPointByStudentGcnAndName(
gcn = student.gcn,
studentName = student.name
).second
Pair(student.id, minusTotalPoint)
}

override fun getAllStudentsByIdsIn(studentIds: List<UUID>) =
queryStudentPort.queryAllStudentsByIdsIn(studentIds)
.also { students ->
Expand Down Expand Up @@ -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<Pair<String, String>, Student>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ interface QueryStudentPort {

fun queryAllStudentsByIdsIn(studentIds: List<UUID>): List<Student>

fun queryAllStudentsByName(name: String?): List<AllStudentsVO>
fun queryAllStudentsByName(name: String?, schoolId: UUID): List<AllStudentsVO>
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ interface CommandTagService {

fun saveTag(tag: Tag): Tag

fun saveStudentTag(studentTag: StudentTag): StudentTag

fun saveAllStudentTags(studentTags: List<StudentTag>)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ class CommandTagServiceImpl(
return commandTagPort.saveTag(tag)
}

override fun saveStudentTag(studentTag: StudentTag): StudentTag =
commandStudentTagPort.saveStudentTag(studentTag)

override fun saveAllStudentTags(studentTags: List<StudentTag>) {
commandStudentTagPort.saveAllStudentTags(studentTags)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String>): List<StudentTag>

fun getStudentTagsByStudentId(studentId: UUID): List<StudentTag>

fun getAllStudentTagDetails(): List<StudentTagDetailVO>

fun getTagsByTagNameIn(names: List<String>): List<Tag>

fun getTagByName(name: String): Tag

fun getTagById(tagId: UUID): Tag

fun getTagsBySchoolId(schoolId: UUID): List<Tag>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,21 +14,12 @@ class GetTagServiceImpl(
private val queryStudentTagPort: QueryStudentTagPort
) : GetTagService {

override fun getStudentTagsByTagNameIn(names: List<String>): List<StudentTag> =
queryStudentTagPort.queryStudentTagsByTagNameIn(names)

override fun getStudentTagsByStudentId(studentId: UUID): List<StudentTag> =
queryStudentTagPort.queryStudentTagsByStudentId(studentId)

override fun getAllStudentTagDetails(): List<StudentTagDetailVO> =
queryStudentTagPort.queryAllStudentTagDetails()

override fun getTagsByTagNameIn(names: List<String>): List<Tag> =
queryTagPort.queryTagsByTagNameIn(names)

override fun getTagByName(name: String) =
queryTagPort.queryTagByName(name) ?: throw TagNotFoundException

override fun getTagById(tagId: UUID) =
queryTagPort.queryTagById(tagId) ?: throw TagNotFoundException

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ interface CommandStudentTagPort {

fun deleteStudentTagByTagId(tagId: UUID)

fun saveStudentTag(studentTag: StudentTag): StudentTag

fun saveAllStudentTags(studentTags: List<StudentTag>)
}
Original file line number Diff line number Diff line change
@@ -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<String>): List<StudentTag>

fun queryStudentTagsByStudentId(studentId: UUID): List<StudentTag>

fun queryAllStudentTagDetails(): List<StudentTagDetailVO>
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Tag>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class StudentPersistenceAdapter(
studentMapper.toDomain(it)!!
}

override fun queryAllStudentsByName(name: String?): List<AllStudentsVO> {
override fun queryAllStudentsByName(name: String?, schoolId: UUID): List<AllStudentsVO> {
return queryFactory
.select(
QQueryAllStudentsVO(
Expand All @@ -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()
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -22,11 +21,6 @@ class StudentTagPersistenceAdapter(
private val queryFactory: JPAQueryFactory
) : StudentTagPort {

override fun queryStudentTagsByStudentId(studentId: UUID): List<StudentTag> {
return studentTagRepository.findAllByStudentId(studentId)
.map { studentTagMapper.toDomain(it)!! }
}

override fun queryAllStudentTagDetails(): List<StudentTagDetailVO> {
return queryFactory.select(
QQueryStudentTagDetailVO(
Expand All @@ -42,16 +36,6 @@ class StudentTagPersistenceAdapter(
.fetch()
}

override fun queryStudentTagsByTagNameIn(names: List<String>): List<StudentTag> {
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<UUID>) {
queryFactory.delete(studentTagJpaEntity)
.where(studentTagJpaEntity.student.id.`in`(studentIds))
Expand All @@ -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<StudentTag>) {
studentTagRepository.saveAll(
studentTags.map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Loading