sent_notification.go
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package domain
import "time"
// 发送出的通知
type SentNotification struct {
// 发送出的通知ID
SentNotificationId int64 `json:"sentNotificationId"`
// 通知
Notification *Notification `json:"notification"`
// 通知接收者
Receiver *EmployeeInfo `json:"receiver"`
// 是否已读
IsRead bool `json:"isRead"`
// 通知读取时间
ReadTime time.Time `json:"readTime"`
}
type SentNotificationRepository interface {
Save(sentNotification *SentNotification) (*SentNotification, error)
Remove(sentNotification *SentNotification) (*SentNotification, error)
FindOne(queryOptions map[string]interface{}) (*SentNotification, error)
Find(queryOptions map[string]interface{}) (int64, []*SentNotification, error)
}
func (sentNotification *SentNotification) Identify() interface{} {
if sentNotification.SentNotificationId == 0 {
return nil
}
return sentNotification.SentNotificationId
}
func (sentNotification *SentNotification) Read() error {
sentNotification.IsRead = true
if sentNotification.ReadTime.IsZero() {
sentNotification.ReadTime = time.Now()
}
return nil
}