Skip to content

Commit

Permalink
v1.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyoil2 committed Aug 13, 2024
2 parents d5c9e19 + 05ad324 commit 631db82
Show file tree
Hide file tree
Showing 54 changed files with 588 additions and 351 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/xquare-cd-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ jobs:
NEIS_KEY=${{ secrets.NEIS_KEY }}
SES_SENDER=${{ secrets.SES_SENDER }}
S3_BUCKET_NAME=${{ secrets.S3_BUCKET_NAME }}
FCM_FILE_URL=${{ secrets.FCM_FILE_URL }}
FCM_FILE_URL=${{ secrets.FCM_FILE_URL }}
FLYWAY_ENABLED=${{ secrets.FLYWAY_ENABLED }}
BASELINE_ON_MIGRATE=${{ secrets.BASELINE_ON_MIGRATE }}
4 changes: 3 additions & 1 deletion .github/workflows/xquare-cd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ jobs:
NEIS_KEY=${{ secrets.NEIS_KEY }}
SES_SENDER=${{ secrets.SES_SENDER }}
S3_BUCKET_NAME=${{ secrets.S3_BUCKET_NAME }}
FCM_FILE_URL=${{ secrets.FCM_FILE_URL }}
FCM_FILE_URL=${{ secrets.FCM_FILE_URL }}
FLYWAY_ENABLED=${{ secrets.FLYWAY_ENABLED }}
BASELINE_ON_MIGRATE=${{ secrets.BASELINE_ON_MIGRATE }}
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,11 @@ ENV S3_BUCKET_NAME ${S3_BUCKET_NAME}
ARG FCM_FILE_URL
ENV FCM_FILE_URL ${FCM_FILE_URL}

ARG FLYWAY_ENABLED
ENV FLYWAY_ENABLED ${FLYWAY_ENABLED}

ARG BASELINE_ON_MIGRATE
ENV BASELINE_ON_MIGRATE ${BASELINE_ON_MIGRATE}

COPY ./dms-infrastructure/build/libs/*.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ interface NotificationEventPort {
fun publishNotification(deviceToken: DeviceToken, notification: Notification)

fun publishNotificationToAllByTopic(notification: Notification)

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

interface EventPort : NotificationEventPort
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ package team.aliens.dms.domain.auth.dto

data class SignInRequest(
val accountId: String,
val password: String
val password: String,
val deviceToken: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import team.aliens.dms.common.service.security.SecurityService
import team.aliens.dms.domain.auth.dto.SignInRequest
import team.aliens.dms.domain.auth.dto.TokenFeatureResponse
import team.aliens.dms.domain.auth.spi.JwtPort
import team.aliens.dms.domain.notification.model.DeviceToken
import team.aliens.dms.domain.notification.service.NotificationService
import team.aliens.dms.domain.school.service.SchoolService
import team.aliens.dms.domain.user.service.UserService

Expand All @@ -13,7 +15,8 @@ class SignInUseCase(
private val securityService: SecurityService,
private val userService: UserService,
private val schoolService: SchoolService,
private val jwtPort: JwtPort
private val notificationService: NotificationService,
private val jwtPort: JwtPort,
) {

fun execute(request: SignInRequest): TokenFeatureResponse {
Expand All @@ -26,6 +29,17 @@ class SignInUseCase(
)
val availableFeatures = schoolService.getAvailableFeaturesBySchoolId(user.schoolId)

if (notificationService.checkDeviceTokenByUserId(user.id))
notificationService.deleteDeviceTokenByUserId(user.id)

notificationService.saveDeviceToken(
DeviceToken(
userId = user.id,
schoolId = user.schoolId,
token = request.deviceToken
)
)

return TokenFeatureResponse.of(tokenResponse, availableFeatures)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ data class TopicSubscriptionGroupsResponse(
topicGroupsMap[it.topicGroup]?.add(
TopicSubscriptionResponse(
topic = it,
isSubscribed = topicSubscriptionsMap[it]?.isSubscribed ?: false
isSubscribed = topicSubscriptionsMap[it]?.isSubscribed ?: true
)
)
}
Expand All @@ -52,7 +52,5 @@ data class TopicGroupSubscriptionResponse(

data class TopicSubscriptionResponse(
val topic: Topic,
val title: String = topic.title,
val description: String = topic.content,
val isSubscribed: Boolean
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package team.aliens.dms.domain.notification.model

import team.aliens.dms.domain.notice.model.Notice
import team.aliens.dms.domain.outing.model.OutingApplication
import team.aliens.dms.domain.point.model.PointHistory
import java.time.LocalDateTime
import java.util.UUID

Expand Down Expand Up @@ -49,4 +51,29 @@ sealed class Notification(
threadId = notice.id.toString(),
isSaveRequired = true
)

class OutingNotification(
schoolId: UUID,
outing: OutingApplication
) : Notification(
schoolId = schoolId,
topic = Topic.OUTING,
linkIdentifier = outing.id.toString(),
title = "외출이 신청되었습니다",
content = "외출 시간은 " + outing.outingTime + " ~ " + outing.arrivalTime + "입니다",
threadId = outing.id.toString(),
isSaveRequired = true
)

class PointNotification(
pointHistory: PointHistory
) : Notification(
schoolId = pointHistory.schoolId,
topic = Topic.POINT,
linkIdentifier = pointHistory.id.toString(),
title = pointHistory.getTitle(),
content = pointHistory.pointName,
threadId = pointHistory.id.toString(),
isSaveRequired = true
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,31 @@ enum class TopicGroup(
val groupName: String
) {
NOTICE("공지"),
STUDY_ROOM("자습실")
STUDY_ROOM("자습실"),
POINT("상벌점"),
OUTING("외출")
}

enum class Topic(
val topicGroup: TopicGroup,
val title: String,
val content: String
val topicGroup: TopicGroup
) {
NOTICE(
topicGroup = TopicGroup.NOTICE,
title = "공지 알림",
content = "기숙사 공지에 대한 알림입니다."
topicGroup = TopicGroup.NOTICE
),

STUDY_ROOM_TIME_SLOT(
topicGroup = TopicGroup.STUDY_ROOM,
title = "이용 시간 알림",
content = "자습실 이용 시작 10분 전에 알림을 받을 수 있습니다."
topicGroup = TopicGroup.STUDY_ROOM
),

STUDY_ROOM_APPLY(
topicGroup = TopicGroup.STUDY_ROOM,
title = "신청 시간 알림",
content = "자습실 신청 시간을 알리는 알림입니다."
topicGroup = TopicGroup.STUDY_ROOM
),

POINT(
topicGroup = TopicGroup.POINT
),

OUTING(
topicGroup = TopicGroup.OUTING
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package team.aliens.dms.domain.notification.service

import java.util.UUID

interface CheckNotificationService {

fun checkDeviceTokenByUserId(userId: UUID): Boolean
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package team.aliens.dms.domain.notification.service

import team.aliens.dms.common.annotation.Service
import team.aliens.dms.domain.notification.spi.QueryDeviceTokenPort
import java.util.UUID

@Service
class CheckNotificationServiceImpl(
private val deviceTokenPort: QueryDeviceTokenPort
) : CheckNotificationService {

override fun checkDeviceTokenByUserId(userId: UUID): Boolean {
return deviceTokenPort.existsDeviceTokenByUserId(userId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ interface CommandNotificationService {

fun saveDeviceToken(deviceToken: DeviceToken): DeviceToken

fun deleteDeviceTokenByUserId(userId: UUID)

fun deleteNotificationOfUserByUserIdAndId(userId: UUID, notificationOfUserId: UUID)

fun deleteNotificationOfUserByUserId(userId: UUID)

fun saveNotificationOfUser(notificationOfUser: NotificationOfUser): NotificationOfUser

fun saveNotificationsOfUser(notificationOfUsers: List<NotificationOfUser>)

fun deleteOldNotifications()
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
package team.aliens.dms.domain.notification.service

import team.aliens.dms.common.annotation.Service
import team.aliens.dms.domain.notification.exception.DeviceTokenNotFoundException
import team.aliens.dms.domain.notification.exception.NotificationOfUserNotFoundException
import team.aliens.dms.domain.notification.model.DeviceToken
import team.aliens.dms.domain.notification.model.NotificationOfUser
import team.aliens.dms.domain.notification.spi.CommandDeviceTokenPort
import team.aliens.dms.domain.notification.spi.CommandNotificationOfUserPort
import team.aliens.dms.domain.notification.spi.DeviceTokenPort
import team.aliens.dms.domain.notification.spi.NotificationPort
import team.aliens.dms.domain.notification.spi.QueryNotificationOfUserPort
import team.aliens.dms.domain.notification.spi.TopicSubscriptionPort
import java.time.LocalDateTime
import java.util.UUID

@Service
class CommandNotificationServiceImpl(
private val deviceTokenPort: CommandDeviceTokenPort,
private val deviceTokenPort: DeviceTokenPort,
private val notificationPort: NotificationPort,
private val queryNotificationOfUserPort: QueryNotificationOfUserPort,
private val commandNotificationOfUserPort: CommandNotificationOfUserPort
private val commandNotificationOfUserPort: CommandNotificationOfUserPort,
private val topicSubscriptionPort: TopicSubscriptionPort
) : CommandNotificationService {

override fun saveDeviceToken(deviceToken: DeviceToken): DeviceToken {
Expand All @@ -26,6 +30,17 @@ class CommandNotificationServiceImpl(
}
}

override fun deleteDeviceTokenByUserId(userId: UUID) {
val deviceToken = deviceTokenPort.queryDeviceTokenByUserId(userId)

if (deviceToken != null) {
topicSubscriptionPort.deleteAllByDeviceTokenId(deviceToken.id)
deviceTokenPort.deleteDeviceTokenByUserId(userId)
} else {
throw DeviceTokenNotFoundException
}
}

override fun deleteNotificationOfUserByUserIdAndId(userId: UUID, notificationOfUserId: UUID) {
queryNotificationOfUserPort.queryNotificationOfUserById(notificationOfUserId).also {
if (it == null || it.userId != userId) {
Expand All @@ -46,4 +61,9 @@ class CommandNotificationServiceImpl(
override fun saveNotificationsOfUser(notificationOfUsers: List<NotificationOfUser>) {
commandNotificationOfUserPort.saveNotificationsOfUser(notificationOfUsers)
}

override fun deleteOldNotifications() {
val cutoffDate = LocalDateTime.now().minusDays(60)
commandNotificationOfUserPort.deleteOldNotificationOfUsers(cutoffDate)
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package team.aliens.dms.domain.notification.service

import team.aliens.dms.common.dto.PageData
import team.aliens.dms.domain.notification.model.DeviceToken
import team.aliens.dms.domain.notification.model.NotificationOfUser
import team.aliens.dms.domain.notification.model.TopicSubscription
import java.util.UUID

interface GetNotificationService {

fun getNotificationOfUsersByUserId(userId: UUID, pageData: PageData): List<NotificationOfUser>
fun getNotificationOfUsersByUserId(userId: UUID): List<NotificationOfUser>

fun getTopicSubscriptionsByToken(token: String): List<TopicSubscription>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package team.aliens.dms.domain.notification.service

import team.aliens.dms.common.annotation.Service
import team.aliens.dms.common.dto.PageData
import team.aliens.dms.domain.notification.exception.DeviceTokenNotFoundException
import team.aliens.dms.domain.notification.model.TopicSubscription
import team.aliens.dms.domain.notification.spi.QueryDeviceTokenPort
Expand All @@ -16,8 +15,8 @@ class GetNotificationServiceImpl(
private val topicSubscriptionPort: QueryTopicSubscriptionPort
) : GetNotificationService {

override fun getNotificationOfUsersByUserId(userId: UUID, pageData: PageData) =
notificationOfUserPort.queryNotificationOfUserByUserId(userId, pageData)
override fun getNotificationOfUsersByUserId(userId: UUID) =
notificationOfUserPort.queryNotificationOfUserByUserId(userId)

override fun getTopicSubscriptionsByToken(token: String): List<TopicSubscription> {
val savedToken = getDeviceTokenByToken(token)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import team.aliens.dms.domain.notification.model.Topic

interface NotificationService :
GetNotificationService,
CheckNotificationService,
CommandNotificationService {

fun unsubscribeTopic(token: String, topic: Topic)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ class NotificationServiceImpl(
private val commandTopicSubscriptionPort: CommandTopicSubscriptionPort,
private val notificationOfUserPort: CommandNotificationOfUserPort,
getNotificationService: GetNotificationService,
checkNotificationService: CheckNotificationService,
commandNotificationService: CommandNotificationService
) : NotificationService,
GetNotificationService by getNotificationService,
CheckNotificationService by checkNotificationService,
CommandNotificationService by commandNotificationService {

override fun subscribeTopic(token: String, topic: Topic) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package team.aliens.dms.domain.notification.spi

import team.aliens.dms.domain.notification.model.NotificationOfUser
import java.time.LocalDateTime
import java.util.UUID

interface CommandNotificationOfUserPort {
Expand All @@ -12,4 +13,6 @@ interface CommandNotificationOfUserPort {
fun deleteNotificationOfUserById(notificationOfUserId: UUID)

fun deleteNotificationOfUserByUserId(userId: UUID)

fun deleteOldNotificationOfUsers(cutoffDate: LocalDateTime)
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package team.aliens.dms.domain.notification.spi

import team.aliens.dms.domain.notification.model.TopicSubscription
import java.util.UUID

interface CommandTopicSubscriptionPort {

fun saveTopicSubscription(topicSubscription: TopicSubscription): TopicSubscription

fun saveAllTopicSubscriptions(topicSubscriptions: List<TopicSubscription>)

fun deleteAllByDeviceTokenId(deviceTokenId: UUID)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import java.util.UUID

interface QueryDeviceTokenPort {

fun existsDeviceTokenByUserId(userId: UUID): Boolean

fun queryDeviceTokenByUserId(userId: UUID): DeviceToken?

fun queryDeviceTokenByToken(token: String): DeviceToken?

fun queryDeviceTokensByStudentIds(studentIds: List<UUID>): List<DeviceToken>
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package team.aliens.dms.domain.notification.spi

import team.aliens.dms.common.dto.PageData
import team.aliens.dms.domain.notification.model.NotificationOfUser
import java.util.UUID

interface QueryNotificationOfUserPort {

fun queryNotificationOfUserByUserId(userId: UUID, pageData: PageData): List<NotificationOfUser>
fun queryNotificationOfUserByUserId(userId: UUID): List<NotificationOfUser>

fun queryNotificationOfUserById(notificationOfUserId: UUID): NotificationOfUser?
}
Loading

0 comments on commit 631db82

Please sign in to comment.