-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from ondosee/12-feature/save-notification
디바이스(FCM) 토큰 저장 API 구현
- Loading branch information
Showing
12 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,24 @@ jobs: | |
redis-version: 7 | ||
redis-port: 6379 | ||
|
||
- name: Set up MariaDB | ||
uses: getong/[email protected] | ||
with: | ||
host-port: 3306 | ||
mariadb-database: 'ondosee' | ||
mariadb-user: 'ondosee-admin' | ||
mariadb-password: ${{ secrets.MARIA_DB_PASSWORD }} | ||
|
||
- name: Grant MariaDB permissions | ||
run: | | ||
sudo apt-get install mariadb-client | ||
mysql -h 127.0.0.1 -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'ondosee-admin'@'%' IDENTIFIED BY '${{ secrets.MARIA_DB_PASSWORD }}'; FLUSH PRIVILEGES;" | ||
- name: Create 'ondosee' database | ||
run: | | ||
sudo apt-get install mariadb-client | ||
mysql -h 127.0.0.1 -u ondosee-admin -p${{ secrets.MARIA_DB_PASSWORD }} -e "CREATE DATABASE IF NOT EXISTS ondosee;" | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/com/ondosee/common/adapter/notification/CommandNotificationAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.ondosee.common.adapter.notification | ||
|
||
import com.ondosee.common.spi.notification.CommandNotificationPort | ||
import com.ondosee.common.spi.notification.QueryNotificationPort | ||
import com.ondosee.domain.notification.domain.entity.Notification | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class CommandNotificationAdapter( | ||
private val queryNotificationPort: QueryNotificationPort | ||
) : CommandNotificationPort { | ||
|
||
override fun saveDeviceToken(deviceToken: String) { | ||
|
||
val notification = Notification( | ||
deviceToken = deviceToken, | ||
alarmTime = null | ||
) | ||
|
||
queryNotificationPort.saveNotification(notification) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/com/ondosee/common/adapter/notification/QueryNotificationAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.ondosee.common.adapter.notification | ||
|
||
import com.ondosee.common.spi.notification.QueryNotificationPort | ||
import com.ondosee.domain.notification.domain.entity.Notification | ||
import com.ondosee.domain.notification.domain.repository.NotificationRepository | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class QueryNotificationAdapter( | ||
private val notificationRepository: NotificationRepository | ||
) : QueryNotificationPort { | ||
|
||
override fun saveNotification(notification: Notification): Notification { | ||
|
||
return notificationRepository.save(notification) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/com/ondosee/common/spi/notification/CommandNotificationPort.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.ondosee.common.spi.notification | ||
|
||
interface CommandNotificationPort { | ||
fun saveDeviceToken(deviceToken: String) | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/com/ondosee/common/spi/notification/QueryNotificationPort.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.ondosee.common.spi.notification | ||
|
||
import com.ondosee.domain.notification.domain.entity.Notification | ||
|
||
interface QueryNotificationPort { | ||
fun saveNotification(notification: Notification): Notification | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/com/ondosee/domain/notification/domain/entity/Notification.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.ondosee.domain.notification.domain.entity | ||
|
||
import java.time.LocalDateTime | ||
import javax.persistence.* | ||
|
||
@Entity | ||
@Table(name = "notification") | ||
data class Notification( | ||
@Id | ||
@Column(name = "notification_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
val id: Long = 0, | ||
|
||
@Column(name = "device_token") | ||
val deviceToken: String, | ||
|
||
@Column(name = "alarm_time") | ||
var alarmTime: LocalDateTime? | ||
) |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/com/ondosee/domain/notification/domain/repository/NotificationRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.ondosee.domain.notification.domain.repository | ||
|
||
import com.ondosee.domain.notification.domain.entity.Notification | ||
import org.springframework.data.repository.CrudRepository | ||
|
||
interface NotificationRepository : CrudRepository<Notification, Long> { | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/com/ondosee/domain/notification/presentation/NotificationController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.ondosee.domain.notification.presentation | ||
|
||
import com.ondosee.domain.notification.service.NotificationService | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RequestParam | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@RestController | ||
@RequestMapping("/notification") | ||
class NotificationController( | ||
private val notificationService: NotificationService | ||
) { | ||
@PostMapping | ||
fun saveNotification(@RequestParam deviceToken: String): ResponseEntity<Void> = | ||
notificationService.saveNotification(deviceToken) | ||
.let { ResponseEntity.status(HttpStatus.CREATED).build() } | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/com/ondosee/domain/notification/service/NotificationService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.ondosee.domain.notification.service | ||
|
||
interface NotificationService { | ||
fun saveNotification(deviceToken: String) | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/com/ondosee/domain/notification/service/NotificationServiceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.ondosee.domain.notification.service | ||
|
||
import com.ondosee.common.spi.notification.CommandNotificationPort | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class NotificationServiceImpl( | ||
private val commandNotificationPort: CommandNotificationPort | ||
) : NotificationService { | ||
override fun saveNotification(deviceToken: String) { | ||
commandNotificationPort.saveDeviceToken(deviceToken) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters