add a new model - UserFilterOr
This commit is contained in:
parent
419c1f7aaf
commit
300709f527
|
@ -1135,6 +1135,14 @@ input UpdateManyUsersInput {
|
|||
activated: Boolean
|
||||
}
|
||||
|
||||
input UserFilterOr {
|
||||
displayNameIEQ: String
|
||||
displayNameMATCH: String
|
||||
|
||||
emailIEQ: String
|
||||
emailMATCH: String
|
||||
}
|
||||
|
||||
input UserFilter {
|
||||
id: [ID!]
|
||||
idNEQ: [ID!]
|
||||
|
@ -1159,6 +1167,8 @@ input UserFilter {
|
|||
createdAtGTE: Time
|
||||
createdAtLT: Time
|
||||
createdAtLTE: Time
|
||||
|
||||
or: UserFilterOr
|
||||
}
|
||||
|
||||
type UserWithToken {
|
||||
|
@ -6879,6 +6889,58 @@ func (ec *executionContext) unmarshalInputUserFilter(ctx context.Context, obj in
|
|||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
case "or":
|
||||
var err error
|
||||
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or"))
|
||||
it.Or, err = ec.unmarshalOUserFilterOr2ᚖgithubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐUserFilterOr(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return it, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalInputUserFilterOr(ctx context.Context, obj interface{}) (models.UserFilterOr, error) {
|
||||
var it models.UserFilterOr
|
||||
var asMap = obj.(map[string]interface{})
|
||||
|
||||
for k, v := range asMap {
|
||||
switch k {
|
||||
case "displayNameIEQ":
|
||||
var err error
|
||||
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("displayNameIEQ"))
|
||||
it.DisplayNameIEQ, err = ec.unmarshalOString2string(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
case "displayNameMATCH":
|
||||
var err error
|
||||
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("displayNameMATCH"))
|
||||
it.DisplayNameMATCH, err = ec.unmarshalOString2string(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
case "emailIEQ":
|
||||
var err error
|
||||
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("emailIEQ"))
|
||||
it.EmailIEQ, err = ec.unmarshalOString2string(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
case "emailMATCH":
|
||||
var err error
|
||||
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("emailMATCH"))
|
||||
it.EmailMATCH, err = ec.unmarshalOString2string(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8785,6 +8847,14 @@ func (ec *executionContext) unmarshalOUserFilter2ᚖgithubᚗcomᚋzdamᚑegzami
|
|||
return &res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalOUserFilterOr2ᚖgithubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐUserFilterOr(ctx context.Context, v interface{}) (*models.UserFilterOr, error) {
|
||||
if v == nil {
|
||||
return nil, nil
|
||||
}
|
||||
res, err := ec.unmarshalInputUserFilterOr(ctx, v)
|
||||
return &res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalOUserWithToken2ᚖgithubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋgraphqlᚋgeneratedᚐUserWithToken(ctx context.Context, sel ast.SelectionSet, v *UserWithToken) graphql.Marshaler {
|
||||
if v == nil {
|
||||
return graphql.Null
|
||||
|
|
|
@ -26,6 +26,9 @@ models:
|
|||
UserFilter:
|
||||
model:
|
||||
- github.com/zdam-egzamin-zawodowy/backend/internal/models.UserFilter
|
||||
UserFilterOr:
|
||||
model:
|
||||
- github.com/zdam-egzamin-zawodowy/backend/internal/models.UserFilterOr
|
||||
UserInput:
|
||||
model:
|
||||
- github.com/zdam-egzamin-zawodowy/backend/internal/models.UserInput
|
||||
|
|
|
@ -30,6 +30,14 @@ input UpdateManyUsersInput {
|
|||
activated: Boolean
|
||||
}
|
||||
|
||||
input UserFilterOr {
|
||||
displayNameIEQ: String
|
||||
displayNameMATCH: String
|
||||
|
||||
emailIEQ: String
|
||||
emailMATCH: String
|
||||
}
|
||||
|
||||
input UserFilter {
|
||||
id: [ID!]
|
||||
idNEQ: [ID!]
|
||||
|
@ -54,6 +62,8 @@ input UserFilter {
|
|||
createdAtGTE: Time
|
||||
createdAtLT: Time
|
||||
createdAtLTE: Time
|
||||
|
||||
or: UserFilterOr
|
||||
}
|
||||
|
||||
type UserWithToken {
|
||||
|
|
|
@ -131,6 +131,45 @@ func (input *UserInput) ApplyUpdate(q *orm.Query) (*orm.Query, error) {
|
|||
return q, nil
|
||||
}
|
||||
|
||||
type UserFilterOr struct {
|
||||
DisplayNameIEQ string `json:"displayNameIEQ" xml:"displayNameIEQ" gqlgen:"displayNameIEQ"`
|
||||
DisplayNameMATCH string `json:"displayNameMATCH" xml:"displayNameMATCH" gqlgen:"displayNameMATCH"`
|
||||
|
||||
EmailIEQ string `json:"emailIEQ" xml:"emailIEQ" gqlgen:"emailIEQ"`
|
||||
EmailMATCH string `json:"emailMATCH" xml:"emailMATCH" gqlgen:"emailMATCH"`
|
||||
}
|
||||
|
||||
func (f *UserFilterOr) WhereWithAlias(q *orm.Query, alias string) *orm.Query {
|
||||
if f == nil {
|
||||
return q
|
||||
}
|
||||
|
||||
q = q.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
|
||||
if !isZero(f.DisplayNameMATCH) {
|
||||
q = q.Where(
|
||||
sqlutils.BuildConditionMatch(sqlutils.AddAliasToColumnName("display_name", alias)),
|
||||
f.DisplayNameMATCH,
|
||||
)
|
||||
}
|
||||
if !isZero(f.DisplayNameIEQ) {
|
||||
q = q.Where(
|
||||
sqlutils.BuildConditionIEQ(sqlutils.AddAliasToColumnName("display_name", alias)),
|
||||
f.DisplayNameIEQ,
|
||||
)
|
||||
}
|
||||
|
||||
if !isZero(f.EmailMATCH) {
|
||||
q = q.Where(sqlutils.BuildConditionMatch(sqlutils.AddAliasToColumnName("email", alias)), f.EmailMATCH)
|
||||
}
|
||||
if !isZero(f.EmailIEQ) {
|
||||
q = q.Where(sqlutils.BuildConditionIEQ(sqlutils.AddAliasToColumnName("email", alias)), f.EmailIEQ)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
})
|
||||
return q
|
||||
}
|
||||
|
||||
type UserFilter struct {
|
||||
ID []int `json:"id" xml:"id" gqlgen:"id"`
|
||||
IDNEQ []int `json:"idNEQ" xml:"idNEQ" gqlgen:"idNEQ"`
|
||||
|
@ -155,6 +194,8 @@ type UserFilter struct {
|
|||
CreatedAtGTE time.Time `json:"createdAtGTE" xml:"createdAtGTE" gqlgen:"createdAtGTE"`
|
||||
CreatedAtLT time.Time `json:"createdAtLT" xml:"createdAtLT" gqlgen:"createdAtLT"`
|
||||
CreatedAtLTE time.Time `json:"createdAtLTE" xml:"createdAtLTE" gqlgen:"createdAtLTE"`
|
||||
|
||||
Or *UserFilterOr
|
||||
}
|
||||
|
||||
func (f *UserFilter) WhereWithAlias(q *orm.Query, alias string) (*orm.Query, error) {
|
||||
|
@ -215,6 +256,10 @@ func (f *UserFilter) WhereWithAlias(q *orm.Query, alias string) (*orm.Query, err
|
|||
q = q.Where(sqlutils.BuildConditionLTE(sqlutils.AddAliasToColumnName("created_at", alias)), f.CreatedAtLTE)
|
||||
}
|
||||
|
||||
if f.Or != nil {
|
||||
q = f.Or.WhereWithAlias(q, alias)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue