2025-11-11 20:09:11 +00:00
|
|
|
// Code generated by BobGen psql v0.41.1. DO NOT EDIT.
|
|
|
|
|
// This file is meant to be re-generated in place and/or deleted at any time.
|
|
|
|
|
|
|
|
|
|
package factory
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"testing"
|
2025-11-11 22:53:48 +00:00
|
|
|
"time"
|
2025-11-11 20:09:11 +00:00
|
|
|
|
|
|
|
|
enums "github.com/Gleipnir-Technology/nidus-sync/enums"
|
|
|
|
|
models "github.com/Gleipnir-Technology/nidus-sync/models"
|
|
|
|
|
"github.com/aarondl/opt/omit"
|
|
|
|
|
"github.com/jaswdr/faker/v2"
|
|
|
|
|
"github.com/stephenafamo/bob"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type NotificationMod interface {
|
|
|
|
|
Apply(context.Context, *NotificationTemplate)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type NotificationModFunc func(context.Context, *NotificationTemplate)
|
|
|
|
|
|
|
|
|
|
func (f NotificationModFunc) Apply(ctx context.Context, n *NotificationTemplate) {
|
|
|
|
|
f(ctx, n)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type NotificationModSlice []NotificationMod
|
|
|
|
|
|
|
|
|
|
func (mods NotificationModSlice) Apply(ctx context.Context, n *NotificationTemplate) {
|
|
|
|
|
for _, f := range mods {
|
|
|
|
|
f.Apply(ctx, n)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NotificationTemplate is an object representing the database table.
|
|
|
|
|
// all columns are optional and should be set by mods
|
|
|
|
|
type NotificationTemplate struct {
|
|
|
|
|
ID func() int32
|
2025-11-11 22:53:48 +00:00
|
|
|
Created func() time.Time
|
|
|
|
|
Link func() string
|
|
|
|
|
Message func() string
|
|
|
|
|
Type func() enums.Notificationtype
|
|
|
|
|
UserID func() int32
|
2025-11-11 20:09:11 +00:00
|
|
|
|
|
|
|
|
r notificationR
|
|
|
|
|
f *Factory
|
|
|
|
|
|
|
|
|
|
alreadyPersisted bool
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type notificationR struct {
|
|
|
|
|
UserUser *notificationRUserUserR
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type notificationRUserUserR struct {
|
|
|
|
|
o *UserTemplate
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Apply mods to the NotificationTemplate
|
|
|
|
|
func (o *NotificationTemplate) Apply(ctx context.Context, mods ...NotificationMod) {
|
|
|
|
|
for _, mod := range mods {
|
|
|
|
|
mod.Apply(ctx, o)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// setModelRels creates and sets the relationships on *models.Notification
|
|
|
|
|
// according to the relationships in the template. Nothing is inserted into the db
|
|
|
|
|
func (t NotificationTemplate) setModelRels(o *models.Notification) {
|
|
|
|
|
if t.r.UserUser != nil {
|
|
|
|
|
rel := t.r.UserUser.o.Build()
|
|
|
|
|
rel.R.UserNotifications = append(rel.R.UserNotifications, o)
|
2025-11-11 22:53:48 +00:00
|
|
|
o.UserID = rel.ID // h2
|
2025-11-11 20:09:11 +00:00
|
|
|
o.R.UserUser = rel
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// BuildSetter returns an *models.NotificationSetter
|
|
|
|
|
// this does nothing with the relationship templates
|
|
|
|
|
func (o NotificationTemplate) BuildSetter() *models.NotificationSetter {
|
|
|
|
|
m := &models.NotificationSetter{}
|
|
|
|
|
|
|
|
|
|
if o.ID != nil {
|
|
|
|
|
val := o.ID()
|
|
|
|
|
m.ID = omit.From(val)
|
|
|
|
|
}
|
2025-11-11 22:53:48 +00:00
|
|
|
if o.Created != nil {
|
|
|
|
|
val := o.Created()
|
|
|
|
|
m.Created = omit.From(val)
|
2025-11-11 20:09:11 +00:00
|
|
|
}
|
|
|
|
|
if o.Link != nil {
|
|
|
|
|
val := o.Link()
|
2025-11-11 22:53:48 +00:00
|
|
|
m.Link = omit.From(val)
|
|
|
|
|
}
|
|
|
|
|
if o.Message != nil {
|
|
|
|
|
val := o.Message()
|
|
|
|
|
m.Message = omit.From(val)
|
2025-11-11 20:09:11 +00:00
|
|
|
}
|
|
|
|
|
if o.Type != nil {
|
|
|
|
|
val := o.Type()
|
2025-11-11 22:53:48 +00:00
|
|
|
m.Type = omit.From(val)
|
|
|
|
|
}
|
|
|
|
|
if o.UserID != nil {
|
|
|
|
|
val := o.UserID()
|
|
|
|
|
m.UserID = omit.From(val)
|
2025-11-11 20:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return m
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// BuildManySetter returns an []*models.NotificationSetter
|
|
|
|
|
// this does nothing with the relationship templates
|
|
|
|
|
func (o NotificationTemplate) BuildManySetter(number int) []*models.NotificationSetter {
|
|
|
|
|
m := make([]*models.NotificationSetter, number)
|
|
|
|
|
|
|
|
|
|
for i := range m {
|
|
|
|
|
m[i] = o.BuildSetter()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return m
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build returns an *models.Notification
|
|
|
|
|
// Related objects are also created and placed in the .R field
|
|
|
|
|
// NOTE: Objects are not inserted into the database. Use NotificationTemplate.Create
|
|
|
|
|
func (o NotificationTemplate) Build() *models.Notification {
|
|
|
|
|
m := &models.Notification{}
|
|
|
|
|
|
|
|
|
|
if o.ID != nil {
|
|
|
|
|
m.ID = o.ID()
|
|
|
|
|
}
|
2025-11-11 22:53:48 +00:00
|
|
|
if o.Created != nil {
|
|
|
|
|
m.Created = o.Created()
|
2025-11-11 20:09:11 +00:00
|
|
|
}
|
|
|
|
|
if o.Link != nil {
|
|
|
|
|
m.Link = o.Link()
|
|
|
|
|
}
|
2025-11-11 22:53:48 +00:00
|
|
|
if o.Message != nil {
|
|
|
|
|
m.Message = o.Message()
|
|
|
|
|
}
|
2025-11-11 20:09:11 +00:00
|
|
|
if o.Type != nil {
|
|
|
|
|
m.Type = o.Type()
|
|
|
|
|
}
|
2025-11-11 22:53:48 +00:00
|
|
|
if o.UserID != nil {
|
|
|
|
|
m.UserID = o.UserID()
|
|
|
|
|
}
|
2025-11-11 20:09:11 +00:00
|
|
|
|
|
|
|
|
o.setModelRels(m)
|
|
|
|
|
|
|
|
|
|
return m
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// BuildMany returns an models.NotificationSlice
|
|
|
|
|
// Related objects are also created and placed in the .R field
|
|
|
|
|
// NOTE: Objects are not inserted into the database. Use NotificationTemplate.CreateMany
|
|
|
|
|
func (o NotificationTemplate) BuildMany(number int) models.NotificationSlice {
|
|
|
|
|
m := make(models.NotificationSlice, number)
|
|
|
|
|
|
|
|
|
|
for i := range m {
|
|
|
|
|
m[i] = o.Build()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return m
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ensureCreatableNotification(m *models.NotificationSetter) {
|
2025-11-11 22:53:48 +00:00
|
|
|
if !(m.Created.IsValue()) {
|
|
|
|
|
val := random_time_Time(nil)
|
|
|
|
|
m.Created = omit.From(val)
|
|
|
|
|
}
|
|
|
|
|
if !(m.Link.IsValue()) {
|
|
|
|
|
val := random_string(nil)
|
|
|
|
|
m.Link = omit.From(val)
|
|
|
|
|
}
|
|
|
|
|
if !(m.Message.IsValue()) {
|
|
|
|
|
val := random_string(nil)
|
|
|
|
|
m.Message = omit.From(val)
|
|
|
|
|
}
|
|
|
|
|
if !(m.Type.IsValue()) {
|
|
|
|
|
val := random_enums_Notificationtype(nil)
|
|
|
|
|
m.Type = omit.From(val)
|
|
|
|
|
}
|
|
|
|
|
if !(m.UserID.IsValue()) {
|
|
|
|
|
val := random_int32(nil)
|
|
|
|
|
m.UserID = omit.From(val)
|
|
|
|
|
}
|
2025-11-11 20:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// insertOptRels creates and inserts any optional the relationships on *models.Notification
|
|
|
|
|
// according to the relationships in the template.
|
|
|
|
|
// any required relationship should have already exist on the model
|
|
|
|
|
func (o *NotificationTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.Notification) error {
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create builds a notification and inserts it into the database
|
|
|
|
|
// Relations objects are also inserted and placed in the .R field
|
|
|
|
|
func (o *NotificationTemplate) Create(ctx context.Context, exec bob.Executor) (*models.Notification, error) {
|
|
|
|
|
var err error
|
|
|
|
|
opt := o.BuildSetter()
|
|
|
|
|
ensureCreatableNotification(opt)
|
|
|
|
|
|
2025-11-11 22:53:48 +00:00
|
|
|
if o.r.UserUser == nil {
|
|
|
|
|
NotificationMods.WithNewUserUser().Apply(ctx, o)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var rel0 *models.User
|
|
|
|
|
|
|
|
|
|
if o.r.UserUser.o.alreadyPersisted {
|
|
|
|
|
rel0 = o.r.UserUser.o.Build()
|
|
|
|
|
} else {
|
|
|
|
|
rel0, err = o.r.UserUser.o.Create(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
opt.UserID = omit.From(rel0.ID)
|
|
|
|
|
|
2025-11-11 20:09:11 +00:00
|
|
|
m, err := models.Notifications.Insert(opt).One(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-11 22:53:48 +00:00
|
|
|
m.R.UserUser = rel0
|
|
|
|
|
|
2025-11-11 20:09:11 +00:00
|
|
|
if err := o.insertOptRels(ctx, exec, m); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return m, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MustCreate builds a notification and inserts it into the database
|
|
|
|
|
// Relations objects are also inserted and placed in the .R field
|
|
|
|
|
// panics if an error occurs
|
|
|
|
|
func (o *NotificationTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.Notification {
|
|
|
|
|
m, err := o.Create(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
return m
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateOrFail builds a notification and inserts it into the database
|
|
|
|
|
// Relations objects are also inserted and placed in the .R field
|
|
|
|
|
// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
|
|
|
|
|
func (o *NotificationTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.Notification {
|
|
|
|
|
tb.Helper()
|
|
|
|
|
m, err := o.Create(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
tb.Fatal(err)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return m
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateMany builds multiple notifications and inserts them into the database
|
|
|
|
|
// Relations objects are also inserted and placed in the .R field
|
|
|
|
|
func (o NotificationTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.NotificationSlice, error) {
|
|
|
|
|
var err error
|
|
|
|
|
m := make(models.NotificationSlice, number)
|
|
|
|
|
|
|
|
|
|
for i := range m {
|
|
|
|
|
m[i], err = o.Create(ctx, exec)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return m, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MustCreateMany builds multiple notifications and inserts them into the database
|
|
|
|
|
// Relations objects are also inserted and placed in the .R field
|
|
|
|
|
// panics if an error occurs
|
|
|
|
|
func (o NotificationTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.NotificationSlice {
|
|
|
|
|
m, err := o.CreateMany(ctx, exec, number)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
return m
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateManyOrFail builds multiple notifications and inserts them into the database
|
|
|
|
|
// Relations objects are also inserted and placed in the .R field
|
|
|
|
|
// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
|
|
|
|
|
func (o NotificationTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.NotificationSlice {
|
|
|
|
|
tb.Helper()
|
|
|
|
|
m, err := o.CreateMany(ctx, exec, number)
|
|
|
|
|
if err != nil {
|
|
|
|
|
tb.Fatal(err)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return m
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Notification has methods that act as mods for the NotificationTemplate
|
|
|
|
|
var NotificationMods notificationMods
|
|
|
|
|
|
|
|
|
|
type notificationMods struct{}
|
|
|
|
|
|
|
|
|
|
func (m notificationMods) RandomizeAllColumns(f *faker.Faker) NotificationMod {
|
|
|
|
|
return NotificationModSlice{
|
|
|
|
|
NotificationMods.RandomID(f),
|
2025-11-11 22:53:48 +00:00
|
|
|
NotificationMods.RandomCreated(f),
|
2025-11-11 20:09:11 +00:00
|
|
|
NotificationMods.RandomLink(f),
|
2025-11-11 22:53:48 +00:00
|
|
|
NotificationMods.RandomMessage(f),
|
2025-11-11 20:09:11 +00:00
|
|
|
NotificationMods.RandomType(f),
|
2025-11-11 22:53:48 +00:00
|
|
|
NotificationMods.RandomUserID(f),
|
2025-11-11 20:09:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set the model columns to this value
|
|
|
|
|
func (m notificationMods) ID(val int32) NotificationMod {
|
|
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
|
|
|
|
o.ID = func() int32 { return val }
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set the Column from the function
|
|
|
|
|
func (m notificationMods) IDFunc(f func() int32) NotificationMod {
|
|
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
|
|
|
|
o.ID = f
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clear any values for the column
|
|
|
|
|
func (m notificationMods) UnsetID() NotificationMod {
|
|
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
|
|
|
|
o.ID = nil
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Generates a random value for the column using the given faker
|
|
|
|
|
// if faker is nil, a default faker is used
|
|
|
|
|
func (m notificationMods) RandomID(f *faker.Faker) NotificationMod {
|
|
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
|
|
|
|
o.ID = func() int32 {
|
|
|
|
|
return random_int32(f)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set the model columns to this value
|
2025-11-11 22:53:48 +00:00
|
|
|
func (m notificationMods) Created(val time.Time) NotificationMod {
|
2025-11-11 20:09:11 +00:00
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
2025-11-11 22:53:48 +00:00
|
|
|
o.Created = func() time.Time { return val }
|
2025-11-11 20:09:11 +00:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set the Column from the function
|
2025-11-11 22:53:48 +00:00
|
|
|
func (m notificationMods) CreatedFunc(f func() time.Time) NotificationMod {
|
2025-11-11 20:09:11 +00:00
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
2025-11-11 22:53:48 +00:00
|
|
|
o.Created = f
|
2025-11-11 20:09:11 +00:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clear any values for the column
|
2025-11-11 22:53:48 +00:00
|
|
|
func (m notificationMods) UnsetCreated() NotificationMod {
|
2025-11-11 20:09:11 +00:00
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
2025-11-11 22:53:48 +00:00
|
|
|
o.Created = nil
|
2025-11-11 20:09:11 +00:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Generates a random value for the column using the given faker
|
|
|
|
|
// if faker is nil, a default faker is used
|
2025-11-11 22:53:48 +00:00
|
|
|
func (m notificationMods) RandomCreated(f *faker.Faker) NotificationMod {
|
2025-11-11 20:09:11 +00:00
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
2025-11-11 22:53:48 +00:00
|
|
|
o.Created = func() time.Time {
|
|
|
|
|
return random_time_Time(f)
|
2025-11-11 20:09:11 +00:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set the model columns to this value
|
2025-11-11 22:53:48 +00:00
|
|
|
func (m notificationMods) Link(val string) NotificationMod {
|
2025-11-11 20:09:11 +00:00
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
2025-11-11 22:53:48 +00:00
|
|
|
o.Link = func() string { return val }
|
2025-11-11 20:09:11 +00:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set the Column from the function
|
2025-11-11 22:53:48 +00:00
|
|
|
func (m notificationMods) LinkFunc(f func() string) NotificationMod {
|
2025-11-11 20:09:11 +00:00
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
2025-11-11 22:53:48 +00:00
|
|
|
o.Link = f
|
2025-11-11 20:09:11 +00:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clear any values for the column
|
2025-11-11 22:53:48 +00:00
|
|
|
func (m notificationMods) UnsetLink() NotificationMod {
|
2025-11-11 20:09:11 +00:00
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
2025-11-11 22:53:48 +00:00
|
|
|
o.Link = nil
|
2025-11-11 20:09:11 +00:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Generates a random value for the column using the given faker
|
|
|
|
|
// if faker is nil, a default faker is used
|
2025-11-11 22:53:48 +00:00
|
|
|
func (m notificationMods) RandomLink(f *faker.Faker) NotificationMod {
|
2025-11-11 20:09:11 +00:00
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
2025-11-11 22:53:48 +00:00
|
|
|
o.Link = func() string {
|
|
|
|
|
return random_string(f)
|
2025-11-11 20:09:11 +00:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set the model columns to this value
|
2025-11-11 22:53:48 +00:00
|
|
|
func (m notificationMods) Message(val string) NotificationMod {
|
2025-11-11 20:09:11 +00:00
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
2025-11-11 22:53:48 +00:00
|
|
|
o.Message = func() string { return val }
|
2025-11-11 20:09:11 +00:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set the Column from the function
|
2025-11-11 22:53:48 +00:00
|
|
|
func (m notificationMods) MessageFunc(f func() string) NotificationMod {
|
2025-11-11 20:09:11 +00:00
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
2025-11-11 22:53:48 +00:00
|
|
|
o.Message = f
|
2025-11-11 20:09:11 +00:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clear any values for the column
|
2025-11-11 22:53:48 +00:00
|
|
|
func (m notificationMods) UnsetMessage() NotificationMod {
|
2025-11-11 20:09:11 +00:00
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
2025-11-11 22:53:48 +00:00
|
|
|
o.Message = nil
|
2025-11-11 20:09:11 +00:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Generates a random value for the column using the given faker
|
|
|
|
|
// if faker is nil, a default faker is used
|
2025-11-11 22:53:48 +00:00
|
|
|
func (m notificationMods) RandomMessage(f *faker.Faker) NotificationMod {
|
2025-11-11 20:09:11 +00:00
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
2025-11-11 22:53:48 +00:00
|
|
|
o.Message = func() string {
|
|
|
|
|
return random_string(f)
|
2025-11-11 20:09:11 +00:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set the model columns to this value
|
2025-11-11 22:53:48 +00:00
|
|
|
func (m notificationMods) Type(val enums.Notificationtype) NotificationMod {
|
2025-11-11 20:09:11 +00:00
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
2025-11-11 22:53:48 +00:00
|
|
|
o.Type = func() enums.Notificationtype { return val }
|
2025-11-11 20:09:11 +00:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set the Column from the function
|
2025-11-11 22:53:48 +00:00
|
|
|
func (m notificationMods) TypeFunc(f func() enums.Notificationtype) NotificationMod {
|
2025-11-11 20:09:11 +00:00
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
|
|
|
|
o.Type = f
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clear any values for the column
|
|
|
|
|
func (m notificationMods) UnsetType() NotificationMod {
|
|
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
|
|
|
|
o.Type = nil
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Generates a random value for the column using the given faker
|
|
|
|
|
// if faker is nil, a default faker is used
|
|
|
|
|
func (m notificationMods) RandomType(f *faker.Faker) NotificationMod {
|
|
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
2025-11-11 22:53:48 +00:00
|
|
|
o.Type = func() enums.Notificationtype {
|
|
|
|
|
return random_enums_Notificationtype(f)
|
2025-11-11 20:09:11 +00:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-11 22:53:48 +00:00
|
|
|
// Set the model columns to this value
|
|
|
|
|
func (m notificationMods) UserID(val int32) NotificationMod {
|
|
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
|
|
|
|
o.UserID = func() int32 { return val }
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set the Column from the function
|
|
|
|
|
func (m notificationMods) UserIDFunc(f func() int32) NotificationMod {
|
|
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
|
|
|
|
o.UserID = f
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clear any values for the column
|
|
|
|
|
func (m notificationMods) UnsetUserID() NotificationMod {
|
|
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
|
|
|
|
o.UserID = nil
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-11 20:09:11 +00:00
|
|
|
// Generates a random value for the column using the given faker
|
|
|
|
|
// if faker is nil, a default faker is used
|
2025-11-11 22:53:48 +00:00
|
|
|
func (m notificationMods) RandomUserID(f *faker.Faker) NotificationMod {
|
2025-11-11 20:09:11 +00:00
|
|
|
return NotificationModFunc(func(_ context.Context, o *NotificationTemplate) {
|
2025-11-11 22:53:48 +00:00
|
|
|
o.UserID = func() int32 {
|
|
|
|
|
return random_int32(f)
|
2025-11-11 20:09:11 +00:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m notificationMods) WithParentsCascading() NotificationMod {
|
|
|
|
|
return NotificationModFunc(func(ctx context.Context, o *NotificationTemplate) {
|
|
|
|
|
if isDone, _ := notificationWithParentsCascadingCtx.Value(ctx); isDone {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
ctx = notificationWithParentsCascadingCtx.WithValue(ctx, true)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
related := o.f.NewUserWithContext(ctx, UserMods.WithParentsCascading())
|
|
|
|
|
m.WithUserUser(related).Apply(ctx, o)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m notificationMods) WithUserUser(rel *UserTemplate) NotificationMod {
|
|
|
|
|
return NotificationModFunc(func(ctx context.Context, o *NotificationTemplate) {
|
|
|
|
|
o.r.UserUser = ¬ificationRUserUserR{
|
|
|
|
|
o: rel,
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m notificationMods) WithNewUserUser(mods ...UserMod) NotificationMod {
|
|
|
|
|
return NotificationModFunc(func(ctx context.Context, o *NotificationTemplate) {
|
|
|
|
|
related := o.f.NewUserWithContext(ctx, mods...)
|
|
|
|
|
|
|
|
|
|
m.WithUserUser(related).Apply(ctx, o)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m notificationMods) WithExistingUserUser(em *models.User) NotificationMod {
|
|
|
|
|
return NotificationModFunc(func(ctx context.Context, o *NotificationTemplate) {
|
|
|
|
|
o.r.UserUser = ¬ificationRUserUserR{
|
|
|
|
|
o: o.f.FromExistingUser(em),
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m notificationMods) WithoutUserUser() NotificationMod {
|
|
|
|
|
return NotificationModFunc(func(ctx context.Context, o *NotificationTemplate) {
|
|
|
|
|
o.r.UserUser = nil
|
|
|
|
|
})
|
|
|
|
|
}
|