github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/setting_update.go (about) 1 // Code generated by ent, DO NOT EDIT. 2 3 package ent 4 5 import ( 6 "context" 7 "errors" 8 "fmt" 9 10 "entgo.io/ent/dialect/sql" 11 "entgo.io/ent/dialect/sql/sqlgraph" 12 "entgo.io/ent/schema/field" 13 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/predicate" 14 "github.com/NpoolPlatform/chain-middleware/pkg/db/ent/setting" 15 "github.com/google/uuid" 16 "github.com/shopspring/decimal" 17 ) 18 19 // SettingUpdate is the builder for updating Setting entities. 20 type SettingUpdate struct { 21 config 22 hooks []Hook 23 mutation *SettingMutation 24 modifiers []func(*sql.UpdateBuilder) 25 } 26 27 // Where appends a list predicates to the SettingUpdate builder. 28 func (su *SettingUpdate) Where(ps ...predicate.Setting) *SettingUpdate { 29 su.mutation.Where(ps...) 30 return su 31 } 32 33 // SetCreatedAt sets the "created_at" field. 34 func (su *SettingUpdate) SetCreatedAt(u uint32) *SettingUpdate { 35 su.mutation.ResetCreatedAt() 36 su.mutation.SetCreatedAt(u) 37 return su 38 } 39 40 // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. 41 func (su *SettingUpdate) SetNillableCreatedAt(u *uint32) *SettingUpdate { 42 if u != nil { 43 su.SetCreatedAt(*u) 44 } 45 return su 46 } 47 48 // AddCreatedAt adds u to the "created_at" field. 49 func (su *SettingUpdate) AddCreatedAt(u int32) *SettingUpdate { 50 su.mutation.AddCreatedAt(u) 51 return su 52 } 53 54 // SetUpdatedAt sets the "updated_at" field. 55 func (su *SettingUpdate) SetUpdatedAt(u uint32) *SettingUpdate { 56 su.mutation.ResetUpdatedAt() 57 su.mutation.SetUpdatedAt(u) 58 return su 59 } 60 61 // AddUpdatedAt adds u to the "updated_at" field. 62 func (su *SettingUpdate) AddUpdatedAt(u int32) *SettingUpdate { 63 su.mutation.AddUpdatedAt(u) 64 return su 65 } 66 67 // SetDeletedAt sets the "deleted_at" field. 68 func (su *SettingUpdate) SetDeletedAt(u uint32) *SettingUpdate { 69 su.mutation.ResetDeletedAt() 70 su.mutation.SetDeletedAt(u) 71 return su 72 } 73 74 // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. 75 func (su *SettingUpdate) SetNillableDeletedAt(u *uint32) *SettingUpdate { 76 if u != nil { 77 su.SetDeletedAt(*u) 78 } 79 return su 80 } 81 82 // AddDeletedAt adds u to the "deleted_at" field. 83 func (su *SettingUpdate) AddDeletedAt(u int32) *SettingUpdate { 84 su.mutation.AddDeletedAt(u) 85 return su 86 } 87 88 // SetEntID sets the "ent_id" field. 89 func (su *SettingUpdate) SetEntID(u uuid.UUID) *SettingUpdate { 90 su.mutation.SetEntID(u) 91 return su 92 } 93 94 // SetNillableEntID sets the "ent_id" field if the given value is not nil. 95 func (su *SettingUpdate) SetNillableEntID(u *uuid.UUID) *SettingUpdate { 96 if u != nil { 97 su.SetEntID(*u) 98 } 99 return su 100 } 101 102 // SetCoinTypeID sets the "coin_type_id" field. 103 func (su *SettingUpdate) SetCoinTypeID(u uuid.UUID) *SettingUpdate { 104 su.mutation.SetCoinTypeID(u) 105 return su 106 } 107 108 // SetNillableCoinTypeID sets the "coin_type_id" field if the given value is not nil. 109 func (su *SettingUpdate) SetNillableCoinTypeID(u *uuid.UUID) *SettingUpdate { 110 if u != nil { 111 su.SetCoinTypeID(*u) 112 } 113 return su 114 } 115 116 // ClearCoinTypeID clears the value of the "coin_type_id" field. 117 func (su *SettingUpdate) ClearCoinTypeID() *SettingUpdate { 118 su.mutation.ClearCoinTypeID() 119 return su 120 } 121 122 // SetFeeCoinTypeID sets the "fee_coin_type_id" field. 123 func (su *SettingUpdate) SetFeeCoinTypeID(u uuid.UUID) *SettingUpdate { 124 su.mutation.SetFeeCoinTypeID(u) 125 return su 126 } 127 128 // SetNillableFeeCoinTypeID sets the "fee_coin_type_id" field if the given value is not nil. 129 func (su *SettingUpdate) SetNillableFeeCoinTypeID(u *uuid.UUID) *SettingUpdate { 130 if u != nil { 131 su.SetFeeCoinTypeID(*u) 132 } 133 return su 134 } 135 136 // ClearFeeCoinTypeID clears the value of the "fee_coin_type_id" field. 137 func (su *SettingUpdate) ClearFeeCoinTypeID() *SettingUpdate { 138 su.mutation.ClearFeeCoinTypeID() 139 return su 140 } 141 142 // SetWithdrawFeeByStableUsd sets the "withdraw_fee_by_stable_usd" field. 143 func (su *SettingUpdate) SetWithdrawFeeByStableUsd(b bool) *SettingUpdate { 144 su.mutation.SetWithdrawFeeByStableUsd(b) 145 return su 146 } 147 148 // SetNillableWithdrawFeeByStableUsd sets the "withdraw_fee_by_stable_usd" field if the given value is not nil. 149 func (su *SettingUpdate) SetNillableWithdrawFeeByStableUsd(b *bool) *SettingUpdate { 150 if b != nil { 151 su.SetWithdrawFeeByStableUsd(*b) 152 } 153 return su 154 } 155 156 // ClearWithdrawFeeByStableUsd clears the value of the "withdraw_fee_by_stable_usd" field. 157 func (su *SettingUpdate) ClearWithdrawFeeByStableUsd() *SettingUpdate { 158 su.mutation.ClearWithdrawFeeByStableUsd() 159 return su 160 } 161 162 // SetWithdrawFeeAmount sets the "withdraw_fee_amount" field. 163 func (su *SettingUpdate) SetWithdrawFeeAmount(d decimal.Decimal) *SettingUpdate { 164 su.mutation.SetWithdrawFeeAmount(d) 165 return su 166 } 167 168 // SetNillableWithdrawFeeAmount sets the "withdraw_fee_amount" field if the given value is not nil. 169 func (su *SettingUpdate) SetNillableWithdrawFeeAmount(d *decimal.Decimal) *SettingUpdate { 170 if d != nil { 171 su.SetWithdrawFeeAmount(*d) 172 } 173 return su 174 } 175 176 // ClearWithdrawFeeAmount clears the value of the "withdraw_fee_amount" field. 177 func (su *SettingUpdate) ClearWithdrawFeeAmount() *SettingUpdate { 178 su.mutation.ClearWithdrawFeeAmount() 179 return su 180 } 181 182 // SetCollectFeeAmount sets the "collect_fee_amount" field. 183 func (su *SettingUpdate) SetCollectFeeAmount(d decimal.Decimal) *SettingUpdate { 184 su.mutation.SetCollectFeeAmount(d) 185 return su 186 } 187 188 // SetNillableCollectFeeAmount sets the "collect_fee_amount" field if the given value is not nil. 189 func (su *SettingUpdate) SetNillableCollectFeeAmount(d *decimal.Decimal) *SettingUpdate { 190 if d != nil { 191 su.SetCollectFeeAmount(*d) 192 } 193 return su 194 } 195 196 // ClearCollectFeeAmount clears the value of the "collect_fee_amount" field. 197 func (su *SettingUpdate) ClearCollectFeeAmount() *SettingUpdate { 198 su.mutation.ClearCollectFeeAmount() 199 return su 200 } 201 202 // SetHotWalletFeeAmount sets the "hot_wallet_fee_amount" field. 203 func (su *SettingUpdate) SetHotWalletFeeAmount(d decimal.Decimal) *SettingUpdate { 204 su.mutation.SetHotWalletFeeAmount(d) 205 return su 206 } 207 208 // SetNillableHotWalletFeeAmount sets the "hot_wallet_fee_amount" field if the given value is not nil. 209 func (su *SettingUpdate) SetNillableHotWalletFeeAmount(d *decimal.Decimal) *SettingUpdate { 210 if d != nil { 211 su.SetHotWalletFeeAmount(*d) 212 } 213 return su 214 } 215 216 // ClearHotWalletFeeAmount clears the value of the "hot_wallet_fee_amount" field. 217 func (su *SettingUpdate) ClearHotWalletFeeAmount() *SettingUpdate { 218 su.mutation.ClearHotWalletFeeAmount() 219 return su 220 } 221 222 // SetLowFeeAmount sets the "low_fee_amount" field. 223 func (su *SettingUpdate) SetLowFeeAmount(d decimal.Decimal) *SettingUpdate { 224 su.mutation.SetLowFeeAmount(d) 225 return su 226 } 227 228 // SetNillableLowFeeAmount sets the "low_fee_amount" field if the given value is not nil. 229 func (su *SettingUpdate) SetNillableLowFeeAmount(d *decimal.Decimal) *SettingUpdate { 230 if d != nil { 231 su.SetLowFeeAmount(*d) 232 } 233 return su 234 } 235 236 // ClearLowFeeAmount clears the value of the "low_fee_amount" field. 237 func (su *SettingUpdate) ClearLowFeeAmount() *SettingUpdate { 238 su.mutation.ClearLowFeeAmount() 239 return su 240 } 241 242 // SetHotLowFeeAmount sets the "hot_low_fee_amount" field. 243 func (su *SettingUpdate) SetHotLowFeeAmount(d decimal.Decimal) *SettingUpdate { 244 su.mutation.SetHotLowFeeAmount(d) 245 return su 246 } 247 248 // SetNillableHotLowFeeAmount sets the "hot_low_fee_amount" field if the given value is not nil. 249 func (su *SettingUpdate) SetNillableHotLowFeeAmount(d *decimal.Decimal) *SettingUpdate { 250 if d != nil { 251 su.SetHotLowFeeAmount(*d) 252 } 253 return su 254 } 255 256 // ClearHotLowFeeAmount clears the value of the "hot_low_fee_amount" field. 257 func (su *SettingUpdate) ClearHotLowFeeAmount() *SettingUpdate { 258 su.mutation.ClearHotLowFeeAmount() 259 return su 260 } 261 262 // SetHotWalletAccountAmount sets the "hot_wallet_account_amount" field. 263 func (su *SettingUpdate) SetHotWalletAccountAmount(d decimal.Decimal) *SettingUpdate { 264 su.mutation.SetHotWalletAccountAmount(d) 265 return su 266 } 267 268 // SetNillableHotWalletAccountAmount sets the "hot_wallet_account_amount" field if the given value is not nil. 269 func (su *SettingUpdate) SetNillableHotWalletAccountAmount(d *decimal.Decimal) *SettingUpdate { 270 if d != nil { 271 su.SetHotWalletAccountAmount(*d) 272 } 273 return su 274 } 275 276 // ClearHotWalletAccountAmount clears the value of the "hot_wallet_account_amount" field. 277 func (su *SettingUpdate) ClearHotWalletAccountAmount() *SettingUpdate { 278 su.mutation.ClearHotWalletAccountAmount() 279 return su 280 } 281 282 // SetPaymentAccountCollectAmount sets the "payment_account_collect_amount" field. 283 func (su *SettingUpdate) SetPaymentAccountCollectAmount(d decimal.Decimal) *SettingUpdate { 284 su.mutation.SetPaymentAccountCollectAmount(d) 285 return su 286 } 287 288 // SetNillablePaymentAccountCollectAmount sets the "payment_account_collect_amount" field if the given value is not nil. 289 func (su *SettingUpdate) SetNillablePaymentAccountCollectAmount(d *decimal.Decimal) *SettingUpdate { 290 if d != nil { 291 su.SetPaymentAccountCollectAmount(*d) 292 } 293 return su 294 } 295 296 // ClearPaymentAccountCollectAmount clears the value of the "payment_account_collect_amount" field. 297 func (su *SettingUpdate) ClearPaymentAccountCollectAmount() *SettingUpdate { 298 su.mutation.ClearPaymentAccountCollectAmount() 299 return su 300 } 301 302 // SetLeastTransferAmount sets the "least_transfer_amount" field. 303 func (su *SettingUpdate) SetLeastTransferAmount(d decimal.Decimal) *SettingUpdate { 304 su.mutation.SetLeastTransferAmount(d) 305 return su 306 } 307 308 // SetNillableLeastTransferAmount sets the "least_transfer_amount" field if the given value is not nil. 309 func (su *SettingUpdate) SetNillableLeastTransferAmount(d *decimal.Decimal) *SettingUpdate { 310 if d != nil { 311 su.SetLeastTransferAmount(*d) 312 } 313 return su 314 } 315 316 // ClearLeastTransferAmount clears the value of the "least_transfer_amount" field. 317 func (su *SettingUpdate) ClearLeastTransferAmount() *SettingUpdate { 318 su.mutation.ClearLeastTransferAmount() 319 return su 320 } 321 322 // SetNeedMemo sets the "need_memo" field. 323 func (su *SettingUpdate) SetNeedMemo(b bool) *SettingUpdate { 324 su.mutation.SetNeedMemo(b) 325 return su 326 } 327 328 // SetNillableNeedMemo sets the "need_memo" field if the given value is not nil. 329 func (su *SettingUpdate) SetNillableNeedMemo(b *bool) *SettingUpdate { 330 if b != nil { 331 su.SetNeedMemo(*b) 332 } 333 return su 334 } 335 336 // ClearNeedMemo clears the value of the "need_memo" field. 337 func (su *SettingUpdate) ClearNeedMemo() *SettingUpdate { 338 su.mutation.ClearNeedMemo() 339 return su 340 } 341 342 // SetRefreshCurrency sets the "refresh_currency" field. 343 func (su *SettingUpdate) SetRefreshCurrency(b bool) *SettingUpdate { 344 su.mutation.SetRefreshCurrency(b) 345 return su 346 } 347 348 // SetNillableRefreshCurrency sets the "refresh_currency" field if the given value is not nil. 349 func (su *SettingUpdate) SetNillableRefreshCurrency(b *bool) *SettingUpdate { 350 if b != nil { 351 su.SetRefreshCurrency(*b) 352 } 353 return su 354 } 355 356 // ClearRefreshCurrency clears the value of the "refresh_currency" field. 357 func (su *SettingUpdate) ClearRefreshCurrency() *SettingUpdate { 358 su.mutation.ClearRefreshCurrency() 359 return su 360 } 361 362 // SetCheckNewAddressBalance sets the "check_new_address_balance" field. 363 func (su *SettingUpdate) SetCheckNewAddressBalance(b bool) *SettingUpdate { 364 su.mutation.SetCheckNewAddressBalance(b) 365 return su 366 } 367 368 // SetNillableCheckNewAddressBalance sets the "check_new_address_balance" field if the given value is not nil. 369 func (su *SettingUpdate) SetNillableCheckNewAddressBalance(b *bool) *SettingUpdate { 370 if b != nil { 371 su.SetCheckNewAddressBalance(*b) 372 } 373 return su 374 } 375 376 // ClearCheckNewAddressBalance clears the value of the "check_new_address_balance" field. 377 func (su *SettingUpdate) ClearCheckNewAddressBalance() *SettingUpdate { 378 su.mutation.ClearCheckNewAddressBalance() 379 return su 380 } 381 382 // Mutation returns the SettingMutation object of the builder. 383 func (su *SettingUpdate) Mutation() *SettingMutation { 384 return su.mutation 385 } 386 387 // Save executes the query and returns the number of nodes affected by the update operation. 388 func (su *SettingUpdate) Save(ctx context.Context) (int, error) { 389 var ( 390 err error 391 affected int 392 ) 393 if err := su.defaults(); err != nil { 394 return 0, err 395 } 396 if len(su.hooks) == 0 { 397 affected, err = su.sqlSave(ctx) 398 } else { 399 var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { 400 mutation, ok := m.(*SettingMutation) 401 if !ok { 402 return nil, fmt.Errorf("unexpected mutation type %T", m) 403 } 404 su.mutation = mutation 405 affected, err = su.sqlSave(ctx) 406 mutation.done = true 407 return affected, err 408 }) 409 for i := len(su.hooks) - 1; i >= 0; i-- { 410 if su.hooks[i] == nil { 411 return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") 412 } 413 mut = su.hooks[i](mut) 414 } 415 if _, err := mut.Mutate(ctx, su.mutation); err != nil { 416 return 0, err 417 } 418 } 419 return affected, err 420 } 421 422 // SaveX is like Save, but panics if an error occurs. 423 func (su *SettingUpdate) SaveX(ctx context.Context) int { 424 affected, err := su.Save(ctx) 425 if err != nil { 426 panic(err) 427 } 428 return affected 429 } 430 431 // Exec executes the query. 432 func (su *SettingUpdate) Exec(ctx context.Context) error { 433 _, err := su.Save(ctx) 434 return err 435 } 436 437 // ExecX is like Exec, but panics if an error occurs. 438 func (su *SettingUpdate) ExecX(ctx context.Context) { 439 if err := su.Exec(ctx); err != nil { 440 panic(err) 441 } 442 } 443 444 // defaults sets the default values of the builder before save. 445 func (su *SettingUpdate) defaults() error { 446 if _, ok := su.mutation.UpdatedAt(); !ok { 447 if setting.UpdateDefaultUpdatedAt == nil { 448 return fmt.Errorf("ent: uninitialized setting.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") 449 } 450 v := setting.UpdateDefaultUpdatedAt() 451 su.mutation.SetUpdatedAt(v) 452 } 453 return nil 454 } 455 456 // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. 457 func (su *SettingUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SettingUpdate { 458 su.modifiers = append(su.modifiers, modifiers...) 459 return su 460 } 461 462 func (su *SettingUpdate) sqlSave(ctx context.Context) (n int, err error) { 463 _spec := &sqlgraph.UpdateSpec{ 464 Node: &sqlgraph.NodeSpec{ 465 Table: setting.Table, 466 Columns: setting.Columns, 467 ID: &sqlgraph.FieldSpec{ 468 Type: field.TypeUint32, 469 Column: setting.FieldID, 470 }, 471 }, 472 } 473 if ps := su.mutation.predicates; len(ps) > 0 { 474 _spec.Predicate = func(selector *sql.Selector) { 475 for i := range ps { 476 ps[i](selector) 477 } 478 } 479 } 480 if value, ok := su.mutation.CreatedAt(); ok { 481 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 482 Type: field.TypeUint32, 483 Value: value, 484 Column: setting.FieldCreatedAt, 485 }) 486 } 487 if value, ok := su.mutation.AddedCreatedAt(); ok { 488 _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ 489 Type: field.TypeUint32, 490 Value: value, 491 Column: setting.FieldCreatedAt, 492 }) 493 } 494 if value, ok := su.mutation.UpdatedAt(); ok { 495 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 496 Type: field.TypeUint32, 497 Value: value, 498 Column: setting.FieldUpdatedAt, 499 }) 500 } 501 if value, ok := su.mutation.AddedUpdatedAt(); ok { 502 _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ 503 Type: field.TypeUint32, 504 Value: value, 505 Column: setting.FieldUpdatedAt, 506 }) 507 } 508 if value, ok := su.mutation.DeletedAt(); ok { 509 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 510 Type: field.TypeUint32, 511 Value: value, 512 Column: setting.FieldDeletedAt, 513 }) 514 } 515 if value, ok := su.mutation.AddedDeletedAt(); ok { 516 _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ 517 Type: field.TypeUint32, 518 Value: value, 519 Column: setting.FieldDeletedAt, 520 }) 521 } 522 if value, ok := su.mutation.EntID(); ok { 523 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 524 Type: field.TypeUUID, 525 Value: value, 526 Column: setting.FieldEntID, 527 }) 528 } 529 if value, ok := su.mutation.CoinTypeID(); ok { 530 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 531 Type: field.TypeUUID, 532 Value: value, 533 Column: setting.FieldCoinTypeID, 534 }) 535 } 536 if su.mutation.CoinTypeIDCleared() { 537 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 538 Type: field.TypeUUID, 539 Column: setting.FieldCoinTypeID, 540 }) 541 } 542 if value, ok := su.mutation.FeeCoinTypeID(); ok { 543 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 544 Type: field.TypeUUID, 545 Value: value, 546 Column: setting.FieldFeeCoinTypeID, 547 }) 548 } 549 if su.mutation.FeeCoinTypeIDCleared() { 550 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 551 Type: field.TypeUUID, 552 Column: setting.FieldFeeCoinTypeID, 553 }) 554 } 555 if value, ok := su.mutation.WithdrawFeeByStableUsd(); ok { 556 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 557 Type: field.TypeBool, 558 Value: value, 559 Column: setting.FieldWithdrawFeeByStableUsd, 560 }) 561 } 562 if su.mutation.WithdrawFeeByStableUsdCleared() { 563 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 564 Type: field.TypeBool, 565 Column: setting.FieldWithdrawFeeByStableUsd, 566 }) 567 } 568 if value, ok := su.mutation.WithdrawFeeAmount(); ok { 569 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 570 Type: field.TypeOther, 571 Value: value, 572 Column: setting.FieldWithdrawFeeAmount, 573 }) 574 } 575 if su.mutation.WithdrawFeeAmountCleared() { 576 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 577 Type: field.TypeOther, 578 Column: setting.FieldWithdrawFeeAmount, 579 }) 580 } 581 if value, ok := su.mutation.CollectFeeAmount(); ok { 582 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 583 Type: field.TypeOther, 584 Value: value, 585 Column: setting.FieldCollectFeeAmount, 586 }) 587 } 588 if su.mutation.CollectFeeAmountCleared() { 589 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 590 Type: field.TypeOther, 591 Column: setting.FieldCollectFeeAmount, 592 }) 593 } 594 if value, ok := su.mutation.HotWalletFeeAmount(); ok { 595 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 596 Type: field.TypeOther, 597 Value: value, 598 Column: setting.FieldHotWalletFeeAmount, 599 }) 600 } 601 if su.mutation.HotWalletFeeAmountCleared() { 602 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 603 Type: field.TypeOther, 604 Column: setting.FieldHotWalletFeeAmount, 605 }) 606 } 607 if value, ok := su.mutation.LowFeeAmount(); ok { 608 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 609 Type: field.TypeOther, 610 Value: value, 611 Column: setting.FieldLowFeeAmount, 612 }) 613 } 614 if su.mutation.LowFeeAmountCleared() { 615 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 616 Type: field.TypeOther, 617 Column: setting.FieldLowFeeAmount, 618 }) 619 } 620 if value, ok := su.mutation.HotLowFeeAmount(); ok { 621 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 622 Type: field.TypeOther, 623 Value: value, 624 Column: setting.FieldHotLowFeeAmount, 625 }) 626 } 627 if su.mutation.HotLowFeeAmountCleared() { 628 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 629 Type: field.TypeOther, 630 Column: setting.FieldHotLowFeeAmount, 631 }) 632 } 633 if value, ok := su.mutation.HotWalletAccountAmount(); ok { 634 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 635 Type: field.TypeOther, 636 Value: value, 637 Column: setting.FieldHotWalletAccountAmount, 638 }) 639 } 640 if su.mutation.HotWalletAccountAmountCleared() { 641 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 642 Type: field.TypeOther, 643 Column: setting.FieldHotWalletAccountAmount, 644 }) 645 } 646 if value, ok := su.mutation.PaymentAccountCollectAmount(); ok { 647 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 648 Type: field.TypeOther, 649 Value: value, 650 Column: setting.FieldPaymentAccountCollectAmount, 651 }) 652 } 653 if su.mutation.PaymentAccountCollectAmountCleared() { 654 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 655 Type: field.TypeOther, 656 Column: setting.FieldPaymentAccountCollectAmount, 657 }) 658 } 659 if value, ok := su.mutation.LeastTransferAmount(); ok { 660 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 661 Type: field.TypeOther, 662 Value: value, 663 Column: setting.FieldLeastTransferAmount, 664 }) 665 } 666 if su.mutation.LeastTransferAmountCleared() { 667 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 668 Type: field.TypeOther, 669 Column: setting.FieldLeastTransferAmount, 670 }) 671 } 672 if value, ok := su.mutation.NeedMemo(); ok { 673 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 674 Type: field.TypeBool, 675 Value: value, 676 Column: setting.FieldNeedMemo, 677 }) 678 } 679 if su.mutation.NeedMemoCleared() { 680 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 681 Type: field.TypeBool, 682 Column: setting.FieldNeedMemo, 683 }) 684 } 685 if value, ok := su.mutation.RefreshCurrency(); ok { 686 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 687 Type: field.TypeBool, 688 Value: value, 689 Column: setting.FieldRefreshCurrency, 690 }) 691 } 692 if su.mutation.RefreshCurrencyCleared() { 693 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 694 Type: field.TypeBool, 695 Column: setting.FieldRefreshCurrency, 696 }) 697 } 698 if value, ok := su.mutation.CheckNewAddressBalance(); ok { 699 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 700 Type: field.TypeBool, 701 Value: value, 702 Column: setting.FieldCheckNewAddressBalance, 703 }) 704 } 705 if su.mutation.CheckNewAddressBalanceCleared() { 706 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 707 Type: field.TypeBool, 708 Column: setting.FieldCheckNewAddressBalance, 709 }) 710 } 711 _spec.Modifiers = su.modifiers 712 if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil { 713 if _, ok := err.(*sqlgraph.NotFoundError); ok { 714 err = &NotFoundError{setting.Label} 715 } else if sqlgraph.IsConstraintError(err) { 716 err = &ConstraintError{msg: err.Error(), wrap: err} 717 } 718 return 0, err 719 } 720 return n, nil 721 } 722 723 // SettingUpdateOne is the builder for updating a single Setting entity. 724 type SettingUpdateOne struct { 725 config 726 fields []string 727 hooks []Hook 728 mutation *SettingMutation 729 modifiers []func(*sql.UpdateBuilder) 730 } 731 732 // SetCreatedAt sets the "created_at" field. 733 func (suo *SettingUpdateOne) SetCreatedAt(u uint32) *SettingUpdateOne { 734 suo.mutation.ResetCreatedAt() 735 suo.mutation.SetCreatedAt(u) 736 return suo 737 } 738 739 // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. 740 func (suo *SettingUpdateOne) SetNillableCreatedAt(u *uint32) *SettingUpdateOne { 741 if u != nil { 742 suo.SetCreatedAt(*u) 743 } 744 return suo 745 } 746 747 // AddCreatedAt adds u to the "created_at" field. 748 func (suo *SettingUpdateOne) AddCreatedAt(u int32) *SettingUpdateOne { 749 suo.mutation.AddCreatedAt(u) 750 return suo 751 } 752 753 // SetUpdatedAt sets the "updated_at" field. 754 func (suo *SettingUpdateOne) SetUpdatedAt(u uint32) *SettingUpdateOne { 755 suo.mutation.ResetUpdatedAt() 756 suo.mutation.SetUpdatedAt(u) 757 return suo 758 } 759 760 // AddUpdatedAt adds u to the "updated_at" field. 761 func (suo *SettingUpdateOne) AddUpdatedAt(u int32) *SettingUpdateOne { 762 suo.mutation.AddUpdatedAt(u) 763 return suo 764 } 765 766 // SetDeletedAt sets the "deleted_at" field. 767 func (suo *SettingUpdateOne) SetDeletedAt(u uint32) *SettingUpdateOne { 768 suo.mutation.ResetDeletedAt() 769 suo.mutation.SetDeletedAt(u) 770 return suo 771 } 772 773 // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. 774 func (suo *SettingUpdateOne) SetNillableDeletedAt(u *uint32) *SettingUpdateOne { 775 if u != nil { 776 suo.SetDeletedAt(*u) 777 } 778 return suo 779 } 780 781 // AddDeletedAt adds u to the "deleted_at" field. 782 func (suo *SettingUpdateOne) AddDeletedAt(u int32) *SettingUpdateOne { 783 suo.mutation.AddDeletedAt(u) 784 return suo 785 } 786 787 // SetEntID sets the "ent_id" field. 788 func (suo *SettingUpdateOne) SetEntID(u uuid.UUID) *SettingUpdateOne { 789 suo.mutation.SetEntID(u) 790 return suo 791 } 792 793 // SetNillableEntID sets the "ent_id" field if the given value is not nil. 794 func (suo *SettingUpdateOne) SetNillableEntID(u *uuid.UUID) *SettingUpdateOne { 795 if u != nil { 796 suo.SetEntID(*u) 797 } 798 return suo 799 } 800 801 // SetCoinTypeID sets the "coin_type_id" field. 802 func (suo *SettingUpdateOne) SetCoinTypeID(u uuid.UUID) *SettingUpdateOne { 803 suo.mutation.SetCoinTypeID(u) 804 return suo 805 } 806 807 // SetNillableCoinTypeID sets the "coin_type_id" field if the given value is not nil. 808 func (suo *SettingUpdateOne) SetNillableCoinTypeID(u *uuid.UUID) *SettingUpdateOne { 809 if u != nil { 810 suo.SetCoinTypeID(*u) 811 } 812 return suo 813 } 814 815 // ClearCoinTypeID clears the value of the "coin_type_id" field. 816 func (suo *SettingUpdateOne) ClearCoinTypeID() *SettingUpdateOne { 817 suo.mutation.ClearCoinTypeID() 818 return suo 819 } 820 821 // SetFeeCoinTypeID sets the "fee_coin_type_id" field. 822 func (suo *SettingUpdateOne) SetFeeCoinTypeID(u uuid.UUID) *SettingUpdateOne { 823 suo.mutation.SetFeeCoinTypeID(u) 824 return suo 825 } 826 827 // SetNillableFeeCoinTypeID sets the "fee_coin_type_id" field if the given value is not nil. 828 func (suo *SettingUpdateOne) SetNillableFeeCoinTypeID(u *uuid.UUID) *SettingUpdateOne { 829 if u != nil { 830 suo.SetFeeCoinTypeID(*u) 831 } 832 return suo 833 } 834 835 // ClearFeeCoinTypeID clears the value of the "fee_coin_type_id" field. 836 func (suo *SettingUpdateOne) ClearFeeCoinTypeID() *SettingUpdateOne { 837 suo.mutation.ClearFeeCoinTypeID() 838 return suo 839 } 840 841 // SetWithdrawFeeByStableUsd sets the "withdraw_fee_by_stable_usd" field. 842 func (suo *SettingUpdateOne) SetWithdrawFeeByStableUsd(b bool) *SettingUpdateOne { 843 suo.mutation.SetWithdrawFeeByStableUsd(b) 844 return suo 845 } 846 847 // SetNillableWithdrawFeeByStableUsd sets the "withdraw_fee_by_stable_usd" field if the given value is not nil. 848 func (suo *SettingUpdateOne) SetNillableWithdrawFeeByStableUsd(b *bool) *SettingUpdateOne { 849 if b != nil { 850 suo.SetWithdrawFeeByStableUsd(*b) 851 } 852 return suo 853 } 854 855 // ClearWithdrawFeeByStableUsd clears the value of the "withdraw_fee_by_stable_usd" field. 856 func (suo *SettingUpdateOne) ClearWithdrawFeeByStableUsd() *SettingUpdateOne { 857 suo.mutation.ClearWithdrawFeeByStableUsd() 858 return suo 859 } 860 861 // SetWithdrawFeeAmount sets the "withdraw_fee_amount" field. 862 func (suo *SettingUpdateOne) SetWithdrawFeeAmount(d decimal.Decimal) *SettingUpdateOne { 863 suo.mutation.SetWithdrawFeeAmount(d) 864 return suo 865 } 866 867 // SetNillableWithdrawFeeAmount sets the "withdraw_fee_amount" field if the given value is not nil. 868 func (suo *SettingUpdateOne) SetNillableWithdrawFeeAmount(d *decimal.Decimal) *SettingUpdateOne { 869 if d != nil { 870 suo.SetWithdrawFeeAmount(*d) 871 } 872 return suo 873 } 874 875 // ClearWithdrawFeeAmount clears the value of the "withdraw_fee_amount" field. 876 func (suo *SettingUpdateOne) ClearWithdrawFeeAmount() *SettingUpdateOne { 877 suo.mutation.ClearWithdrawFeeAmount() 878 return suo 879 } 880 881 // SetCollectFeeAmount sets the "collect_fee_amount" field. 882 func (suo *SettingUpdateOne) SetCollectFeeAmount(d decimal.Decimal) *SettingUpdateOne { 883 suo.mutation.SetCollectFeeAmount(d) 884 return suo 885 } 886 887 // SetNillableCollectFeeAmount sets the "collect_fee_amount" field if the given value is not nil. 888 func (suo *SettingUpdateOne) SetNillableCollectFeeAmount(d *decimal.Decimal) *SettingUpdateOne { 889 if d != nil { 890 suo.SetCollectFeeAmount(*d) 891 } 892 return suo 893 } 894 895 // ClearCollectFeeAmount clears the value of the "collect_fee_amount" field. 896 func (suo *SettingUpdateOne) ClearCollectFeeAmount() *SettingUpdateOne { 897 suo.mutation.ClearCollectFeeAmount() 898 return suo 899 } 900 901 // SetHotWalletFeeAmount sets the "hot_wallet_fee_amount" field. 902 func (suo *SettingUpdateOne) SetHotWalletFeeAmount(d decimal.Decimal) *SettingUpdateOne { 903 suo.mutation.SetHotWalletFeeAmount(d) 904 return suo 905 } 906 907 // SetNillableHotWalletFeeAmount sets the "hot_wallet_fee_amount" field if the given value is not nil. 908 func (suo *SettingUpdateOne) SetNillableHotWalletFeeAmount(d *decimal.Decimal) *SettingUpdateOne { 909 if d != nil { 910 suo.SetHotWalletFeeAmount(*d) 911 } 912 return suo 913 } 914 915 // ClearHotWalletFeeAmount clears the value of the "hot_wallet_fee_amount" field. 916 func (suo *SettingUpdateOne) ClearHotWalletFeeAmount() *SettingUpdateOne { 917 suo.mutation.ClearHotWalletFeeAmount() 918 return suo 919 } 920 921 // SetLowFeeAmount sets the "low_fee_amount" field. 922 func (suo *SettingUpdateOne) SetLowFeeAmount(d decimal.Decimal) *SettingUpdateOne { 923 suo.mutation.SetLowFeeAmount(d) 924 return suo 925 } 926 927 // SetNillableLowFeeAmount sets the "low_fee_amount" field if the given value is not nil. 928 func (suo *SettingUpdateOne) SetNillableLowFeeAmount(d *decimal.Decimal) *SettingUpdateOne { 929 if d != nil { 930 suo.SetLowFeeAmount(*d) 931 } 932 return suo 933 } 934 935 // ClearLowFeeAmount clears the value of the "low_fee_amount" field. 936 func (suo *SettingUpdateOne) ClearLowFeeAmount() *SettingUpdateOne { 937 suo.mutation.ClearLowFeeAmount() 938 return suo 939 } 940 941 // SetHotLowFeeAmount sets the "hot_low_fee_amount" field. 942 func (suo *SettingUpdateOne) SetHotLowFeeAmount(d decimal.Decimal) *SettingUpdateOne { 943 suo.mutation.SetHotLowFeeAmount(d) 944 return suo 945 } 946 947 // SetNillableHotLowFeeAmount sets the "hot_low_fee_amount" field if the given value is not nil. 948 func (suo *SettingUpdateOne) SetNillableHotLowFeeAmount(d *decimal.Decimal) *SettingUpdateOne { 949 if d != nil { 950 suo.SetHotLowFeeAmount(*d) 951 } 952 return suo 953 } 954 955 // ClearHotLowFeeAmount clears the value of the "hot_low_fee_amount" field. 956 func (suo *SettingUpdateOne) ClearHotLowFeeAmount() *SettingUpdateOne { 957 suo.mutation.ClearHotLowFeeAmount() 958 return suo 959 } 960 961 // SetHotWalletAccountAmount sets the "hot_wallet_account_amount" field. 962 func (suo *SettingUpdateOne) SetHotWalletAccountAmount(d decimal.Decimal) *SettingUpdateOne { 963 suo.mutation.SetHotWalletAccountAmount(d) 964 return suo 965 } 966 967 // SetNillableHotWalletAccountAmount sets the "hot_wallet_account_amount" field if the given value is not nil. 968 func (suo *SettingUpdateOne) SetNillableHotWalletAccountAmount(d *decimal.Decimal) *SettingUpdateOne { 969 if d != nil { 970 suo.SetHotWalletAccountAmount(*d) 971 } 972 return suo 973 } 974 975 // ClearHotWalletAccountAmount clears the value of the "hot_wallet_account_amount" field. 976 func (suo *SettingUpdateOne) ClearHotWalletAccountAmount() *SettingUpdateOne { 977 suo.mutation.ClearHotWalletAccountAmount() 978 return suo 979 } 980 981 // SetPaymentAccountCollectAmount sets the "payment_account_collect_amount" field. 982 func (suo *SettingUpdateOne) SetPaymentAccountCollectAmount(d decimal.Decimal) *SettingUpdateOne { 983 suo.mutation.SetPaymentAccountCollectAmount(d) 984 return suo 985 } 986 987 // SetNillablePaymentAccountCollectAmount sets the "payment_account_collect_amount" field if the given value is not nil. 988 func (suo *SettingUpdateOne) SetNillablePaymentAccountCollectAmount(d *decimal.Decimal) *SettingUpdateOne { 989 if d != nil { 990 suo.SetPaymentAccountCollectAmount(*d) 991 } 992 return suo 993 } 994 995 // ClearPaymentAccountCollectAmount clears the value of the "payment_account_collect_amount" field. 996 func (suo *SettingUpdateOne) ClearPaymentAccountCollectAmount() *SettingUpdateOne { 997 suo.mutation.ClearPaymentAccountCollectAmount() 998 return suo 999 } 1000 1001 // SetLeastTransferAmount sets the "least_transfer_amount" field. 1002 func (suo *SettingUpdateOne) SetLeastTransferAmount(d decimal.Decimal) *SettingUpdateOne { 1003 suo.mutation.SetLeastTransferAmount(d) 1004 return suo 1005 } 1006 1007 // SetNillableLeastTransferAmount sets the "least_transfer_amount" field if the given value is not nil. 1008 func (suo *SettingUpdateOne) SetNillableLeastTransferAmount(d *decimal.Decimal) *SettingUpdateOne { 1009 if d != nil { 1010 suo.SetLeastTransferAmount(*d) 1011 } 1012 return suo 1013 } 1014 1015 // ClearLeastTransferAmount clears the value of the "least_transfer_amount" field. 1016 func (suo *SettingUpdateOne) ClearLeastTransferAmount() *SettingUpdateOne { 1017 suo.mutation.ClearLeastTransferAmount() 1018 return suo 1019 } 1020 1021 // SetNeedMemo sets the "need_memo" field. 1022 func (suo *SettingUpdateOne) SetNeedMemo(b bool) *SettingUpdateOne { 1023 suo.mutation.SetNeedMemo(b) 1024 return suo 1025 } 1026 1027 // SetNillableNeedMemo sets the "need_memo" field if the given value is not nil. 1028 func (suo *SettingUpdateOne) SetNillableNeedMemo(b *bool) *SettingUpdateOne { 1029 if b != nil { 1030 suo.SetNeedMemo(*b) 1031 } 1032 return suo 1033 } 1034 1035 // ClearNeedMemo clears the value of the "need_memo" field. 1036 func (suo *SettingUpdateOne) ClearNeedMemo() *SettingUpdateOne { 1037 suo.mutation.ClearNeedMemo() 1038 return suo 1039 } 1040 1041 // SetRefreshCurrency sets the "refresh_currency" field. 1042 func (suo *SettingUpdateOne) SetRefreshCurrency(b bool) *SettingUpdateOne { 1043 suo.mutation.SetRefreshCurrency(b) 1044 return suo 1045 } 1046 1047 // SetNillableRefreshCurrency sets the "refresh_currency" field if the given value is not nil. 1048 func (suo *SettingUpdateOne) SetNillableRefreshCurrency(b *bool) *SettingUpdateOne { 1049 if b != nil { 1050 suo.SetRefreshCurrency(*b) 1051 } 1052 return suo 1053 } 1054 1055 // ClearRefreshCurrency clears the value of the "refresh_currency" field. 1056 func (suo *SettingUpdateOne) ClearRefreshCurrency() *SettingUpdateOne { 1057 suo.mutation.ClearRefreshCurrency() 1058 return suo 1059 } 1060 1061 // SetCheckNewAddressBalance sets the "check_new_address_balance" field. 1062 func (suo *SettingUpdateOne) SetCheckNewAddressBalance(b bool) *SettingUpdateOne { 1063 suo.mutation.SetCheckNewAddressBalance(b) 1064 return suo 1065 } 1066 1067 // SetNillableCheckNewAddressBalance sets the "check_new_address_balance" field if the given value is not nil. 1068 func (suo *SettingUpdateOne) SetNillableCheckNewAddressBalance(b *bool) *SettingUpdateOne { 1069 if b != nil { 1070 suo.SetCheckNewAddressBalance(*b) 1071 } 1072 return suo 1073 } 1074 1075 // ClearCheckNewAddressBalance clears the value of the "check_new_address_balance" field. 1076 func (suo *SettingUpdateOne) ClearCheckNewAddressBalance() *SettingUpdateOne { 1077 suo.mutation.ClearCheckNewAddressBalance() 1078 return suo 1079 } 1080 1081 // Mutation returns the SettingMutation object of the builder. 1082 func (suo *SettingUpdateOne) Mutation() *SettingMutation { 1083 return suo.mutation 1084 } 1085 1086 // Select allows selecting one or more fields (columns) of the returned entity. 1087 // The default is selecting all fields defined in the entity schema. 1088 func (suo *SettingUpdateOne) Select(field string, fields ...string) *SettingUpdateOne { 1089 suo.fields = append([]string{field}, fields...) 1090 return suo 1091 } 1092 1093 // Save executes the query and returns the updated Setting entity. 1094 func (suo *SettingUpdateOne) Save(ctx context.Context) (*Setting, error) { 1095 var ( 1096 err error 1097 node *Setting 1098 ) 1099 if err := suo.defaults(); err != nil { 1100 return nil, err 1101 } 1102 if len(suo.hooks) == 0 { 1103 node, err = suo.sqlSave(ctx) 1104 } else { 1105 var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { 1106 mutation, ok := m.(*SettingMutation) 1107 if !ok { 1108 return nil, fmt.Errorf("unexpected mutation type %T", m) 1109 } 1110 suo.mutation = mutation 1111 node, err = suo.sqlSave(ctx) 1112 mutation.done = true 1113 return node, err 1114 }) 1115 for i := len(suo.hooks) - 1; i >= 0; i-- { 1116 if suo.hooks[i] == nil { 1117 return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") 1118 } 1119 mut = suo.hooks[i](mut) 1120 } 1121 v, err := mut.Mutate(ctx, suo.mutation) 1122 if err != nil { 1123 return nil, err 1124 } 1125 nv, ok := v.(*Setting) 1126 if !ok { 1127 return nil, fmt.Errorf("unexpected node type %T returned from SettingMutation", v) 1128 } 1129 node = nv 1130 } 1131 return node, err 1132 } 1133 1134 // SaveX is like Save, but panics if an error occurs. 1135 func (suo *SettingUpdateOne) SaveX(ctx context.Context) *Setting { 1136 node, err := suo.Save(ctx) 1137 if err != nil { 1138 panic(err) 1139 } 1140 return node 1141 } 1142 1143 // Exec executes the query on the entity. 1144 func (suo *SettingUpdateOne) Exec(ctx context.Context) error { 1145 _, err := suo.Save(ctx) 1146 return err 1147 } 1148 1149 // ExecX is like Exec, but panics if an error occurs. 1150 func (suo *SettingUpdateOne) ExecX(ctx context.Context) { 1151 if err := suo.Exec(ctx); err != nil { 1152 panic(err) 1153 } 1154 } 1155 1156 // defaults sets the default values of the builder before save. 1157 func (suo *SettingUpdateOne) defaults() error { 1158 if _, ok := suo.mutation.UpdatedAt(); !ok { 1159 if setting.UpdateDefaultUpdatedAt == nil { 1160 return fmt.Errorf("ent: uninitialized setting.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") 1161 } 1162 v := setting.UpdateDefaultUpdatedAt() 1163 suo.mutation.SetUpdatedAt(v) 1164 } 1165 return nil 1166 } 1167 1168 // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. 1169 func (suo *SettingUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SettingUpdateOne { 1170 suo.modifiers = append(suo.modifiers, modifiers...) 1171 return suo 1172 } 1173 1174 func (suo *SettingUpdateOne) sqlSave(ctx context.Context) (_node *Setting, err error) { 1175 _spec := &sqlgraph.UpdateSpec{ 1176 Node: &sqlgraph.NodeSpec{ 1177 Table: setting.Table, 1178 Columns: setting.Columns, 1179 ID: &sqlgraph.FieldSpec{ 1180 Type: field.TypeUint32, 1181 Column: setting.FieldID, 1182 }, 1183 }, 1184 } 1185 id, ok := suo.mutation.ID() 1186 if !ok { 1187 return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Setting.id" for update`)} 1188 } 1189 _spec.Node.ID.Value = id 1190 if fields := suo.fields; len(fields) > 0 { 1191 _spec.Node.Columns = make([]string, 0, len(fields)) 1192 _spec.Node.Columns = append(_spec.Node.Columns, setting.FieldID) 1193 for _, f := range fields { 1194 if !setting.ValidColumn(f) { 1195 return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} 1196 } 1197 if f != setting.FieldID { 1198 _spec.Node.Columns = append(_spec.Node.Columns, f) 1199 } 1200 } 1201 } 1202 if ps := suo.mutation.predicates; len(ps) > 0 { 1203 _spec.Predicate = func(selector *sql.Selector) { 1204 for i := range ps { 1205 ps[i](selector) 1206 } 1207 } 1208 } 1209 if value, ok := suo.mutation.CreatedAt(); ok { 1210 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1211 Type: field.TypeUint32, 1212 Value: value, 1213 Column: setting.FieldCreatedAt, 1214 }) 1215 } 1216 if value, ok := suo.mutation.AddedCreatedAt(); ok { 1217 _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ 1218 Type: field.TypeUint32, 1219 Value: value, 1220 Column: setting.FieldCreatedAt, 1221 }) 1222 } 1223 if value, ok := suo.mutation.UpdatedAt(); ok { 1224 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1225 Type: field.TypeUint32, 1226 Value: value, 1227 Column: setting.FieldUpdatedAt, 1228 }) 1229 } 1230 if value, ok := suo.mutation.AddedUpdatedAt(); ok { 1231 _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ 1232 Type: field.TypeUint32, 1233 Value: value, 1234 Column: setting.FieldUpdatedAt, 1235 }) 1236 } 1237 if value, ok := suo.mutation.DeletedAt(); ok { 1238 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1239 Type: field.TypeUint32, 1240 Value: value, 1241 Column: setting.FieldDeletedAt, 1242 }) 1243 } 1244 if value, ok := suo.mutation.AddedDeletedAt(); ok { 1245 _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ 1246 Type: field.TypeUint32, 1247 Value: value, 1248 Column: setting.FieldDeletedAt, 1249 }) 1250 } 1251 if value, ok := suo.mutation.EntID(); ok { 1252 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1253 Type: field.TypeUUID, 1254 Value: value, 1255 Column: setting.FieldEntID, 1256 }) 1257 } 1258 if value, ok := suo.mutation.CoinTypeID(); ok { 1259 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1260 Type: field.TypeUUID, 1261 Value: value, 1262 Column: setting.FieldCoinTypeID, 1263 }) 1264 } 1265 if suo.mutation.CoinTypeIDCleared() { 1266 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1267 Type: field.TypeUUID, 1268 Column: setting.FieldCoinTypeID, 1269 }) 1270 } 1271 if value, ok := suo.mutation.FeeCoinTypeID(); ok { 1272 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1273 Type: field.TypeUUID, 1274 Value: value, 1275 Column: setting.FieldFeeCoinTypeID, 1276 }) 1277 } 1278 if suo.mutation.FeeCoinTypeIDCleared() { 1279 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1280 Type: field.TypeUUID, 1281 Column: setting.FieldFeeCoinTypeID, 1282 }) 1283 } 1284 if value, ok := suo.mutation.WithdrawFeeByStableUsd(); ok { 1285 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1286 Type: field.TypeBool, 1287 Value: value, 1288 Column: setting.FieldWithdrawFeeByStableUsd, 1289 }) 1290 } 1291 if suo.mutation.WithdrawFeeByStableUsdCleared() { 1292 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1293 Type: field.TypeBool, 1294 Column: setting.FieldWithdrawFeeByStableUsd, 1295 }) 1296 } 1297 if value, ok := suo.mutation.WithdrawFeeAmount(); ok { 1298 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1299 Type: field.TypeOther, 1300 Value: value, 1301 Column: setting.FieldWithdrawFeeAmount, 1302 }) 1303 } 1304 if suo.mutation.WithdrawFeeAmountCleared() { 1305 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1306 Type: field.TypeOther, 1307 Column: setting.FieldWithdrawFeeAmount, 1308 }) 1309 } 1310 if value, ok := suo.mutation.CollectFeeAmount(); ok { 1311 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1312 Type: field.TypeOther, 1313 Value: value, 1314 Column: setting.FieldCollectFeeAmount, 1315 }) 1316 } 1317 if suo.mutation.CollectFeeAmountCleared() { 1318 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1319 Type: field.TypeOther, 1320 Column: setting.FieldCollectFeeAmount, 1321 }) 1322 } 1323 if value, ok := suo.mutation.HotWalletFeeAmount(); ok { 1324 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1325 Type: field.TypeOther, 1326 Value: value, 1327 Column: setting.FieldHotWalletFeeAmount, 1328 }) 1329 } 1330 if suo.mutation.HotWalletFeeAmountCleared() { 1331 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1332 Type: field.TypeOther, 1333 Column: setting.FieldHotWalletFeeAmount, 1334 }) 1335 } 1336 if value, ok := suo.mutation.LowFeeAmount(); ok { 1337 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1338 Type: field.TypeOther, 1339 Value: value, 1340 Column: setting.FieldLowFeeAmount, 1341 }) 1342 } 1343 if suo.mutation.LowFeeAmountCleared() { 1344 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1345 Type: field.TypeOther, 1346 Column: setting.FieldLowFeeAmount, 1347 }) 1348 } 1349 if value, ok := suo.mutation.HotLowFeeAmount(); ok { 1350 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1351 Type: field.TypeOther, 1352 Value: value, 1353 Column: setting.FieldHotLowFeeAmount, 1354 }) 1355 } 1356 if suo.mutation.HotLowFeeAmountCleared() { 1357 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1358 Type: field.TypeOther, 1359 Column: setting.FieldHotLowFeeAmount, 1360 }) 1361 } 1362 if value, ok := suo.mutation.HotWalletAccountAmount(); ok { 1363 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1364 Type: field.TypeOther, 1365 Value: value, 1366 Column: setting.FieldHotWalletAccountAmount, 1367 }) 1368 } 1369 if suo.mutation.HotWalletAccountAmountCleared() { 1370 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1371 Type: field.TypeOther, 1372 Column: setting.FieldHotWalletAccountAmount, 1373 }) 1374 } 1375 if value, ok := suo.mutation.PaymentAccountCollectAmount(); ok { 1376 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1377 Type: field.TypeOther, 1378 Value: value, 1379 Column: setting.FieldPaymentAccountCollectAmount, 1380 }) 1381 } 1382 if suo.mutation.PaymentAccountCollectAmountCleared() { 1383 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1384 Type: field.TypeOther, 1385 Column: setting.FieldPaymentAccountCollectAmount, 1386 }) 1387 } 1388 if value, ok := suo.mutation.LeastTransferAmount(); ok { 1389 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1390 Type: field.TypeOther, 1391 Value: value, 1392 Column: setting.FieldLeastTransferAmount, 1393 }) 1394 } 1395 if suo.mutation.LeastTransferAmountCleared() { 1396 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1397 Type: field.TypeOther, 1398 Column: setting.FieldLeastTransferAmount, 1399 }) 1400 } 1401 if value, ok := suo.mutation.NeedMemo(); ok { 1402 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1403 Type: field.TypeBool, 1404 Value: value, 1405 Column: setting.FieldNeedMemo, 1406 }) 1407 } 1408 if suo.mutation.NeedMemoCleared() { 1409 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1410 Type: field.TypeBool, 1411 Column: setting.FieldNeedMemo, 1412 }) 1413 } 1414 if value, ok := suo.mutation.RefreshCurrency(); ok { 1415 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1416 Type: field.TypeBool, 1417 Value: value, 1418 Column: setting.FieldRefreshCurrency, 1419 }) 1420 } 1421 if suo.mutation.RefreshCurrencyCleared() { 1422 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1423 Type: field.TypeBool, 1424 Column: setting.FieldRefreshCurrency, 1425 }) 1426 } 1427 if value, ok := suo.mutation.CheckNewAddressBalance(); ok { 1428 _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ 1429 Type: field.TypeBool, 1430 Value: value, 1431 Column: setting.FieldCheckNewAddressBalance, 1432 }) 1433 } 1434 if suo.mutation.CheckNewAddressBalanceCleared() { 1435 _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ 1436 Type: field.TypeBool, 1437 Column: setting.FieldCheckNewAddressBalance, 1438 }) 1439 } 1440 _spec.Modifiers = suo.modifiers 1441 _node = &Setting{config: suo.config} 1442 _spec.Assign = _node.assignValues 1443 _spec.ScanValues = _node.scanValues 1444 if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil { 1445 if _, ok := err.(*sqlgraph.NotFoundError); ok { 1446 err = &NotFoundError{setting.Label} 1447 } else if sqlgraph.IsConstraintError(err) { 1448 err = &ConstraintError{msg: err.Error(), wrap: err} 1449 } 1450 return nil, err 1451 } 1452 return _node, nil 1453 }