123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "w303a/server/app/gate/internal/data/ent/predicate"
- "w303a/server/app/gate/internal/data/ent/pushregistration"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // PushRegistrationUpdate is the builder for updating PushRegistration entities.
- type PushRegistrationUpdate struct {
- config
- hooks []Hook
- mutation *PushRegistrationMutation
- }
- // Where appends a list predicates to the PushRegistrationUpdate builder.
- func (pru *PushRegistrationUpdate) Where(ps ...predicate.PushRegistration) *PushRegistrationUpdate {
- pru.mutation.Where(ps...)
- return pru
- }
- // SetRegID sets the "reg_id" field.
- func (pru *PushRegistrationUpdate) SetRegID(s string) *PushRegistrationUpdate {
- pru.mutation.SetRegID(s)
- return pru
- }
- // SetNillableRegID sets the "reg_id" field if the given value is not nil.
- func (pru *PushRegistrationUpdate) SetNillableRegID(s *string) *PushRegistrationUpdate {
- if s != nil {
- pru.SetRegID(*s)
- }
- return pru
- }
- // SetRegistrantPlatformType sets the "registrant_platform_type" field.
- func (pru *PushRegistrationUpdate) SetRegistrantPlatformType(i int8) *PushRegistrationUpdate {
- pru.mutation.ResetRegistrantPlatformType()
- pru.mutation.SetRegistrantPlatformType(i)
- return pru
- }
- // SetNillableRegistrantPlatformType sets the "registrant_platform_type" field if the given value is not nil.
- func (pru *PushRegistrationUpdate) SetNillableRegistrantPlatformType(i *int8) *PushRegistrationUpdate {
- if i != nil {
- pru.SetRegistrantPlatformType(*i)
- }
- return pru
- }
- // AddRegistrantPlatformType adds i to the "registrant_platform_type" field.
- func (pru *PushRegistrationUpdate) AddRegistrantPlatformType(i int8) *PushRegistrationUpdate {
- pru.mutation.AddRegistrantPlatformType(i)
- return pru
- }
- // SetLanguage sets the "language" field.
- func (pru *PushRegistrationUpdate) SetLanguage(s string) *PushRegistrationUpdate {
- pru.mutation.SetLanguage(s)
- return pru
- }
- // SetNillableLanguage sets the "language" field if the given value is not nil.
- func (pru *PushRegistrationUpdate) SetNillableLanguage(s *string) *PushRegistrationUpdate {
- if s != nil {
- pru.SetLanguage(*s)
- }
- return pru
- }
- // SetDeviceModel sets the "device_model" field.
- func (pru *PushRegistrationUpdate) SetDeviceModel(s string) *PushRegistrationUpdate {
- pru.mutation.SetDeviceModel(s)
- return pru
- }
- // SetNillableDeviceModel sets the "device_model" field if the given value is not nil.
- func (pru *PushRegistrationUpdate) SetNillableDeviceModel(s *string) *PushRegistrationUpdate {
- if s != nil {
- pru.SetDeviceModel(*s)
- }
- return pru
- }
- // SetDeviceManufacturer sets the "device_manufacturer" field.
- func (pru *PushRegistrationUpdate) SetDeviceManufacturer(s string) *PushRegistrationUpdate {
- pru.mutation.SetDeviceManufacturer(s)
- return pru
- }
- // SetNillableDeviceManufacturer sets the "device_manufacturer" field if the given value is not nil.
- func (pru *PushRegistrationUpdate) SetNillableDeviceManufacturer(s *string) *PushRegistrationUpdate {
- if s != nil {
- pru.SetDeviceManufacturer(*s)
- }
- return pru
- }
- // SetDeviceSystemVersion sets the "device_system_version" field.
- func (pru *PushRegistrationUpdate) SetDeviceSystemVersion(s string) *PushRegistrationUpdate {
- pru.mutation.SetDeviceSystemVersion(s)
- return pru
- }
- // SetNillableDeviceSystemVersion sets the "device_system_version" field if the given value is not nil.
- func (pru *PushRegistrationUpdate) SetNillableDeviceSystemVersion(s *string) *PushRegistrationUpdate {
- if s != nil {
- pru.SetDeviceSystemVersion(*s)
- }
- return pru
- }
- // SetDeviceSystem sets the "device_system" field.
- func (pru *PushRegistrationUpdate) SetDeviceSystem(s string) *PushRegistrationUpdate {
- pru.mutation.SetDeviceSystem(s)
- return pru
- }
- // SetNillableDeviceSystem sets the "device_system" field if the given value is not nil.
- func (pru *PushRegistrationUpdate) SetNillableDeviceSystem(s *string) *PushRegistrationUpdate {
- if s != nil {
- pru.SetDeviceSystem(*s)
- }
- return pru
- }
- // SetCreatedAt sets the "created_at" field.
- func (pru *PushRegistrationUpdate) SetCreatedAt(t time.Time) *PushRegistrationUpdate {
- pru.mutation.SetCreatedAt(t)
- return pru
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (pru *PushRegistrationUpdate) SetNillableCreatedAt(t *time.Time) *PushRegistrationUpdate {
- if t != nil {
- pru.SetCreatedAt(*t)
- }
- return pru
- }
- // ClearCreatedAt clears the value of the "created_at" field.
- func (pru *PushRegistrationUpdate) ClearCreatedAt() *PushRegistrationUpdate {
- pru.mutation.ClearCreatedAt()
- return pru
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (pru *PushRegistrationUpdate) SetUpdatedAt(t time.Time) *PushRegistrationUpdate {
- pru.mutation.SetUpdatedAt(t)
- return pru
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (pru *PushRegistrationUpdate) SetNillableUpdatedAt(t *time.Time) *PushRegistrationUpdate {
- if t != nil {
- pru.SetUpdatedAt(*t)
- }
- return pru
- }
- // ClearUpdatedAt clears the value of the "updated_at" field.
- func (pru *PushRegistrationUpdate) ClearUpdatedAt() *PushRegistrationUpdate {
- pru.mutation.ClearUpdatedAt()
- return pru
- }
- // Mutation returns the PushRegistrationMutation object of the builder.
- func (pru *PushRegistrationUpdate) Mutation() *PushRegistrationMutation {
- return pru.mutation
- }
- // Save executes the query and returns the number of nodes affected by the update operation.
- func (pru *PushRegistrationUpdate) Save(ctx context.Context) (int, error) {
- return withHooks(ctx, pru.sqlSave, pru.mutation, pru.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (pru *PushRegistrationUpdate) SaveX(ctx context.Context) int {
- affected, err := pru.Save(ctx)
- if err != nil {
- panic(err)
- }
- return affected
- }
- // Exec executes the query.
- func (pru *PushRegistrationUpdate) Exec(ctx context.Context) error {
- _, err := pru.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (pru *PushRegistrationUpdate) ExecX(ctx context.Context) {
- if err := pru.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // check runs all checks and user-defined validators on the builder.
- func (pru *PushRegistrationUpdate) check() error {
- if v, ok := pru.mutation.Language(); ok {
- if err := pushregistration.LanguageValidator(v); err != nil {
- return &ValidationError{Name: "language", err: fmt.Errorf(`ent: validator failed for field "PushRegistration.language": %w`, err)}
- }
- }
- return nil
- }
- func (pru *PushRegistrationUpdate) sqlSave(ctx context.Context) (n int, err error) {
- if err := pru.check(); err != nil {
- return n, err
- }
- _spec := sqlgraph.NewUpdateSpec(pushregistration.Table, pushregistration.Columns, sqlgraph.NewFieldSpec(pushregistration.FieldID, field.TypeUUID))
- if ps := pru.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := pru.mutation.RegID(); ok {
- _spec.SetField(pushregistration.FieldRegID, field.TypeString, value)
- }
- if value, ok := pru.mutation.RegistrantPlatformType(); ok {
- _spec.SetField(pushregistration.FieldRegistrantPlatformType, field.TypeInt8, value)
- }
- if value, ok := pru.mutation.AddedRegistrantPlatformType(); ok {
- _spec.AddField(pushregistration.FieldRegistrantPlatformType, field.TypeInt8, value)
- }
- if value, ok := pru.mutation.Language(); ok {
- _spec.SetField(pushregistration.FieldLanguage, field.TypeString, value)
- }
- if value, ok := pru.mutation.DeviceModel(); ok {
- _spec.SetField(pushregistration.FieldDeviceModel, field.TypeString, value)
- }
- if value, ok := pru.mutation.DeviceManufacturer(); ok {
- _spec.SetField(pushregistration.FieldDeviceManufacturer, field.TypeString, value)
- }
- if value, ok := pru.mutation.DeviceSystemVersion(); ok {
- _spec.SetField(pushregistration.FieldDeviceSystemVersion, field.TypeString, value)
- }
- if value, ok := pru.mutation.DeviceSystem(); ok {
- _spec.SetField(pushregistration.FieldDeviceSystem, field.TypeString, value)
- }
- if value, ok := pru.mutation.CreatedAt(); ok {
- _spec.SetField(pushregistration.FieldCreatedAt, field.TypeTime, value)
- }
- if pru.mutation.CreatedAtCleared() {
- _spec.ClearField(pushregistration.FieldCreatedAt, field.TypeTime)
- }
- if value, ok := pru.mutation.UpdatedAt(); ok {
- _spec.SetField(pushregistration.FieldUpdatedAt, field.TypeTime, value)
- }
- if pru.mutation.UpdatedAtCleared() {
- _spec.ClearField(pushregistration.FieldUpdatedAt, field.TypeTime)
- }
- if n, err = sqlgraph.UpdateNodes(ctx, pru.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{pushregistration.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return 0, err
- }
- pru.mutation.done = true
- return n, nil
- }
- // PushRegistrationUpdateOne is the builder for updating a single PushRegistration entity.
- type PushRegistrationUpdateOne struct {
- config
- fields []string
- hooks []Hook
- mutation *PushRegistrationMutation
- }
- // SetRegID sets the "reg_id" field.
- func (pruo *PushRegistrationUpdateOne) SetRegID(s string) *PushRegistrationUpdateOne {
- pruo.mutation.SetRegID(s)
- return pruo
- }
- // SetNillableRegID sets the "reg_id" field if the given value is not nil.
- func (pruo *PushRegistrationUpdateOne) SetNillableRegID(s *string) *PushRegistrationUpdateOne {
- if s != nil {
- pruo.SetRegID(*s)
- }
- return pruo
- }
- // SetRegistrantPlatformType sets the "registrant_platform_type" field.
- func (pruo *PushRegistrationUpdateOne) SetRegistrantPlatformType(i int8) *PushRegistrationUpdateOne {
- pruo.mutation.ResetRegistrantPlatformType()
- pruo.mutation.SetRegistrantPlatformType(i)
- return pruo
- }
- // SetNillableRegistrantPlatformType sets the "registrant_platform_type" field if the given value is not nil.
- func (pruo *PushRegistrationUpdateOne) SetNillableRegistrantPlatformType(i *int8) *PushRegistrationUpdateOne {
- if i != nil {
- pruo.SetRegistrantPlatformType(*i)
- }
- return pruo
- }
- // AddRegistrantPlatformType adds i to the "registrant_platform_type" field.
- func (pruo *PushRegistrationUpdateOne) AddRegistrantPlatformType(i int8) *PushRegistrationUpdateOne {
- pruo.mutation.AddRegistrantPlatformType(i)
- return pruo
- }
- // SetLanguage sets the "language" field.
- func (pruo *PushRegistrationUpdateOne) SetLanguage(s string) *PushRegistrationUpdateOne {
- pruo.mutation.SetLanguage(s)
- return pruo
- }
- // SetNillableLanguage sets the "language" field if the given value is not nil.
- func (pruo *PushRegistrationUpdateOne) SetNillableLanguage(s *string) *PushRegistrationUpdateOne {
- if s != nil {
- pruo.SetLanguage(*s)
- }
- return pruo
- }
- // SetDeviceModel sets the "device_model" field.
- func (pruo *PushRegistrationUpdateOne) SetDeviceModel(s string) *PushRegistrationUpdateOne {
- pruo.mutation.SetDeviceModel(s)
- return pruo
- }
- // SetNillableDeviceModel sets the "device_model" field if the given value is not nil.
- func (pruo *PushRegistrationUpdateOne) SetNillableDeviceModel(s *string) *PushRegistrationUpdateOne {
- if s != nil {
- pruo.SetDeviceModel(*s)
- }
- return pruo
- }
- // SetDeviceManufacturer sets the "device_manufacturer" field.
- func (pruo *PushRegistrationUpdateOne) SetDeviceManufacturer(s string) *PushRegistrationUpdateOne {
- pruo.mutation.SetDeviceManufacturer(s)
- return pruo
- }
- // SetNillableDeviceManufacturer sets the "device_manufacturer" field if the given value is not nil.
- func (pruo *PushRegistrationUpdateOne) SetNillableDeviceManufacturer(s *string) *PushRegistrationUpdateOne {
- if s != nil {
- pruo.SetDeviceManufacturer(*s)
- }
- return pruo
- }
- // SetDeviceSystemVersion sets the "device_system_version" field.
- func (pruo *PushRegistrationUpdateOne) SetDeviceSystemVersion(s string) *PushRegistrationUpdateOne {
- pruo.mutation.SetDeviceSystemVersion(s)
- return pruo
- }
- // SetNillableDeviceSystemVersion sets the "device_system_version" field if the given value is not nil.
- func (pruo *PushRegistrationUpdateOne) SetNillableDeviceSystemVersion(s *string) *PushRegistrationUpdateOne {
- if s != nil {
- pruo.SetDeviceSystemVersion(*s)
- }
- return pruo
- }
- // SetDeviceSystem sets the "device_system" field.
- func (pruo *PushRegistrationUpdateOne) SetDeviceSystem(s string) *PushRegistrationUpdateOne {
- pruo.mutation.SetDeviceSystem(s)
- return pruo
- }
- // SetNillableDeviceSystem sets the "device_system" field if the given value is not nil.
- func (pruo *PushRegistrationUpdateOne) SetNillableDeviceSystem(s *string) *PushRegistrationUpdateOne {
- if s != nil {
- pruo.SetDeviceSystem(*s)
- }
- return pruo
- }
- // SetCreatedAt sets the "created_at" field.
- func (pruo *PushRegistrationUpdateOne) SetCreatedAt(t time.Time) *PushRegistrationUpdateOne {
- pruo.mutation.SetCreatedAt(t)
- return pruo
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (pruo *PushRegistrationUpdateOne) SetNillableCreatedAt(t *time.Time) *PushRegistrationUpdateOne {
- if t != nil {
- pruo.SetCreatedAt(*t)
- }
- return pruo
- }
- // ClearCreatedAt clears the value of the "created_at" field.
- func (pruo *PushRegistrationUpdateOne) ClearCreatedAt() *PushRegistrationUpdateOne {
- pruo.mutation.ClearCreatedAt()
- return pruo
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (pruo *PushRegistrationUpdateOne) SetUpdatedAt(t time.Time) *PushRegistrationUpdateOne {
- pruo.mutation.SetUpdatedAt(t)
- return pruo
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (pruo *PushRegistrationUpdateOne) SetNillableUpdatedAt(t *time.Time) *PushRegistrationUpdateOne {
- if t != nil {
- pruo.SetUpdatedAt(*t)
- }
- return pruo
- }
- // ClearUpdatedAt clears the value of the "updated_at" field.
- func (pruo *PushRegistrationUpdateOne) ClearUpdatedAt() *PushRegistrationUpdateOne {
- pruo.mutation.ClearUpdatedAt()
- return pruo
- }
- // Mutation returns the PushRegistrationMutation object of the builder.
- func (pruo *PushRegistrationUpdateOne) Mutation() *PushRegistrationMutation {
- return pruo.mutation
- }
- // Where appends a list predicates to the PushRegistrationUpdate builder.
- func (pruo *PushRegistrationUpdateOne) Where(ps ...predicate.PushRegistration) *PushRegistrationUpdateOne {
- pruo.mutation.Where(ps...)
- return pruo
- }
- // Select allows selecting one or more fields (columns) of the returned entity.
- // The default is selecting all fields defined in the entity schema.
- func (pruo *PushRegistrationUpdateOne) Select(field string, fields ...string) *PushRegistrationUpdateOne {
- pruo.fields = append([]string{field}, fields...)
- return pruo
- }
- // Save executes the query and returns the updated PushRegistration entity.
- func (pruo *PushRegistrationUpdateOne) Save(ctx context.Context) (*PushRegistration, error) {
- return withHooks(ctx, pruo.sqlSave, pruo.mutation, pruo.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (pruo *PushRegistrationUpdateOne) SaveX(ctx context.Context) *PushRegistration {
- node, err := pruo.Save(ctx)
- if err != nil {
- panic(err)
- }
- return node
- }
- // Exec executes the query on the entity.
- func (pruo *PushRegistrationUpdateOne) Exec(ctx context.Context) error {
- _, err := pruo.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (pruo *PushRegistrationUpdateOne) ExecX(ctx context.Context) {
- if err := pruo.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // check runs all checks and user-defined validators on the builder.
- func (pruo *PushRegistrationUpdateOne) check() error {
- if v, ok := pruo.mutation.Language(); ok {
- if err := pushregistration.LanguageValidator(v); err != nil {
- return &ValidationError{Name: "language", err: fmt.Errorf(`ent: validator failed for field "PushRegistration.language": %w`, err)}
- }
- }
- return nil
- }
- func (pruo *PushRegistrationUpdateOne) sqlSave(ctx context.Context) (_node *PushRegistration, err error) {
- if err := pruo.check(); err != nil {
- return _node, err
- }
- _spec := sqlgraph.NewUpdateSpec(pushregistration.Table, pushregistration.Columns, sqlgraph.NewFieldSpec(pushregistration.FieldID, field.TypeUUID))
- id, ok := pruo.mutation.ID()
- if !ok {
- return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PushRegistration.id" for update`)}
- }
- _spec.Node.ID.Value = id
- if fields := pruo.fields; len(fields) > 0 {
- _spec.Node.Columns = make([]string, 0, len(fields))
- _spec.Node.Columns = append(_spec.Node.Columns, pushregistration.FieldID)
- for _, f := range fields {
- if !pushregistration.ValidColumn(f) {
- return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
- }
- if f != pushregistration.FieldID {
- _spec.Node.Columns = append(_spec.Node.Columns, f)
- }
- }
- }
- if ps := pruo.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := pruo.mutation.RegID(); ok {
- _spec.SetField(pushregistration.FieldRegID, field.TypeString, value)
- }
- if value, ok := pruo.mutation.RegistrantPlatformType(); ok {
- _spec.SetField(pushregistration.FieldRegistrantPlatformType, field.TypeInt8, value)
- }
- if value, ok := pruo.mutation.AddedRegistrantPlatformType(); ok {
- _spec.AddField(pushregistration.FieldRegistrantPlatformType, field.TypeInt8, value)
- }
- if value, ok := pruo.mutation.Language(); ok {
- _spec.SetField(pushregistration.FieldLanguage, field.TypeString, value)
- }
- if value, ok := pruo.mutation.DeviceModel(); ok {
- _spec.SetField(pushregistration.FieldDeviceModel, field.TypeString, value)
- }
- if value, ok := pruo.mutation.DeviceManufacturer(); ok {
- _spec.SetField(pushregistration.FieldDeviceManufacturer, field.TypeString, value)
- }
- if value, ok := pruo.mutation.DeviceSystemVersion(); ok {
- _spec.SetField(pushregistration.FieldDeviceSystemVersion, field.TypeString, value)
- }
- if value, ok := pruo.mutation.DeviceSystem(); ok {
- _spec.SetField(pushregistration.FieldDeviceSystem, field.TypeString, value)
- }
- if value, ok := pruo.mutation.CreatedAt(); ok {
- _spec.SetField(pushregistration.FieldCreatedAt, field.TypeTime, value)
- }
- if pruo.mutation.CreatedAtCleared() {
- _spec.ClearField(pushregistration.FieldCreatedAt, field.TypeTime)
- }
- if value, ok := pruo.mutation.UpdatedAt(); ok {
- _spec.SetField(pushregistration.FieldUpdatedAt, field.TypeTime, value)
- }
- if pruo.mutation.UpdatedAtCleared() {
- _spec.ClearField(pushregistration.FieldUpdatedAt, field.TypeTime)
- }
- _node = &PushRegistration{config: pruo.config}
- _spec.Assign = _node.assignValues
- _spec.ScanValues = _node.scanValues
- if err = sqlgraph.UpdateNode(ctx, pruo.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{pushregistration.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- pruo.mutation.done = true
- return _node, nil
- }
|