Files
quyun-v2/backend/app/jobs/notification_job.go

29 lines
574 B
Go

package jobs
import (
"context"
"quyun/v2/app/jobs/args"
"quyun/v2/database/models"
"github.com/riverqueue/river"
)
// @provider(job)
type NotificationWorker struct {
river.WorkerDefaults[args.NotificationArgs]
}
func (j *NotificationWorker) Work(ctx context.Context, job *river.Job[args.NotificationArgs]) error {
arg := job.Args
n := &models.Notification{
TenantID: arg.TenantID,
UserID: arg.UserID,
Type: arg.Type,
Title: arg.Title,
Content: arg.Content,
IsRead: false,
}
return models.NotificationQuery.WithContext(ctx).Create(n)
}