I originally wasn't going to do passwords, but after struggling with webauthn I decided I'd just go for it. It simplifies the code a lot if I assert that I always have a password, displayname, etc.
179 lines
4.9 KiB
Go
179 lines
4.9 KiB
Go
// 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"
|
|
"time"
|
|
|
|
enums "github.com/Gleipnir-Technology/nidus-sync/enums"
|
|
models "github.com/Gleipnir-Technology/nidus-sync/models"
|
|
"github.com/aarondl/opt/null"
|
|
)
|
|
|
|
type Factory struct {
|
|
baseGooseDBVersionMods GooseDBVersionModSlice
|
|
baseOrganizationMods OrganizationModSlice
|
|
baseSessionMods SessionModSlice
|
|
baseUserMods UserModSlice
|
|
}
|
|
|
|
func New() *Factory {
|
|
return &Factory{}
|
|
}
|
|
|
|
func (f *Factory) NewGooseDBVersion(mods ...GooseDBVersionMod) *GooseDBVersionTemplate {
|
|
return f.NewGooseDBVersionWithContext(context.Background(), mods...)
|
|
}
|
|
|
|
func (f *Factory) NewGooseDBVersionWithContext(ctx context.Context, mods ...GooseDBVersionMod) *GooseDBVersionTemplate {
|
|
o := &GooseDBVersionTemplate{f: f}
|
|
|
|
if f != nil {
|
|
f.baseGooseDBVersionMods.Apply(ctx, o)
|
|
}
|
|
|
|
GooseDBVersionModSlice(mods).Apply(ctx, o)
|
|
|
|
return o
|
|
}
|
|
|
|
func (f *Factory) FromExistingGooseDBVersion(m *models.GooseDBVersion) *GooseDBVersionTemplate {
|
|
o := &GooseDBVersionTemplate{f: f, alreadyPersisted: true}
|
|
|
|
o.ID = func() int32 { return m.ID }
|
|
o.VersionID = func() int64 { return m.VersionID }
|
|
o.IsApplied = func() bool { return m.IsApplied }
|
|
o.Tstamp = func() time.Time { return m.Tstamp }
|
|
|
|
return o
|
|
}
|
|
|
|
func (f *Factory) NewOrganization(mods ...OrganizationMod) *OrganizationTemplate {
|
|
return f.NewOrganizationWithContext(context.Background(), mods...)
|
|
}
|
|
|
|
func (f *Factory) NewOrganizationWithContext(ctx context.Context, mods ...OrganizationMod) *OrganizationTemplate {
|
|
o := &OrganizationTemplate{f: f}
|
|
|
|
if f != nil {
|
|
f.baseOrganizationMods.Apply(ctx, o)
|
|
}
|
|
|
|
OrganizationModSlice(mods).Apply(ctx, o)
|
|
|
|
return o
|
|
}
|
|
|
|
func (f *Factory) FromExistingOrganization(m *models.Organization) *OrganizationTemplate {
|
|
o := &OrganizationTemplate{f: f, alreadyPersisted: true}
|
|
|
|
o.ID = func() int32 { return m.ID }
|
|
o.Name = func() null.Val[string] { return m.Name }
|
|
|
|
ctx := context.Background()
|
|
if len(m.R.User) > 0 {
|
|
OrganizationMods.AddExistingUser(m.R.User...).Apply(ctx, o)
|
|
}
|
|
|
|
return o
|
|
}
|
|
|
|
func (f *Factory) NewSession(mods ...SessionMod) *SessionTemplate {
|
|
return f.NewSessionWithContext(context.Background(), mods...)
|
|
}
|
|
|
|
func (f *Factory) NewSessionWithContext(ctx context.Context, mods ...SessionMod) *SessionTemplate {
|
|
o := &SessionTemplate{f: f}
|
|
|
|
if f != nil {
|
|
f.baseSessionMods.Apply(ctx, o)
|
|
}
|
|
|
|
SessionModSlice(mods).Apply(ctx, o)
|
|
|
|
return o
|
|
}
|
|
|
|
func (f *Factory) FromExistingSession(m *models.Session) *SessionTemplate {
|
|
o := &SessionTemplate{f: f, alreadyPersisted: true}
|
|
|
|
o.Token = func() string { return m.Token }
|
|
o.Data = func() []byte { return m.Data }
|
|
o.Expiry = func() time.Time { return m.Expiry }
|
|
|
|
return o
|
|
}
|
|
|
|
func (f *Factory) NewUser(mods ...UserMod) *UserTemplate {
|
|
return f.NewUserWithContext(context.Background(), mods...)
|
|
}
|
|
|
|
func (f *Factory) NewUserWithContext(ctx context.Context, mods ...UserMod) *UserTemplate {
|
|
o := &UserTemplate{f: f}
|
|
|
|
if f != nil {
|
|
f.baseUserMods.Apply(ctx, o)
|
|
}
|
|
|
|
UserModSlice(mods).Apply(ctx, o)
|
|
|
|
return o
|
|
}
|
|
|
|
func (f *Factory) FromExistingUser(m *models.User) *UserTemplate {
|
|
o := &UserTemplate{f: f, alreadyPersisted: true}
|
|
|
|
o.ID = func() int32 { return m.ID }
|
|
o.ArcgisAccessToken = func() null.Val[string] { return m.ArcgisAccessToken }
|
|
o.ArcgisLicense = func() null.Val[enums.Arcgislicensetype] { return m.ArcgisLicense }
|
|
o.ArcgisRefreshToken = func() null.Val[string] { return m.ArcgisRefreshToken }
|
|
o.ArcgisRefreshTokenExpires = func() null.Val[time.Time] { return m.ArcgisRefreshTokenExpires }
|
|
o.ArcgisRole = func() null.Val[string] { return m.ArcgisRole }
|
|
o.DisplayName = func() string { return m.DisplayName }
|
|
o.Email = func() null.Val[string] { return m.Email }
|
|
o.OrganizationID = func() null.Val[int32] { return m.OrganizationID }
|
|
o.Username = func() string { return m.Username }
|
|
o.PasswordHashType = func() enums.Hashtype { return m.PasswordHashType }
|
|
o.PasswordHash = func() string { return m.PasswordHash }
|
|
|
|
ctx := context.Background()
|
|
if m.R.Organization != nil {
|
|
UserMods.WithExistingOrganization(m.R.Organization).Apply(ctx, o)
|
|
}
|
|
|
|
return o
|
|
}
|
|
|
|
func (f *Factory) ClearBaseGooseDBVersionMods() {
|
|
f.baseGooseDBVersionMods = nil
|
|
}
|
|
|
|
func (f *Factory) AddBaseGooseDBVersionMod(mods ...GooseDBVersionMod) {
|
|
f.baseGooseDBVersionMods = append(f.baseGooseDBVersionMods, mods...)
|
|
}
|
|
|
|
func (f *Factory) ClearBaseOrganizationMods() {
|
|
f.baseOrganizationMods = nil
|
|
}
|
|
|
|
func (f *Factory) AddBaseOrganizationMod(mods ...OrganizationMod) {
|
|
f.baseOrganizationMods = append(f.baseOrganizationMods, mods...)
|
|
}
|
|
|
|
func (f *Factory) ClearBaseSessionMods() {
|
|
f.baseSessionMods = nil
|
|
}
|
|
|
|
func (f *Factory) AddBaseSessionMod(mods ...SessionMod) {
|
|
f.baseSessionMods = append(f.baseSessionMods, mods...)
|
|
}
|
|
|
|
func (f *Factory) ClearBaseUserMods() {
|
|
f.baseUserMods = nil
|
|
}
|
|
|
|
func (f *Factory) AddBaseUserMod(mods ...UserMod) {
|
|
f.baseUserMods = append(f.baseUserMods, mods...)
|
|
}
|