github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/schema/exchangerate.go (about) 1 package schema 2 3 import ( 4 "entgo.io/ent" 5 "entgo.io/ent/dialect" 6 "entgo.io/ent/schema/field" 7 "github.com/NpoolPlatform/chain-middleware/pkg/db/mixin" 8 crudermixin "github.com/NpoolPlatform/libent-cruder/pkg/mixin" 9 "github.com/google/uuid" 10 "github.com/shopspring/decimal" 11 ) 12 13 // ExchangeRate holds the schema definition for the ExchangeRate entity. 14 type ExchangeRate struct { 15 ent.Schema 16 } 17 18 func (ExchangeRate) Mixin() []ent.Mixin { 19 return []ent.Mixin{ 20 mixin.TimeMixin{}, 21 crudermixin.AutoIDMixin{}, 22 } 23 } 24 25 // Fields of the ExchangeRate. 26 func (ExchangeRate) Fields() []ent.Field { 27 return []ent.Field{ 28 field. 29 UUID("app_id", uuid.UUID{}). 30 Optional(). 31 Default(uuid.New), 32 field. 33 UUID("coin_type_id", uuid.UUID{}). 34 Optional(). 35 Default(uuid.New), 36 field. 37 Other("market_value", decimal.Decimal{}). 38 SchemaType(map[string]string{ 39 dialect.MySQL: "decimal(37,18)", 40 }). 41 Optional(). 42 Default(decimal.Decimal{}), 43 field. 44 Other("settle_value", decimal.Decimal{}). 45 SchemaType(map[string]string{ 46 dialect.MySQL: "decimal(37,18)", 47 }). 48 Optional(). 49 Default(decimal.Decimal{}), 50 field. 51 Uint32("settle_percent"). 52 Optional(). 53 Default(100), // nolint 54 field. 55 JSON("settle_tips", []string{}). 56 Optional(). 57 Default([]string{}), 58 field. 59 UUID("setter", uuid.UUID{}). 60 Optional(). 61 Default(uuid.New), 62 } 63 } 64 65 // Edges of the ExchangeRate. 66 func (ExchangeRate) Edges() []ent.Edge { 67 return nil 68 }