276 lines
9.8 KiB
Go
276 lines
9.8 KiB
Go
// Code generated by BobGen psql v0.42.5. DO NOT EDIT.
|
|
// This file is meant to be re-generated in place and/or deleted at any time.
|
|
|
|
package factory
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
models "github.com/Gleipnir-Technology/nidus-sync/db/models"
|
|
"github.com/aarondl/opt/null"
|
|
"github.com/jaswdr/faker/v2"
|
|
)
|
|
|
|
type PublicreportSubscribeEmailMod interface {
|
|
Apply(context.Context, *PublicreportSubscribeEmailTemplate)
|
|
}
|
|
|
|
type PublicreportSubscribeEmailModFunc func(context.Context, *PublicreportSubscribeEmailTemplate)
|
|
|
|
func (f PublicreportSubscribeEmailModFunc) Apply(ctx context.Context, n *PublicreportSubscribeEmailTemplate) {
|
|
f(ctx, n)
|
|
}
|
|
|
|
type PublicreportSubscribeEmailModSlice []PublicreportSubscribeEmailMod
|
|
|
|
func (mods PublicreportSubscribeEmailModSlice) Apply(ctx context.Context, n *PublicreportSubscribeEmailTemplate) {
|
|
for _, f := range mods {
|
|
f.Apply(ctx, n)
|
|
}
|
|
}
|
|
|
|
// PublicreportSubscribeEmailTemplate is an object representing the database table.
|
|
// all columns are optional and should be set by mods
|
|
type PublicreportSubscribeEmailTemplate struct {
|
|
Created func() time.Time
|
|
Deleted func() null.Val[time.Time]
|
|
EmailAddress func() string
|
|
|
|
r publicreportSubscribeEmailR
|
|
f *Factory
|
|
|
|
alreadyPersisted bool
|
|
}
|
|
|
|
type publicreportSubscribeEmailR struct {
|
|
EmailAddressEmailContact *publicreportSubscribeEmailREmailAddressEmailContactR
|
|
}
|
|
|
|
type publicreportSubscribeEmailREmailAddressEmailContactR struct {
|
|
o *CommsEmailContactTemplate
|
|
}
|
|
|
|
// Apply mods to the PublicreportSubscribeEmailTemplate
|
|
func (o *PublicreportSubscribeEmailTemplate) Apply(ctx context.Context, mods ...PublicreportSubscribeEmailMod) {
|
|
for _, mod := range mods {
|
|
mod.Apply(ctx, o)
|
|
}
|
|
}
|
|
|
|
// setModelRels creates and sets the relationships on *models.PublicreportSubscribeEmail
|
|
// according to the relationships in the template. Nothing is inserted into the db
|
|
func (t PublicreportSubscribeEmailTemplate) setModelRels(o *models.PublicreportSubscribeEmail) {
|
|
if t.r.EmailAddressEmailContact != nil {
|
|
rel := t.r.EmailAddressEmailContact.o.Build()
|
|
rel.R.EmailAddressSubscribeEmails = append(rel.R.EmailAddressSubscribeEmails, o)
|
|
o.EmailAddress = rel.Address // h2
|
|
o.R.EmailAddressEmailContact = rel
|
|
}
|
|
}
|
|
|
|
// Build returns an *models.PublicreportSubscribeEmail
|
|
// Related objects are also created and placed in the .R field
|
|
// NOTE: Objects are not inserted into the database. Use PublicreportSubscribeEmailTemplate.Create
|
|
func (o PublicreportSubscribeEmailTemplate) Build() *models.PublicreportSubscribeEmail {
|
|
m := &models.PublicreportSubscribeEmail{}
|
|
|
|
if o.Created != nil {
|
|
m.Created = o.Created()
|
|
}
|
|
if o.Deleted != nil {
|
|
m.Deleted = o.Deleted()
|
|
}
|
|
if o.EmailAddress != nil {
|
|
m.EmailAddress = o.EmailAddress()
|
|
}
|
|
|
|
o.setModelRels(m)
|
|
|
|
return m
|
|
}
|
|
|
|
// BuildMany returns an models.PublicreportSubscribeEmailSlice
|
|
// Related objects are also created and placed in the .R field
|
|
// NOTE: Objects are not inserted into the database. Use PublicreportSubscribeEmailTemplate.CreateMany
|
|
func (o PublicreportSubscribeEmailTemplate) BuildMany(number int) models.PublicreportSubscribeEmailSlice {
|
|
m := make(models.PublicreportSubscribeEmailSlice, number)
|
|
|
|
for i := range m {
|
|
m[i] = o.Build()
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
// PublicreportSubscribeEmail has methods that act as mods for the PublicreportSubscribeEmailTemplate
|
|
var PublicreportSubscribeEmailMods publicreportSubscribeEmailMods
|
|
|
|
type publicreportSubscribeEmailMods struct{}
|
|
|
|
func (m publicreportSubscribeEmailMods) RandomizeAllColumns(f *faker.Faker) PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModSlice{
|
|
PublicreportSubscribeEmailMods.RandomCreated(f),
|
|
PublicreportSubscribeEmailMods.RandomDeleted(f),
|
|
PublicreportSubscribeEmailMods.RandomEmailAddress(f),
|
|
}
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m publicreportSubscribeEmailMods) Created(val time.Time) PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(_ context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
o.Created = func() time.Time { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m publicreportSubscribeEmailMods) CreatedFunc(f func() time.Time) PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(_ context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
o.Created = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m publicreportSubscribeEmailMods) UnsetCreated() PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(_ context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
o.Created = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m publicreportSubscribeEmailMods) RandomCreated(f *faker.Faker) PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(_ context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
o.Created = func() time.Time {
|
|
return random_time_Time(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m publicreportSubscribeEmailMods) Deleted(val null.Val[time.Time]) PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(_ context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
o.Deleted = func() null.Val[time.Time] { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m publicreportSubscribeEmailMods) DeletedFunc(f func() null.Val[time.Time]) PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(_ context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
o.Deleted = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m publicreportSubscribeEmailMods) UnsetDeleted() PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(_ context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
o.Deleted = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
// The generated value is sometimes null
|
|
func (m publicreportSubscribeEmailMods) RandomDeleted(f *faker.Faker) PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(_ context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
o.Deleted = func() null.Val[time.Time] {
|
|
if f == nil {
|
|
f = &defaultFaker
|
|
}
|
|
|
|
val := random_time_Time(f)
|
|
return null.From(val)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
// The generated value is never null
|
|
func (m publicreportSubscribeEmailMods) RandomDeletedNotNull(f *faker.Faker) PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(_ context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
o.Deleted = func() null.Val[time.Time] {
|
|
if f == nil {
|
|
f = &defaultFaker
|
|
}
|
|
|
|
val := random_time_Time(f)
|
|
return null.From(val)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m publicreportSubscribeEmailMods) EmailAddress(val string) PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(_ context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
o.EmailAddress = func() string { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m publicreportSubscribeEmailMods) EmailAddressFunc(f func() string) PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(_ context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
o.EmailAddress = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m publicreportSubscribeEmailMods) UnsetEmailAddress() PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(_ context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
o.EmailAddress = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m publicreportSubscribeEmailMods) RandomEmailAddress(f *faker.Faker) PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(_ context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
o.EmailAddress = func() string {
|
|
return random_string(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m publicreportSubscribeEmailMods) WithParentsCascading() PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(ctx context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
if isDone, _ := publicreportSubscribeEmailWithParentsCascadingCtx.Value(ctx); isDone {
|
|
return
|
|
}
|
|
ctx = publicreportSubscribeEmailWithParentsCascadingCtx.WithValue(ctx, true)
|
|
{
|
|
|
|
related := o.f.NewCommsEmailContactWithContext(ctx, CommsEmailContactMods.WithParentsCascading())
|
|
m.WithEmailAddressEmailContact(related).Apply(ctx, o)
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m publicreportSubscribeEmailMods) WithEmailAddressEmailContact(rel *CommsEmailContactTemplate) PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(ctx context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
o.r.EmailAddressEmailContact = &publicreportSubscribeEmailREmailAddressEmailContactR{
|
|
o: rel,
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m publicreportSubscribeEmailMods) WithNewEmailAddressEmailContact(mods ...CommsEmailContactMod) PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(ctx context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
related := o.f.NewCommsEmailContactWithContext(ctx, mods...)
|
|
|
|
m.WithEmailAddressEmailContact(related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m publicreportSubscribeEmailMods) WithExistingEmailAddressEmailContact(em *models.CommsEmailContact) PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(ctx context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
o.r.EmailAddressEmailContact = &publicreportSubscribeEmailREmailAddressEmailContactR{
|
|
o: o.f.FromExistingCommsEmailContact(em),
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m publicreportSubscribeEmailMods) WithoutEmailAddressEmailContact() PublicreportSubscribeEmailMod {
|
|
return PublicreportSubscribeEmailModFunc(func(ctx context.Context, o *PublicreportSubscribeEmailTemplate) {
|
|
o.r.EmailAddressEmailContact = nil
|
|
})
|
|
}
|