github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/coinbase.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/coinbase" 11 "github.com/google/uuid" 12 "github.com/shopspring/decimal" 13 ) 14 15 // CoinBase is the model entity for the CoinBase schema. 16 type CoinBase 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 // Name holds the value of the "name" field. 29 Name string `json:"name,omitempty"` 30 // Logo holds the value of the "logo" field. 31 Logo string `json:"logo,omitempty"` 32 // Presale holds the value of the "presale" field. 33 Presale bool `json:"presale,omitempty"` 34 // Unit holds the value of the "unit" field. 35 Unit string `json:"unit,omitempty"` 36 // Env holds the value of the "env" field. 37 Env string `json:"env,omitempty"` 38 // ReservedAmount holds the value of the "reserved_amount" field. 39 ReservedAmount decimal.Decimal `json:"reserved_amount,omitempty"` 40 // ForPay holds the value of the "for_pay" field. 41 ForPay bool `json:"for_pay,omitempty"` 42 // Disabled holds the value of the "disabled" field. 43 Disabled bool `json:"disabled,omitempty"` 44 } 45 46 // scanValues returns the types for scanning values from sql.Rows. 47 func (*CoinBase) scanValues(columns []string) ([]interface{}, error) { 48 values := make([]interface{}, len(columns)) 49 for i := range columns { 50 switch columns[i] { 51 case coinbase.FieldReservedAmount: 52 values[i] = new(decimal.Decimal) 53 case coinbase.FieldPresale, coinbase.FieldForPay, coinbase.FieldDisabled: 54 values[i] = new(sql.NullBool) 55 case coinbase.FieldID, coinbase.FieldCreatedAt, coinbase.FieldUpdatedAt, coinbase.FieldDeletedAt: 56 values[i] = new(sql.NullInt64) 57 case coinbase.FieldName, coinbase.FieldLogo, coinbase.FieldUnit, coinbase.FieldEnv: 58 values[i] = new(sql.NullString) 59 case coinbase.FieldEntID: 60 values[i] = new(uuid.UUID) 61 default: 62 return nil, fmt.Errorf("unexpected column %q for type CoinBase", columns[i]) 63 } 64 } 65 return values, nil 66 } 67 68 // assignValues assigns the values that were returned from sql.Rows (after scanning) 69 // to the CoinBase fields. 70 func (cb *CoinBase) assignValues(columns []string, values []interface{}) error { 71 if m, n := len(values), len(columns); m < n { 72 return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) 73 } 74 for i := range columns { 75 switch columns[i] { 76 case coinbase.FieldID: 77 value, ok := values[i].(*sql.NullInt64) 78 if !ok { 79 return fmt.Errorf("unexpected type %T for field id", value) 80 } 81 cb.ID = uint32(value.Int64) 82 case coinbase.FieldCreatedAt: 83 if value, ok := values[i].(*sql.NullInt64); !ok { 84 return fmt.Errorf("unexpected type %T for field created_at", values[i]) 85 } else if value.Valid { 86 cb.CreatedAt = uint32(value.Int64) 87 } 88 case coinbase.FieldUpdatedAt: 89 if value, ok := values[i].(*sql.NullInt64); !ok { 90 return fmt.Errorf("unexpected type %T for field updated_at", values[i]) 91 } else if value.Valid { 92 cb.UpdatedAt = uint32(value.Int64) 93 } 94 case coinbase.FieldDeletedAt: 95 if value, ok := values[i].(*sql.NullInt64); !ok { 96 return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) 97 } else if value.Valid { 98 cb.DeletedAt = uint32(value.Int64) 99 } 100 case coinbase.FieldEntID: 101 if value, ok := values[i].(*uuid.UUID); !ok { 102 return fmt.Errorf("unexpected type %T for field ent_id", values[i]) 103 } else if value != nil { 104 cb.EntID = *value 105 } 106 case coinbase.FieldName: 107 if value, ok := values[i].(*sql.NullString); !ok { 108 return fmt.Errorf("unexpected type %T for field name", values[i]) 109 } else if value.Valid { 110 cb.Name = value.String 111 } 112 case coinbase.FieldLogo: 113 if value, ok := values[i].(*sql.NullString); !ok { 114 return fmt.Errorf("unexpected type %T for field logo", values[i]) 115 } else if value.Valid { 116 cb.Logo = value.String 117 } 118 case coinbase.FieldPresale: 119 if value, ok := values[i].(*sql.NullBool); !ok { 120 return fmt.Errorf("unexpected type %T for field presale", values[i]) 121 } else if value.Valid { 122 cb.Presale = value.Bool 123 } 124 case coinbase.FieldUnit: 125 if value, ok := values[i].(*sql.NullString); !ok { 126 return fmt.Errorf("unexpected type %T for field unit", values[i]) 127 } else if value.Valid { 128 cb.Unit = value.String 129 } 130 case coinbase.FieldEnv: 131 if value, ok := values[i].(*sql.NullString); !ok { 132 return fmt.Errorf("unexpected type %T for field env", values[i]) 133 } else if value.Valid { 134 cb.Env = value.String 135 } 136 case coinbase.FieldReservedAmount: 137 if value, ok := values[i].(*decimal.Decimal); !ok { 138 return fmt.Errorf("unexpected type %T for field reserved_amount", values[i]) 139 } else if value != nil { 140 cb.ReservedAmount = *value 141 } 142 case coinbase.FieldForPay: 143 if value, ok := values[i].(*sql.NullBool); !ok { 144 return fmt.Errorf("unexpected type %T for field for_pay", values[i]) 145 } else if value.Valid { 146 cb.ForPay = value.Bool 147 } 148 case coinbase.FieldDisabled: 149 if value, ok := values[i].(*sql.NullBool); !ok { 150 return fmt.Errorf("unexpected type %T for field disabled", values[i]) 151 } else if value.Valid { 152 cb.Disabled = value.Bool 153 } 154 } 155 } 156 return nil 157 } 158 159 // Update returns a builder for updating this CoinBase. 160 // Note that you need to call CoinBase.Unwrap() before calling this method if this CoinBase 161 // was returned from a transaction, and the transaction was committed or rolled back. 162 func (cb *CoinBase) Update() *CoinBaseUpdateOne { 163 return (&CoinBaseClient{config: cb.config}).UpdateOne(cb) 164 } 165 166 // Unwrap unwraps the CoinBase entity that was returned from a transaction after it was closed, 167 // so that all future queries will be executed through the driver which created the transaction. 168 func (cb *CoinBase) Unwrap() *CoinBase { 169 _tx, ok := cb.config.driver.(*txDriver) 170 if !ok { 171 panic("ent: CoinBase is not a transactional entity") 172 } 173 cb.config.driver = _tx.drv 174 return cb 175 } 176 177 // String implements the fmt.Stringer. 178 func (cb *CoinBase) String() string { 179 var builder strings.Builder 180 builder.WriteString("CoinBase(") 181 builder.WriteString(fmt.Sprintf("id=%v, ", cb.ID)) 182 builder.WriteString("created_at=") 183 builder.WriteString(fmt.Sprintf("%v", cb.CreatedAt)) 184 builder.WriteString(", ") 185 builder.WriteString("updated_at=") 186 builder.WriteString(fmt.Sprintf("%v", cb.UpdatedAt)) 187 builder.WriteString(", ") 188 builder.WriteString("deleted_at=") 189 builder.WriteString(fmt.Sprintf("%v", cb.DeletedAt)) 190 builder.WriteString(", ") 191 builder.WriteString("ent_id=") 192 builder.WriteString(fmt.Sprintf("%v", cb.EntID)) 193 builder.WriteString(", ") 194 builder.WriteString("name=") 195 builder.WriteString(cb.Name) 196 builder.WriteString(", ") 197 builder.WriteString("logo=") 198 builder.WriteString(cb.Logo) 199 builder.WriteString(", ") 200 builder.WriteString("presale=") 201 builder.WriteString(fmt.Sprintf("%v", cb.Presale)) 202 builder.WriteString(", ") 203 builder.WriteString("unit=") 204 builder.WriteString(cb.Unit) 205 builder.WriteString(", ") 206 builder.WriteString("env=") 207 builder.WriteString(cb.Env) 208 builder.WriteString(", ") 209 builder.WriteString("reserved_amount=") 210 builder.WriteString(fmt.Sprintf("%v", cb.ReservedAmount)) 211 builder.WriteString(", ") 212 builder.WriteString("for_pay=") 213 builder.WriteString(fmt.Sprintf("%v", cb.ForPay)) 214 builder.WriteString(", ") 215 builder.WriteString("disabled=") 216 builder.WriteString(fmt.Sprintf("%v", cb.Disabled)) 217 builder.WriteByte(')') 218 return builder.String() 219 } 220 221 // CoinBases is a parsable slice of CoinBase. 222 type CoinBases []*CoinBase 223 224 func (cb CoinBases) config(cfg config) { 225 for _i := range cb { 226 cb[_i].config = cfg 227 } 228 }