diff --git a/notification-app/entity/channel.go b/notification-app/entity/channel.go new file mode 100644 index 00000000..fa114320 --- /dev/null +++ b/notification-app/entity/channel.go @@ -0,0 +1,8 @@ +package entity + +type Channel struct { + ID int8 + Type notificationType + Provider string + Config string +} diff --git a/notification-app/entity/notification.go b/notification-app/entity/notification.go new file mode 100644 index 00000000..96887c62 --- /dev/null +++ b/notification-app/entity/notification.go @@ -0,0 +1,51 @@ +package entity + +type Notification struct { + ID int8 + Type NotificationType + Recipinet string + Body string + Status NotificationStatus +} + +type NotificationType uint8 + +const ( + Email NotificationType = iota + 1 + SMS + Push +) + +func (t NotificationType) String() string { + switch t { + case Email: + return "Email" + case SMS: + return "SMS" + case Push: + return "Push" + default: + return "Unknown" + } +} + +type NotificationStatus uint8 + +const ( + Pending NotificationStatus = iota + 1 + Success + Failed +) + +func (t NotificationStatus) String() string { + switch t { + case Pending: + return "Pending" + case Success: + return "Success" + case Failed: + return "Failed" + default: + return "Unknown" + } +} diff --git a/notification-app/messagebroker/redis.go b/notification-app/messagebroker/redis.go new file mode 100644 index 00000000..31dc8033 --- /dev/null +++ b/notification-app/messagebroker/redis.go @@ -0,0 +1,17 @@ +package messagebroker + +import "git.gocasts.ir/ebhomengo/niki/notification-app/entity" + +type redis struct { +} + +func (r *redis) AddItem(notification entity.Notification) error { + return nil +} + +func (r *redis) RemoveItem(notification entity.Notification) error { + return nil +} +func (r *redis) HealthCheck() error { + return nil +} diff --git a/notification-app/service/additem.go b/notification-app/service/additem.go new file mode 100644 index 00000000..c4702e35 --- /dev/null +++ b/notification-app/service/additem.go @@ -0,0 +1,48 @@ +package service + +import ( + _ "time" + + "git.gocasts.ir/ebhomengo/niki/notification-app/entity" +) + +type notifservice struct { + //MessageBroker MessageBroker +} + +func NewNotifservice() *notifservice { + return ¬ifservice{} +} + +func (n *notifservice) NewNotification(notificationType entity.NotificationType, Recipinet, Body string) *entity.Notification { + + return &entity.Notification{ + Type: notificationType, + Recipinet: Recipinet, + Body: Body, + Status: entity.Pending, + } +} + +func (n *notifservice) Send(notification entity.Notification) error { + return nil +} + +func (n *notifservice) Add(notification *entity.Notification) error { + return nil +} + +type MessageBroker interface { + AddItem(notification entity.Notification) error + RemoveItem(notification entity.Notification) error + HealthCheck() error +} + +func main() { + f := NewNotifservice() + + notif := f.NewNotification(entity.SMS, "09201008697", "Hello World") + + f.Add(notif) + +} diff --git a/notification-app/service/send.go b/notification-app/service/send.go new file mode 100644 index 00000000..ef8b6d87 --- /dev/null +++ b/notification-app/service/send.go @@ -0,0 +1,7 @@ +package service + +import "git.gocasts.ir/ebhomengo/niki/notification-app/entity" + +type sender interface { + Send(notification entity.Notification) error +}