Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyoil2 committed Aug 19, 2024
2 parents 631db82 + 463abed commit 57c814a
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ interface NotificationEventPort {

fun publishNotification(deviceToken: DeviceToken, notification: Notification)

fun publishNotificationToAllByTopic(notification: Notification)

fun publishNotificationToApplicant(deviceTokens: List<DeviceToken>, notification: Notification)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,26 @@ import team.aliens.dms.common.spi.NotificationEventPort
import team.aliens.dms.common.spi.SecurityPort
import team.aliens.dms.domain.notice.model.Notice
import team.aliens.dms.domain.notice.spi.CommandNoticePort
import team.aliens.dms.domain.notification.model.DeviceToken
import team.aliens.dms.domain.notification.model.Notification
import team.aliens.dms.domain.notification.spi.QueryDeviceTokenPort

@Service
class CommandNoticeServiceImpl(
private val commandNoticePort: CommandNoticePort,
private val notificationEventPort: NotificationEventPort,
private val securityPort: SecurityPort
private val securityPort: SecurityPort,
private val deviceTokenPort: QueryDeviceTokenPort,
) : CommandNoticeService {

override fun saveNotice(notice: Notice): Notice {
val schoolId = securityPort.getCurrentUserSchoolId()
val deviceTokens: List<DeviceToken> = deviceTokenPort.queryDeviceTokensBySchoolId(schoolId)

return commandNoticePort.saveNotice(notice)
.also {
notificationEventPort.publishNotificationToAllByTopic(
Notification.NoticeNotification(schoolId, it)
notificationEventPort.publishNotificationToApplicant(
deviceTokens, Notification.NoticeNotification(schoolId, it)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ interface QueryDeviceTokenPort {
fun queryDeviceTokenByToken(token: String): DeviceToken?

fun queryDeviceTokensByStudentIds(studentIds: List<UUID>): List<DeviceToken>

fun queryDeviceTokensBySchoolId(schoolId: UUID): List<DeviceToken>
}
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 @@ -20,20 +20,7 @@ class EventAdapter(
)
}

override fun publishNotificationToAllByTopic(
notification: Notification
) {
eventPublisher.publishEvent(
TopicNotificationEvent(
notification = notification
)
)
}

override fun publishNotificationToApplicant(
deviceTokens: List<DeviceToken>,
notification: Notification
) {
override fun publishNotificationToApplicant(deviceTokens: List<DeviceToken>, notification: Notification) {
eventPublisher.publishEvent(
GroupNotificationEvent(
deviceTokens = deviceTokens,
Expand Down
10 changes: 10 additions & 0 deletions dms-infrastructure/src/main/resources/banner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
${AnsiColor.BRIGHT_CYAN} ,-.,-. ,--------.,------. ,---. ,--. ,--. ,------. ,--. ,--. ,---. ,-.,-.
${AnsiColor.BRIGHT_CYAN} / / / '--. .--'| .---' / O \ | `.' | | .-. \ | `.' |' .-' \ \ \
${AnsiColor.BRIGHT_CYAN}/ / / | | | `--, | .-. || |'.'| | | | \ :| |'.'| |`. `-. \ \ \
${AnsiColor.BRIGHT_CYAN}\ \ \ | | | `---.| | | || | | | | '--' /| | | |.-' | / / /
${AnsiColor.BRIGHT_CYAN} \ \ \ `--' `------'`--' `--'`--' `--' `-------' `--' `--'`-----' / / /
${AnsiColor.BRIGHT_CYAN} `-'`-' `-'`-'
${AnsiColor.BRIGHT_WHITE}Domitory Management System
${AnsiColor.BLUE}최고의 기숙사 관리 서비스
${AnsiColor.BRIGHT_GREEN}Powered by Spring Boot ${spring-boot.version}
${AnsiColor.WHITE}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import java.util.UUID
class DeviceTokenPersistenceAdapter(
private val notificationMapper: DeviceTokenMapper,
private val deviceTokenRepository: DeviceTokenJpaRepository,
private val queryFactory: JPAQueryFactory
private val queryFactory: JPAQueryFactory,
) : DeviceTokenPort {

override fun existsDeviceTokenByUserId(userId: UUID): Boolean {
Expand Down Expand Up @@ -48,6 +48,17 @@ class DeviceTokenPersistenceAdapter(
}
}

override fun queryDeviceTokensBySchoolId(schoolId: UUID): List<DeviceToken> {
return queryFactory
.selectFrom(deviceTokenJpaEntity)
.join(deviceTokenJpaEntity.user, userJpaEntity)
.where(userJpaEntity.school.id.eq(schoolId))
.fetch()
.map {
notificationMapper.toDomain(it)!!
}
}

override fun deleteDeviceTokenByUserId(userId: UUID) {
deviceTokenRepository.deleteByUserId(userId)
}
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

0 comments on commit 57c814a

Please sign in to comment.