notification.go 1.3 KB
package domain

import "time"

const (
	NOTIFICATION_TYPE_SYSTEM      = iota + 1 //系统通知
	NOTIFICATION_TYPE_INTERACTION            //互动通知
)

const (
	EXTERNAL_RESOURCE_TYPE_TASK = iota + 1 //任务
	EXTERNAL_RESOURCE_TYPE_REJECT_TASK_RECORD  //驳回任务记录
)

// 通知
type Notification struct {
	// 通知ID
	NotificationId int64 `json:"notificationId"`
	// 通知类型
	NotificationType int `json:"notificationType"`
	// 通知标题
	NotificationTitle string `json:"notificationTitle"`
	// 通知内容
	NotificationContent string `json:"notificationContent"`
	// 通知时间
	NotificationTime time.Time `json:"notificationTime"`
	// 外部资源引用类型(1任务2驳回任务记录)
	ExternalResourceType int `json:"externalResourceType"`
	// 外部资源引用
	ExternalResource int64 `json:"externalResource"`
}

type NotificationRepository interface {
	Save(notification *Notification) (*Notification, error)
	Remove(notification *Notification) (*Notification, error)
	FindOne(queryOptions map[string]interface{}) (*Notification, error)
	Find(queryOptions map[string]interface{}) (int64, []*Notification, error)
}

func (notification *Notification) Identify() interface{} {
	if notification.NotificationId == 0 {
		return nil
	}
	return notification.NotificationId
}