Skip to content
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
2 changes: 1 addition & 1 deletion dmforu-admin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {

implementation("org.springframework.boot:spring-boot-starter-web")

runtimeOnly(project(":dmforu-infrastructure:sqs"))
runtimeOnly(project(":dmforu-infrastructure:fcm"))
runtimeOnly(project(":dmforu-infrastructure:storage:mysql"))
runtimeOnly(project(":dmforu-infrastructure:storage:mongo"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.util.*
@SpringBootApplication(
scanBasePackages = [
"com.dmforu.admin",
"com.dmforu.sqs",
"com.dmforu.fcm",
"com.dmforu.storage.db.mongo",
"com.dmforu.storage.db.mysql"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ class MessageService(
sendDepartmentNoticeMessage(notice)
}

fun sendTestNoticeMessage(token: String, notice: Notice) {
if (notice.isUniversityNotice()) {
val keyword = keywordFilter.extractKeywordFrom(notice.title) ?: return
val message = NoticeMessage.createUniversityNoticeMessage(notice = notice, keyword = keyword)
messageSender.sendNoticeMessage(message = message, tokens = listOf(token))
return
}

val message = NoticeMessage.createDepartmentNoticeMessage(notice = notice)
messageSender.sendNoticeMessage(message = message, tokens = listOf(token))
}

private fun sendUniversityNoticeMessage(notice: Notice) {
val keyword = keywordFilter.extractKeywordFrom(notice.title) ?: return

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.dmforu.admin.presentation

import com.dmforu.admin.message.MessageService
import com.dmforu.admin.presentation.request.SendNoticeMessageRequest
import com.dmforu.domain.notice.Notice
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RestController
import java.time.LocalDate

@RestController
class PushMessageController(
private val messageService: MessageService,
) {
@PostMapping("/api/v1/messages/notice")
fun sendMessageToEvery(@RequestBody request: SendNoticeMessageRequest) {
val notice = Notice.of(
number = 0,
type = request.type,
date = LocalDate.now(),
title = request.title,
author = "관리자",
url = request.url
)

messageService.sendTestNoticeMessage(request.token, notice)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.dmforu.admin.presentation.request

data class SendNoticeMessageRequest(
val token: String,
val title: String,
val type: String,
val body: String,
val url: String
)
Loading