notify

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Info = iota + 1
	Success
	Warning
	Error
)

Variables

This section is empty.

Functions

func NewNotify

func NewNotify[T primary.Key]() web.Constructor

Types

type Notification

type Notification[T primary.Key] struct {
	Message map[T]chan *Records[T]
	*NotifyMapper[T]
	// contains filtered or unexported fields
}

func (*Notification[T]) GetNotify

func (notify *Notification[T]) GetNotify(id T) chan *Records[T]

GetNotify 获取用户的消息通知通道

func (*Notification[T]) New

func (notify *Notification[T]) New(level int, id T, title, text string) *Records[T]

func (*Notification[T]) Publish

func (notify *Notification[T]) Publish(records *Records[T], user T, ids ...T)

Publish 发送消息给指定的 ids

type NotifyMapper

type NotifyMapper[T primary.Key] struct {
	AddRecords func(any) error

	FindUntreated func(any) ([]*Records[T], error)

	DelRecords func(any) error
}

type Records

type Records[T primary.Key] struct {
	Id         T      `column:"id"`
	PubId      T      `column:"pub_id"`   // 生产者
	SubId      T      `column:"sub_id"`   // 消费者
	Title      string `column:"title"`    // 消息标题
	MsgType    int    `column:"msg_type"` // 消息类型
	Text       string `column:"text"`     // 消息文本
	Template   string `column:"template"` // 消息模版
	Data       string `column:"data"`     // 模版上下文数据
	Status     int    `column:"status"`   // 消息状态
	Del        int    `column:"del"`
	CreateTime string `column:"create_time"` // 消息生成时间
	HandleTime string `column:"handle_time"` // 消息处理时间
}

func NewRecords

func NewRecords[T primary.Key](level int, id T, title, text string) *Records[T]

func (*Records[T]) String

func (r *Records[T]) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL