github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/setting.go (about)

     1  // Code generated by ent, DO NOT EDIT.
     2  
     3  package ent
     4  
     5  import (
     6  	"fmt"
     7  	"strings"
     8  
     9  	"entgo.io/ent/dialect/sql"
    10  	"github.com/NpoolPlatform/chain-middleware/pkg/db/ent/setting"
    11  	"github.com/google/uuid"
    12  	"github.com/shopspring/decimal"
    13  )
    14  
    15  // Setting is the model entity for the Setting schema.
    16  type Setting struct {
    17  	config `json:"-"`
    18  	// ID of the ent.
    19  	ID uint32 `json:"id,omitempty"`
    20  	// CreatedAt holds the value of the "created_at" field.
    21  	CreatedAt uint32 `json:"created_at,omitempty"`
    22  	// UpdatedAt holds the value of the "updated_at" field.
    23  	UpdatedAt uint32 `json:"updated_at,omitempty"`
    24  	// DeletedAt holds the value of the "deleted_at" field.
    25  	DeletedAt uint32 `json:"deleted_at,omitempty"`
    26  	// EntID holds the value of the "ent_id" field.
    27  	EntID uuid.UUID `json:"ent_id,omitempty"`
    28  	// CoinTypeID holds the value of the "coin_type_id" field.
    29  	CoinTypeID uuid.UUID `json:"coin_type_id,omitempty"`
    30  	// FeeCoinTypeID holds the value of the "fee_coin_type_id" field.
    31  	FeeCoinTypeID uuid.UUID `json:"fee_coin_type_id,omitempty"`
    32  	// WithdrawFeeByStableUsd holds the value of the "withdraw_fee_by_stable_usd" field.
    33  	WithdrawFeeByStableUsd bool `json:"withdraw_fee_by_stable_usd,omitempty"`
    34  	// WithdrawFeeAmount holds the value of the "withdraw_fee_amount" field.
    35  	WithdrawFeeAmount decimal.Decimal `json:"withdraw_fee_amount,omitempty"`
    36  	// CollectFeeAmount holds the value of the "collect_fee_amount" field.
    37  	CollectFeeAmount decimal.Decimal `json:"collect_fee_amount,omitempty"`
    38  	// HotWalletFeeAmount holds the value of the "hot_wallet_fee_amount" field.
    39  	HotWalletFeeAmount decimal.Decimal `json:"hot_wallet_fee_amount,omitempty"`
    40  	// LowFeeAmount holds the value of the "low_fee_amount" field.
    41  	LowFeeAmount decimal.Decimal `json:"low_fee_amount,omitempty"`
    42  	// HotLowFeeAmount holds the value of the "hot_low_fee_amount" field.
    43  	HotLowFeeAmount decimal.Decimal `json:"hot_low_fee_amount,omitempty"`
    44  	// HotWalletAccountAmount holds the value of the "hot_wallet_account_amount" field.
    45  	HotWalletAccountAmount decimal.Decimal `json:"hot_wallet_account_amount,omitempty"`
    46  	// PaymentAccountCollectAmount holds the value of the "payment_account_collect_amount" field.
    47  	PaymentAccountCollectAmount decimal.Decimal `json:"payment_account_collect_amount,omitempty"`
    48  	// LeastTransferAmount holds the value of the "least_transfer_amount" field.
    49  	LeastTransferAmount decimal.Decimal `json:"least_transfer_amount,omitempty"`
    50  	// NeedMemo holds the value of the "need_memo" field.
    51  	NeedMemo bool `json:"need_memo,omitempty"`
    52  	// RefreshCurrency holds the value of the "refresh_currency" field.
    53  	RefreshCurrency bool `json:"refresh_currency,omitempty"`
    54  	// CheckNewAddressBalance holds the value of the "check_new_address_balance" field.
    55  	CheckNewAddressBalance bool `json:"check_new_address_balance,omitempty"`
    56  }
    57  
    58  // scanValues returns the types for scanning values from sql.Rows.
    59  func (*Setting) scanValues(columns []string) ([]interface{}, error) {
    60  	values := make([]interface{}, len(columns))
    61  	for i := range columns {
    62  		switch columns[i] {
    63  		case setting.FieldWithdrawFeeAmount, setting.FieldCollectFeeAmount, setting.FieldHotWalletFeeAmount, setting.FieldLowFeeAmount, setting.FieldHotLowFeeAmount, setting.FieldHotWalletAccountAmount, setting.FieldPaymentAccountCollectAmount, setting.FieldLeastTransferAmount:
    64  			values[i] = new(decimal.Decimal)
    65  		case setting.FieldWithdrawFeeByStableUsd, setting.FieldNeedMemo, setting.FieldRefreshCurrency, setting.FieldCheckNewAddressBalance:
    66  			values[i] = new(sql.NullBool)
    67  		case setting.FieldID, setting.FieldCreatedAt, setting.FieldUpdatedAt, setting.FieldDeletedAt:
    68  			values[i] = new(sql.NullInt64)
    69  		case setting.FieldEntID, setting.FieldCoinTypeID, setting.FieldFeeCoinTypeID:
    70  			values[i] = new(uuid.UUID)
    71  		default:
    72  			return nil, fmt.Errorf("unexpected column %q for type Setting", columns[i])
    73  		}
    74  	}
    75  	return values, nil
    76  }
    77  
    78  // assignValues assigns the values that were returned from sql.Rows (after scanning)
    79  // to the Setting fields.
    80  func (s *Setting) assignValues(columns []string, values []interface{}) error {
    81  	if m, n := len(values), len(columns); m < n {
    82  		return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
    83  	}
    84  	for i := range columns {
    85  		switch columns[i] {
    86  		case setting.FieldID:
    87  			value, ok := values[i].(*sql.NullInt64)
    88  			if !ok {
    89  				return fmt.Errorf("unexpected type %T for field id", value)
    90  			}
    91  			s.ID = uint32(value.Int64)
    92  		case setting.FieldCreatedAt:
    93  			if value, ok := values[i].(*sql.NullInt64); !ok {
    94  				return fmt.Errorf("unexpected type %T for field created_at", values[i])
    95  			} else if value.Valid {
    96  				s.CreatedAt = uint32(value.Int64)
    97  			}
    98  		case setting.FieldUpdatedAt:
    99  			if value, ok := values[i].(*sql.NullInt64); !ok {
   100  				return fmt.Errorf("unexpected type %T for field updated_at", values[i])
   101  			} else if value.Valid {
   102  				s.UpdatedAt = uint32(value.Int64)
   103  			}
   104  		case setting.FieldDeletedAt:
   105  			if value, ok := values[i].(*sql.NullInt64); !ok {
   106  				return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
   107  			} else if value.Valid {
   108  				s.DeletedAt = uint32(value.Int64)
   109  			}
   110  		case setting.FieldEntID:
   111  			if value, ok := values[i].(*uuid.UUID); !ok {
   112  				return fmt.Errorf("unexpected type %T for field ent_id", values[i])
   113  			} else if value != nil {
   114  				s.EntID = *value
   115  			}
   116  		case setting.FieldCoinTypeID:
   117  			if value, ok := values[i].(*uuid.UUID); !ok {
   118  				return fmt.Errorf("unexpected type %T for field coin_type_id", values[i])
   119  			} else if value != nil {
   120  				s.CoinTypeID = *value
   121  			}
   122  		case setting.FieldFeeCoinTypeID:
   123  			if value, ok := values[i].(*uuid.UUID); !ok {
   124  				return fmt.Errorf("unexpected type %T for field fee_coin_type_id", values[i])
   125  			} else if value != nil {
   126  				s.FeeCoinTypeID = *value
   127  			}
   128  		case setting.FieldWithdrawFeeByStableUsd:
   129  			if value, ok := values[i].(*sql.NullBool); !ok {
   130  				return fmt.Errorf("unexpected type %T for field withdraw_fee_by_stable_usd", values[i])
   131  			} else if value.Valid {
   132  				s.WithdrawFeeByStableUsd = value.Bool
   133  			}
   134  		case setting.FieldWithdrawFeeAmount:
   135  			if value, ok := values[i].(*decimal.Decimal); !ok {
   136  				return fmt.Errorf("unexpected type %T for field withdraw_fee_amount", values[i])
   137  			} else if value != nil {
   138  				s.WithdrawFeeAmount = *value
   139  			}
   140  		case setting.FieldCollectFeeAmount:
   141  			if value, ok := values[i].(*decimal.Decimal); !ok {
   142  				return fmt.Errorf("unexpected type %T for field collect_fee_amount", values[i])
   143  			} else if value != nil {
   144  				s.CollectFeeAmount = *value
   145  			}
   146  		case setting.FieldHotWalletFeeAmount:
   147  			if value, ok := values[i].(*decimal.Decimal); !ok {
   148  				return fmt.Errorf("unexpected type %T for field hot_wallet_fee_amount", values[i])
   149  			} else if value != nil {
   150  				s.HotWalletFeeAmount = *value
   151  			}
   152  		case setting.FieldLowFeeAmount:
   153  			if value, ok := values[i].(*decimal.Decimal); !ok {
   154  				return fmt.Errorf("unexpected type %T for field low_fee_amount", values[i])
   155  			} else if value != nil {
   156  				s.LowFeeAmount = *value
   157  			}
   158  		case setting.FieldHotLowFeeAmount:
   159  			if value, ok := values[i].(*decimal.Decimal); !ok {
   160  				return fmt.Errorf("unexpected type %T for field hot_low_fee_amount", values[i])
   161  			} else if value != nil {
   162  				s.HotLowFeeAmount = *value
   163  			}
   164  		case setting.FieldHotWalletAccountAmount:
   165  			if value, ok := values[i].(*decimal.Decimal); !ok {
   166  				return fmt.Errorf("unexpected type %T for field hot_wallet_account_amount", values[i])
   167  			} else if value != nil {
   168  				s.HotWalletAccountAmount = *value
   169  			}
   170  		case setting.FieldPaymentAccountCollectAmount:
   171  			if value, ok := values[i].(*decimal.Decimal); !ok {
   172  				return fmt.Errorf("unexpected type %T for field payment_account_collect_amount", values[i])
   173  			} else if value != nil {
   174  				s.PaymentAccountCollectAmount = *value
   175  			}
   176  		case setting.FieldLeastTransferAmount:
   177  			if value, ok := values[i].(*decimal.Decimal); !ok {
   178  				return fmt.Errorf("unexpected type %T for field least_transfer_amount", values[i])
   179  			} else if value != nil {
   180  				s.LeastTransferAmount = *value
   181  			}
   182  		case setting.FieldNeedMemo:
   183  			if value, ok := values[i].(*sql.NullBool); !ok {
   184  				return fmt.Errorf("unexpected type %T for field need_memo", values[i])
   185  			} else if value.Valid {
   186  				s.NeedMemo = value.Bool
   187  			}
   188  		case setting.FieldRefreshCurrency:
   189  			if value, ok := values[i].(*sql.NullBool); !ok {
   190  				return fmt.Errorf("unexpected type %T for field refresh_currency", values[i])
   191  			} else if value.Valid {
   192  				s.RefreshCurrency = value.Bool
   193  			}
   194  		case setting.FieldCheckNewAddressBalance:
   195  			if value, ok := values[i].(*sql.NullBool); !ok {
   196  				return fmt.Errorf("unexpected type %T for field check_new_address_balance", values[i])
   197  			} else if value.Valid {
   198  				s.CheckNewAddressBalance = value.Bool
   199  			}
   200  		}
   201  	}
   202  	return nil
   203  }
   204  
   205  // Update returns a builder for updating this Setting.
   206  // Note that you need to call Setting.Unwrap() before calling this method if this Setting
   207  // was returned from a transaction, and the transaction was committed or rolled back.
   208  func (s *Setting) Update() *SettingUpdateOne {
   209  	return (&SettingClient{config: s.config}).UpdateOne(s)
   210  }
   211  
   212  // Unwrap unwraps the Setting entity that was returned from a transaction after it was closed,
   213  // so that all future queries will be executed through the driver which created the transaction.
   214  func (s *Setting) Unwrap() *Setting {
   215  	_tx, ok := s.config.driver.(*txDriver)
   216  	if !ok {
   217  		panic("ent: Setting is not a transactional entity")
   218  	}
   219  	s.config.driver = _tx.drv
   220  	return s
   221  }
   222  
   223  // String implements the fmt.Stringer.
   224  func (s *Setting) String() string {
   225  	var builder strings.Builder
   226  	builder.WriteString("Setting(")
   227  	builder.WriteString(fmt.Sprintf("id=%v, ", s.ID))
   228  	builder.WriteString("created_at=")
   229  	builder.WriteString(fmt.Sprintf("%v", s.CreatedAt))
   230  	builder.WriteString(", ")
   231  	builder.WriteString("updated_at=")
   232  	builder.WriteString(fmt.Sprintf("%v", s.UpdatedAt))
   233  	builder.WriteString(", ")
   234  	builder.WriteString("deleted_at=")
   235  	builder.WriteString(fmt.Sprintf("%v", s.DeletedAt))
   236  	builder.WriteString(", ")
   237  	builder.WriteString("ent_id=")
   238  	builder.WriteString(fmt.Sprintf("%v", s.EntID))
   239  	builder.WriteString(", ")
   240  	builder.WriteString("coin_type_id=")
   241  	builder.WriteString(fmt.Sprintf("%v", s.CoinTypeID))
   242  	builder.WriteString(", ")
   243  	builder.WriteString("fee_coin_type_id=")
   244  	builder.WriteString(fmt.Sprintf("%v", s.FeeCoinTypeID))
   245  	builder.WriteString(", ")
   246  	builder.WriteString("withdraw_fee_by_stable_usd=")
   247  	builder.WriteString(fmt.Sprintf("%v", s.WithdrawFeeByStableUsd))
   248  	builder.WriteString(", ")
   249  	builder.WriteString("withdraw_fee_amount=")
   250  	builder.WriteString(fmt.Sprintf("%v", s.WithdrawFeeAmount))
   251  	builder.WriteString(", ")
   252  	builder.WriteString("collect_fee_amount=")
   253  	builder.WriteString(fmt.Sprintf("%v", s.CollectFeeAmount))
   254  	builder.WriteString(", ")
   255  	builder.WriteString("hot_wallet_fee_amount=")
   256  	builder.WriteString(fmt.Sprintf("%v", s.HotWalletFeeAmount))
   257  	builder.WriteString(", ")
   258  	builder.WriteString("low_fee_amount=")
   259  	builder.WriteString(fmt.Sprintf("%v", s.LowFeeAmount))
   260  	builder.WriteString(", ")
   261  	builder.WriteString("hot_low_fee_amount=")
   262  	builder.WriteString(fmt.Sprintf("%v", s.HotLowFeeAmount))
   263  	builder.WriteString(", ")
   264  	builder.WriteString("hot_wallet_account_amount=")
   265  	builder.WriteString(fmt.Sprintf("%v", s.HotWalletAccountAmount))
   266  	builder.WriteString(", ")
   267  	builder.WriteString("payment_account_collect_amount=")
   268  	builder.WriteString(fmt.Sprintf("%v", s.PaymentAccountCollectAmount))
   269  	builder.WriteString(", ")
   270  	builder.WriteString("least_transfer_amount=")
   271  	builder.WriteString(fmt.Sprintf("%v", s.LeastTransferAmount))
   272  	builder.WriteString(", ")
   273  	builder.WriteString("need_memo=")
   274  	builder.WriteString(fmt.Sprintf("%v", s.NeedMemo))
   275  	builder.WriteString(", ")
   276  	builder.WriteString("refresh_currency=")
   277  	builder.WriteString(fmt.Sprintf("%v", s.RefreshCurrency))
   278  	builder.WriteString(", ")
   279  	builder.WriteString("check_new_address_balance=")
   280  	builder.WriteString(fmt.Sprintf("%v", s.CheckNewAddressBalance))
   281  	builder.WriteByte(')')
   282  	return builder.String()
   283  }
   284  
   285  // Settings is a parsable slice of Setting.
   286  type Settings []*Setting
   287  
   288  func (s Settings) config(cfg config) {
   289  	for _i := range s {
   290  		s[_i].config = cfg
   291  	}
   292  }