-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
308 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...rc/main/kotlin/team/comit/simtong/domain/notification/exception/NotificationExceptions.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,24 @@ | ||
package team.comit.simtong.domain.notification.exception | ||
|
||
import team.comit.simtong.global.exception.BusinessException | ||
|
||
/** | ||
* | ||
* Notification Domain에서 발생하는 Exception을 관리하는 NotificationExceptions | ||
* | ||
* @author kimbeomjin | ||
* @date 2022/12/29 | ||
* @version 1.1.0 | ||
**/ | ||
sealed class NotificationExceptions( | ||
override val status: Int, | ||
override val message: String, | ||
) : BusinessException(status, message) { | ||
|
||
// 404 | ||
class NotFound(message: String = NOT_FOUND) : NotificationExceptions(404, message) | ||
|
||
companion object { | ||
private const val NOT_FOUND = "알림을 찾을 수 없습니다." | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
simtong-domain/src/main/kotlin/team/comit/simtong/domain/notification/model/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,26 @@ | ||
package team.comit.simtong.domain.notification.model | ||
|
||
import java.time.LocalDateTime | ||
import java.util.UUID | ||
|
||
/** | ||
* | ||
* 알림 Aggregate의 Root를 담당하는 Notification | ||
* | ||
* @author kimbeomjin | ||
* @date 2022/12/29 | ||
* @version 1.1.0 | ||
**/ | ||
data class Notification( | ||
val id: UUID, | ||
|
||
val title: String, | ||
|
||
val content: String, | ||
|
||
val type: NotificationType, | ||
|
||
val identify: UUID?, | ||
|
||
val createdAt: LocalDateTime | ||
) |
18 changes: 18 additions & 0 deletions
18
...main/src/main/kotlin/team/comit/simtong/domain/notification/model/NotificationReceiver.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,18 @@ | ||
package team.comit.simtong.domain.notification.model | ||
|
||
import java.time.LocalDateTime | ||
import java.util.UUID | ||
|
||
/** | ||
* | ||
* 알림 Aggregate의 알림을 받은 수신자를 담당하는 NotificationReceiver | ||
* | ||
* @author kimbeomjin | ||
* @date 2022/12/29 | ||
* @version 1.1.0 | ||
**/ | ||
data class NotificationReceiver( | ||
val userId: UUID, | ||
val notificationId: UUID, | ||
val checkedAt: LocalDateTime | ||
) |
27 changes: 27 additions & 0 deletions
27
...g-domain/src/main/kotlin/team/comit/simtong/domain/notification/model/NotificationType.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,27 @@ | ||
package team.comit.simtong.domain.notification.model | ||
|
||
/** | ||
* | ||
* 알림의 종류를 구분하는 NotificationType | ||
* | ||
* @author kimbeomjin | ||
* @date 2022/12/29 | ||
* @version 1.1.0 | ||
**/ | ||
enum class NotificationType { | ||
|
||
/** | ||
* 메뉴 관련 알림 | ||
*/ | ||
MEAL, | ||
|
||
/** | ||
* 휴무일 관련 알림 | ||
*/ | ||
HOLIDAY, | ||
|
||
/** | ||
* 일정 관련 알림 | ||
*/ | ||
SCHEDULE | ||
} |
46 changes: 46 additions & 0 deletions
46
...c/main/kotlin/team/comit/simtong/persistence/notification/entity/NotificationJpaEntity.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,46 @@ | ||
package team.comit.simtong.persistence.notification.entity | ||
|
||
import team.comit.simtong.domain.notification.model.NotificationType | ||
import team.comit.simtong.persistence.BaseEntity | ||
import java.time.LocalDateTime | ||
import java.util.UUID | ||
import javax.persistence.Column | ||
import javax.persistence.Entity | ||
import javax.persistence.EnumType | ||
import javax.persistence.Enumerated | ||
import javax.persistence.Table | ||
import javax.validation.constraints.NotNull | ||
|
||
/** | ||
* | ||
* 알림에 관해 관리하는 JPA 엔티티인 NotificationJpaEntity | ||
* | ||
* @author kimbeomjin | ||
* @date 2022/12/29 | ||
* @version 1.1.0 | ||
**/ | ||
@Entity | ||
@Table(name = "tbl_notification") | ||
class NotificationJpaEntity( | ||
override val id: UUID, | ||
|
||
@field:NotNull | ||
@Column(columnDefinition = "VARCHAR(50)") | ||
val title: String, | ||
|
||
@field:NotNull | ||
@Column(columnDefinition = "VARCHAR(255)") | ||
val content: String, | ||
|
||
@field:NotNull | ||
@Column(columnDefinition = "VARCHAR(20)") | ||
@Enumerated(EnumType.STRING) | ||
val type: NotificationType, | ||
|
||
@Column(columnDefinition = "BINARY(16)") | ||
val identify: UUID?, | ||
|
||
@field:NotNull | ||
override val createdAt: LocalDateTime | ||
|
||
) : BaseEntity(id) |
61 changes: 61 additions & 0 deletions
61
...otlin/team/comit/simtong/persistence/notification/entity/NotificationReceiverJpaEntity.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,61 @@ | ||
package team.comit.simtong.persistence.notification.entity | ||
|
||
import team.comit.simtong.persistence.user.entity.UserJpaEntity | ||
import java.io.Serializable | ||
import java.time.LocalDateTime | ||
import java.util.UUID | ||
import javax.persistence.Column | ||
import javax.persistence.Embeddable | ||
import javax.persistence.EmbeddedId | ||
import javax.persistence.Entity | ||
import javax.persistence.FetchType | ||
import javax.persistence.JoinColumn | ||
import javax.persistence.ManyToOne | ||
import javax.persistence.MapsId | ||
import javax.persistence.Table | ||
|
||
/** | ||
* | ||
* 알림 수신자에 관해 관리하는 JPA 엔티티인 NotificationReceiverJpaEntity | ||
* | ||
* @author kimbeomjin | ||
* @date 2022/12/29 | ||
* @version 1.1.0 | ||
**/ | ||
@Entity | ||
@Table(name = "tbl_notification_receiver") | ||
class NotificationReceiverJpaEntity( | ||
@EmbeddedId | ||
val notificationReceiverId: Id, | ||
|
||
@MapsId("userId") | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id", columnDefinition = "BINARY(16)", nullable = false) | ||
val user: UserJpaEntity, | ||
|
||
@MapsId("notificationId") | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "notification_id", columnDefinition = "BINARY(16)", nullable = false) | ||
val notification: NotificationJpaEntity, | ||
|
||
val checkedAt: LocalDateTime? | ||
) { | ||
|
||
/** | ||
* | ||
* 알림 엔티티의 기본키인 NotificationReceiver Id | ||
* | ||
* @author kimbeomjin | ||
* @date 2022/12/29 | ||
* @version 1.1.0 | ||
**/ | ||
@Embeddable | ||
data class Id( | ||
@Column(columnDefinition = "BINARY(16)", nullable = false) | ||
val userId: UUID, | ||
|
||
@Column(columnDefinition = "BINARY(16)", nullable = false) | ||
val notificationId: UUID | ||
) : Serializable | ||
} | ||
|
18 changes: 18 additions & 0 deletions
18
.../src/main/kotlin/team/comit/simtong/persistence/notification/mapper/NotificationMapper.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,18 @@ | ||
package team.comit.simtong.persistence.notification.mapper | ||
|
||
import org.mapstruct.Mapper | ||
import team.comit.simtong.domain.notification.model.Notification | ||
import team.comit.simtong.persistence.GenericMapper | ||
import team.comit.simtong.persistence.notification.entity.NotificationJpaEntity | ||
|
||
/** | ||
* | ||
* Notification Entity와 Notification Aggregate를 변환하는 NotificationMapper | ||
* | ||
* @author kimbeomjin | ||
* @date 2022/12/29 | ||
* @version 1.1.0 | ||
**/ | ||
@Mapper | ||
abstract class NotificationMapper : GenericMapper<NotificationJpaEntity, Notification> { | ||
} |
53 changes: 53 additions & 0 deletions
53
...n/kotlin/team/comit/simtong/persistence/notification/mapper/NotificationReceiverMapper.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,53 @@ | ||
package team.comit.simtong.persistence.notification.mapper | ||
|
||
import org.mapstruct.Mapper | ||
import org.mapstruct.Mapping | ||
import org.mapstruct.Mappings | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import team.comit.simtong.domain.notification.model.NotificationReceiver | ||
import team.comit.simtong.persistence.GenericMapper | ||
import team.comit.simtong.persistence.notification.entity.NotificationReceiverJpaEntity | ||
import team.comit.simtong.persistence.notification.repository.NotificationJpaRepository | ||
import team.comit.simtong.persistence.spot.SpotJpaRepository | ||
import team.comit.simtong.persistence.user.repository.UserJpaRepository | ||
|
||
/** | ||
* | ||
* NotificationReceiver Entity와 NotificationReceiver Aggregate를 변환하는 NotificationReceiverMapper | ||
* | ||
* @author kimbeomjin | ||
* @date 2022/12/29 | ||
* @version 1.1.0 | ||
**/ | ||
@Mapper | ||
abstract class NotificationReceiverMapper : GenericMapper<NotificationReceiverJpaEntity, NotificationReceiver> { | ||
|
||
@Autowired | ||
protected lateinit var notificationRepository: NotificationJpaRepository | ||
|
||
@Autowired | ||
protected lateinit var userRepository: UserJpaRepository | ||
|
||
@Mappings( | ||
Mapping( | ||
target = "notificationReceiverId", | ||
expression = "java(new NotificationReceiverJpaEntity.Id(model.getUserId(), model.getNotificationId()))" | ||
), | ||
Mapping( | ||
target = "user", | ||
expression = "java(userRepository.findById(model.getUserId()).orElse(null))" | ||
), | ||
Mapping( | ||
target = "notification", | ||
expression = "java(notificationRepository.findById(model.getNotificationId()).orElse(null))" | ||
) | ||
) | ||
abstract override fun toEntity(model: NotificationReceiver): NotificationReceiverJpaEntity | ||
|
||
@Mappings( | ||
Mapping(target = "userId", expression = "java(entity.getNotificationReceiverId().getUserId())"), | ||
Mapping(target = "notificationId", expression = "java(entity.getNotificationReceiverId().getNotificationId())") | ||
) | ||
abstract override fun toDomain(entity: NotificationReceiverJpaEntity?): NotificationReceiver? | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...otlin/team/comit/simtong/persistence/notification/repository/NotificationJpaRepository.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,18 @@ | ||
package team.comit.simtong.persistence.notification.repository | ||
|
||
import org.springframework.data.repository.CrudRepository | ||
import org.springframework.stereotype.Repository | ||
import team.comit.simtong.persistence.notification.entity.NotificationJpaEntity | ||
import java.util.UUID | ||
|
||
/** | ||
* | ||
* 알림의 Spring Repository를 담당하는 NotificationJpaRepository | ||
* | ||
* @author kimbeomjin | ||
* @date 2022/12/29 | ||
* @version 1.1.0 | ||
**/ | ||
@Repository | ||
interface NotificationJpaRepository : CrudRepository<NotificationJpaEntity, UUID> { | ||
} |
17 changes: 17 additions & 0 deletions
17
.../team/comit/simtong/persistence/notification/repository/NotificationReceiverRepository.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 team.comit.simtong.persistence.notification.repository | ||
|
||
import org.springframework.data.repository.CrudRepository | ||
import org.springframework.stereotype.Repository | ||
import team.comit.simtong.persistence.notification.entity.NotificationReceiverJpaEntity | ||
|
||
/** | ||
* | ||
* 알림 수신자의 Spring Repository를 담당하는 NotificationReceiverRepository | ||
* | ||
* @author kimbeomjin | ||
* @date 2022/12/29 | ||
* @version 1.1.0 | ||
**/ | ||
@Repository | ||
interface NotificationReceiverRepository : CrudRepository<NotificationReceiverJpaEntity, NotificationReceiverJpaEntity.Id> { | ||
} |