Save information about the organization and user from ArcGIS
This commit is contained in:
parent
07d3b3ea76
commit
a08cd87813
20 changed files with 786 additions and 93 deletions
|
|
@ -76,6 +76,8 @@ func (f *Factory) FromExistingOauthToken(m *models.OauthToken) *OauthTokenTempla
|
|||
o.RefreshToken = func() string { return m.RefreshToken }
|
||||
o.Username = func() string { return m.Username }
|
||||
o.UserID = func() int32 { return m.UserID }
|
||||
o.ArcgisID = func() null.Val[string] { return m.ArcgisID }
|
||||
o.ArcgisLicenseTypeID = func() null.Val[string] { return m.ArcgisLicenseTypeID }
|
||||
|
||||
ctx := context.Background()
|
||||
if m.R.UserUser != nil {
|
||||
|
|
@ -106,6 +108,8 @@ func (f *Factory) FromExistingOrganization(m *models.Organization) *Organization
|
|||
|
||||
o.ID = func() int32 { return m.ID }
|
||||
o.Name = func() null.Val[string] { return m.Name }
|
||||
o.ArcgisID = func() null.Val[string] { return m.ArcgisID }
|
||||
o.ArcgisName = func() null.Val[string] { return m.ArcgisName }
|
||||
|
||||
ctx := context.Background()
|
||||
if len(m.R.User) > 0 {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ import (
|
|||
"time"
|
||||
|
||||
models "github.com/Gleipnir-Technology/nidus-sync/models"
|
||||
"github.com/aarondl/opt/null"
|
||||
"github.com/aarondl/opt/omit"
|
||||
"github.com/aarondl/opt/omitnull"
|
||||
"github.com/jaswdr/faker/v2"
|
||||
"github.com/stephenafamo/bob"
|
||||
)
|
||||
|
|
@ -35,12 +37,14 @@ func (mods OauthTokenModSlice) Apply(ctx context.Context, n *OauthTokenTemplate)
|
|||
// OauthTokenTemplate is an object representing the database table.
|
||||
// all columns are optional and should be set by mods
|
||||
type OauthTokenTemplate struct {
|
||||
ID func() int32
|
||||
AccessToken func() string
|
||||
Expires func() time.Time
|
||||
RefreshToken func() string
|
||||
Username func() string
|
||||
UserID func() int32
|
||||
ID func() int32
|
||||
AccessToken func() string
|
||||
Expires func() time.Time
|
||||
RefreshToken func() string
|
||||
Username func() string
|
||||
UserID func() int32
|
||||
ArcgisID func() null.Val[string]
|
||||
ArcgisLicenseTypeID func() null.Val[string]
|
||||
|
||||
r oauthTokenR
|
||||
f *Factory
|
||||
|
|
@ -103,6 +107,14 @@ func (o OauthTokenTemplate) BuildSetter() *models.OauthTokenSetter {
|
|||
val := o.UserID()
|
||||
m.UserID = omit.From(val)
|
||||
}
|
||||
if o.ArcgisID != nil {
|
||||
val := o.ArcgisID()
|
||||
m.ArcgisID = omitnull.FromNull(val)
|
||||
}
|
||||
if o.ArcgisLicenseTypeID != nil {
|
||||
val := o.ArcgisLicenseTypeID()
|
||||
m.ArcgisLicenseTypeID = omitnull.FromNull(val)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
|
@ -143,6 +155,12 @@ func (o OauthTokenTemplate) Build() *models.OauthToken {
|
|||
if o.UserID != nil {
|
||||
m.UserID = o.UserID()
|
||||
}
|
||||
if o.ArcgisID != nil {
|
||||
m.ArcgisID = o.ArcgisID()
|
||||
}
|
||||
if o.ArcgisLicenseTypeID != nil {
|
||||
m.ArcgisLicenseTypeID = o.ArcgisLicenseTypeID()
|
||||
}
|
||||
|
||||
o.setModelRels(m)
|
||||
|
||||
|
|
@ -308,6 +326,8 @@ func (m oauthTokenMods) RandomizeAllColumns(f *faker.Faker) OauthTokenMod {
|
|||
OauthTokenMods.RandomRefreshToken(f),
|
||||
OauthTokenMods.RandomUsername(f),
|
||||
OauthTokenMods.RandomUserID(f),
|
||||
OauthTokenMods.RandomArcgisID(f),
|
||||
OauthTokenMods.RandomArcgisLicenseTypeID(f),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -497,6 +517,112 @@ func (m oauthTokenMods) RandomUserID(f *faker.Faker) OauthTokenMod {
|
|||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m oauthTokenMods) ArcgisID(val null.Val[string]) OauthTokenMod {
|
||||
return OauthTokenModFunc(func(_ context.Context, o *OauthTokenTemplate) {
|
||||
o.ArcgisID = func() null.Val[string] { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m oauthTokenMods) ArcgisIDFunc(f func() null.Val[string]) OauthTokenMod {
|
||||
return OauthTokenModFunc(func(_ context.Context, o *OauthTokenTemplate) {
|
||||
o.ArcgisID = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m oauthTokenMods) UnsetArcgisID() OauthTokenMod {
|
||||
return OauthTokenModFunc(func(_ context.Context, o *OauthTokenTemplate) {
|
||||
o.ArcgisID = 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 oauthTokenMods) RandomArcgisID(f *faker.Faker) OauthTokenMod {
|
||||
return OauthTokenModFunc(func(_ context.Context, o *OauthTokenTemplate) {
|
||||
o.ArcgisID = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(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 oauthTokenMods) RandomArcgisIDNotNull(f *faker.Faker) OauthTokenMod {
|
||||
return OauthTokenModFunc(func(_ context.Context, o *OauthTokenTemplate) {
|
||||
o.ArcgisID = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m oauthTokenMods) ArcgisLicenseTypeID(val null.Val[string]) OauthTokenMod {
|
||||
return OauthTokenModFunc(func(_ context.Context, o *OauthTokenTemplate) {
|
||||
o.ArcgisLicenseTypeID = func() null.Val[string] { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m oauthTokenMods) ArcgisLicenseTypeIDFunc(f func() null.Val[string]) OauthTokenMod {
|
||||
return OauthTokenModFunc(func(_ context.Context, o *OauthTokenTemplate) {
|
||||
o.ArcgisLicenseTypeID = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m oauthTokenMods) UnsetArcgisLicenseTypeID() OauthTokenMod {
|
||||
return OauthTokenModFunc(func(_ context.Context, o *OauthTokenTemplate) {
|
||||
o.ArcgisLicenseTypeID = 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 oauthTokenMods) RandomArcgisLicenseTypeID(f *faker.Faker) OauthTokenMod {
|
||||
return OauthTokenModFunc(func(_ context.Context, o *OauthTokenTemplate) {
|
||||
o.ArcgisLicenseTypeID = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(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 oauthTokenMods) RandomArcgisLicenseTypeIDNotNull(f *faker.Faker) OauthTokenMod {
|
||||
return OauthTokenModFunc(func(_ context.Context, o *OauthTokenTemplate) {
|
||||
o.ArcgisLicenseTypeID = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (m oauthTokenMods) WithParentsCascading() OauthTokenMod {
|
||||
return OauthTokenModFunc(func(ctx context.Context, o *OauthTokenTemplate) {
|
||||
if isDone, _ := oauthTokenWithParentsCascadingCtx.Value(ctx); isDone {
|
||||
|
|
|
|||
|
|
@ -36,8 +36,10 @@ func (mods OrganizationModSlice) Apply(ctx context.Context, n *OrganizationTempl
|
|||
// OrganizationTemplate is an object representing the database table.
|
||||
// all columns are optional and should be set by mods
|
||||
type OrganizationTemplate struct {
|
||||
ID func() int32
|
||||
Name func() null.Val[string]
|
||||
ID func() int32
|
||||
Name func() null.Val[string]
|
||||
ArcgisID func() null.Val[string]
|
||||
ArcgisName func() null.Val[string]
|
||||
|
||||
r organizationR
|
||||
f *Factory
|
||||
|
|
@ -91,6 +93,14 @@ func (o OrganizationTemplate) BuildSetter() *models.OrganizationSetter {
|
|||
val := o.Name()
|
||||
m.Name = omitnull.FromNull(val)
|
||||
}
|
||||
if o.ArcgisID != nil {
|
||||
val := o.ArcgisID()
|
||||
m.ArcgisID = omitnull.FromNull(val)
|
||||
}
|
||||
if o.ArcgisName != nil {
|
||||
val := o.ArcgisName()
|
||||
m.ArcgisName = omitnull.FromNull(val)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
|
@ -119,6 +129,12 @@ func (o OrganizationTemplate) Build() *models.Organization {
|
|||
if o.Name != nil {
|
||||
m.Name = o.Name()
|
||||
}
|
||||
if o.ArcgisID != nil {
|
||||
m.ArcgisID = o.ArcgisID()
|
||||
}
|
||||
if o.ArcgisName != nil {
|
||||
m.ArcgisName = o.ArcgisName()
|
||||
}
|
||||
|
||||
o.setModelRels(m)
|
||||
|
||||
|
|
@ -261,6 +277,8 @@ func (m organizationMods) RandomizeAllColumns(f *faker.Faker) OrganizationMod {
|
|||
return OrganizationModSlice{
|
||||
OrganizationMods.RandomID(f),
|
||||
OrganizationMods.RandomName(f),
|
||||
OrganizationMods.RandomArcgisID(f),
|
||||
OrganizationMods.RandomArcgisName(f),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -348,6 +366,112 @@ func (m organizationMods) RandomNameNotNull(f *faker.Faker) OrganizationMod {
|
|||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m organizationMods) ArcgisID(val null.Val[string]) OrganizationMod {
|
||||
return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
|
||||
o.ArcgisID = func() null.Val[string] { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m organizationMods) ArcgisIDFunc(f func() null.Val[string]) OrganizationMod {
|
||||
return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
|
||||
o.ArcgisID = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m organizationMods) UnsetArcgisID() OrganizationMod {
|
||||
return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
|
||||
o.ArcgisID = 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 organizationMods) RandomArcgisID(f *faker.Faker) OrganizationMod {
|
||||
return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
|
||||
o.ArcgisID = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(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 organizationMods) RandomArcgisIDNotNull(f *faker.Faker) OrganizationMod {
|
||||
return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
|
||||
o.ArcgisID = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m organizationMods) ArcgisName(val null.Val[string]) OrganizationMod {
|
||||
return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
|
||||
o.ArcgisName = func() null.Val[string] { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m organizationMods) ArcgisNameFunc(f func() null.Val[string]) OrganizationMod {
|
||||
return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
|
||||
o.ArcgisName = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m organizationMods) UnsetArcgisName() OrganizationMod {
|
||||
return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
|
||||
o.ArcgisName = 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 organizationMods) RandomArcgisName(f *faker.Faker) OrganizationMod {
|
||||
return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
|
||||
o.ArcgisName = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(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 organizationMods) RandomArcgisNameNotNull(f *faker.Faker) OrganizationMod {
|
||||
return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
|
||||
o.ArcgisName = func() null.Val[string] {
|
||||
if f == nil {
|
||||
f = &defaultFaker
|
||||
}
|
||||
|
||||
val := random_string(f)
|
||||
return null.From(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (m organizationMods) WithParentsCascading() OrganizationMod {
|
||||
return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) {
|
||||
if isDone, _ := organizationWithParentsCascadingCtx.Value(ctx); isDone {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue