123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487 |
- package models
- import (
- "database/sql"
- "time"
- "github.com/google/uuid"
- "github.com/guregu/null"
- "gorm.io/gorm"
- )
- var (
- _ = time.Second
- _ = sql.LevelDefault
- _ = null.Bool{}
- _ = uuid.UUID{}
- )
- /*
- DB Table Details
- -------------------------------------
- CREATE TABLE `sale` (
- `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
- `token_id` bigint(20) unsigned NOT NULL,
- `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- `deleted_at` timestamp NULL DEFAULT NULL,
- `is_resale` tinyint(4) NOT NULL DEFAULT '0',
- `sale_type` enum('fixed','auction','time') COLLATE utf8mb4_bin NOT NULL,
- `price` double DEFAULT NULL,
- `start_price` double DEFAULT NULL,
- `start_at` timestamp NULL DEFAULT NULL,
- `end_at` timestamp NULL DEFAULT NULL,
- `uid` varchar(256) COLLATE utf8mb4_bin NOT NULL,
- `currency` enum('eth','mr','mf') COLLATE utf8mb4_bin NOT NULL,
- `status` enum('ongoing','end','cancel') COLLATE utf8mb4_bin NOT NULL COMMENT 'Ongoing\nEnd: 판매가 일어나서 정상 종료(트랜잭션 발생)\nCancel: 판매자가 취소하는 케이스! 판매하지 않고 판매만 종료(트랜잭션 미발생)\n',
- `hash_data` varchar(256) COLLATE utf8mb4_bin NOT NULL,
- `signature` varchar(256) COLLATE utf8mb4_bin NOT NULL,
- `treasury_tax` double NOT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `id_UNIQUE` (`id`),
- KEY `fk_sale_token1_idx` (`token_id`),
- CONSTRAINT `fk_sale_token1` FOREIGN KEY (`token_id`) REFERENCES `token` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
- ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
- JSON Sample
- -------------------------------------
- { "id": 79, "token_id": 77, "created_at": "2036-06-23T08:15:03.681534345+09:00", "updated_at": "2079-01-07T21:39:30.415341036+09:00", "deleted_at": "2311-01-12T15:25:40.427122699+09:00", "is_resale": 75, "sale_type": "LibImOuHvBkYvBlKhLaNiwVgZ", "price": 0.3331036926143512, "start_price": 0.37895024299401436, "start_at": "2219-06-08T06:32:54.134481296+09:00", "end_at": "2268-04-08T16:03:30.525325274+09:00", "uid": "PcxGvDbIOCRVcXXUVRpLjSCfd", "currency": "OuflBMihymHxsAmyJCESpMGGY", "status": "iJqTALvdjLiwOQSHVZayHZEYX", "hash_data": "QZnBmYfxODbqpkKcMkDmoeddr", "signature": "JxMcSsMLMyVHUcpKxRGwNLlJL", "treasury_tax": 0.7619896885043733}
- Comments
- -------------------------------------
- [ 0] column is set for unsigned
- [ 1] column is set for unsigned
- */
- // Sale struct is a row record of the sale table in the metarare database
- type Sale struct {
- //[ 0] id ubigint null: false primary: true isArray: false auto: true col: ubigint len: -1 default: []
- ID uint64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:ubigint;" json:"id"`
- //[ 1] token_id ubigint null: false primary: false isArray: false auto: false col: ubigint len: -1 default: []
- TokenID uint64 `gorm:"column:token_id;type:ubigint;" json:"token_id"`
- //[ 2] created_at timestamp null: false primary: false isArray: false auto: false col: timestamp len: -1 default: [CURRENT_TIMESTAMP]
- CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:CURRENT_TIMESTAMP;" json:"created_at"`
- //[ 3] updated_at timestamp null: false primary: false isArray: false auto: false col: timestamp len: -1 default: [CURRENT_TIMESTAMP]
- UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:CURRENT_TIMESTAMP;" json:"updated_at"`
- //[ 4] deleted_at timestamp null: true primary: false isArray: false auto: false col: timestamp len: -1 default: []
- DeletedAt null.Time `gorm:"column:deleted_at;type:timestamp;" json:"deleted_at"`
- //[ 5] is_resale tinyint null: false primary: false isArray: false auto: false col: tinyint len: -1 default: [0]
- IsResale int32 `gorm:"column:is_resale;type:tinyint;default:0;" json:"is_resale"`
- //[ 6] sale_type char(7) null: false primary: false isArray: false auto: false col: char len: 7 default: []
- SaleType string `gorm:"column:sale_type;type:char;size:7;" json:"sale_type"`
- //[ 7] price double null: true primary: false isArray: false auto: false col: double len: -1 default: []
- Price null.Float `gorm:"column:price;type:double;" json:"price"`
- //[ 8] start_price double null: true primary: false isArray: false auto: false col: double len: -1 default: []
- StartPrice null.Float `gorm:"column:start_price;type:double;" json:"start_price"`
- //[ 9] start_at timestamp null: true primary: false isArray: false auto: false col: timestamp len: -1 default: []
- StartAt null.Time `gorm:"column:start_at;type:timestamp;" json:"start_at"`
- //[10] end_at timestamp null: true primary: false isArray: false auto: false col: timestamp len: -1 default: []
- EndAt null.Time `gorm:"column:end_at;type:timestamp;" json:"end_at"`
- //[11] uid varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: []
- UID string `gorm:"column:uid;type:varchar;size:256;" json:"uid"`
- //[12] currency char(3) null: false primary: false isArray: false auto: false col: char len: 3 default: []
- Currency string `gorm:"column:currency;type:char;size:3;" json:"currency"`
- //[13] status char(7) null: false primary: false isArray: false auto: false col: char len: 7 default: []
- Status string `gorm:"column:status;type:char;size:7;" json:"status"` // Ongoing\nEnd: 판매가 일어나서 정상 종료(트랜잭션 발생)\nCancel: 판매자가 취소하는 케이스! 판매하지 않고 판매만 종료(트랜잭션 미발생)\n
- //[14] hash_data varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: []
- HashData string `gorm:"column:hash_data;type:varchar;size:256;" json:"hash_data"`
- //[15] signature varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: []
- Signature string `gorm:"column:signature;type:varchar;size:256;" json:"signature"`
- //[16] treasury_tax double null: false primary: false isArray: false auto: false col: double len: -1 default: []
- TreasuryTax float64 `gorm:"column:treasury_tax;type:double;" json:"treasury_tax"`
- Token Token
- BidLog BidLog
- }
- var saleTableInfo = &TableInfo{
- Name: "sale",
- Columns: []*ColumnInfo{
- &ColumnInfo{
- Index: 0,
- Name: "id",
- Comment: ``,
- Notes: `column is set for unsigned`,
- Nullable: false,
- DatabaseTypeName: "ubigint",
- DatabaseTypePretty: "ubigint",
- IsPrimaryKey: true,
- IsAutoIncrement: true,
- IsArray: false,
- ColumnType: "ubigint",
- ColumnLength: -1,
- GoFieldName: "ID",
- GoFieldType: "uint64",
- JSONFieldName: "id",
- ProtobufFieldName: "id",
- ProtobufType: "uint64",
- ProtobufPos: 1,
- },
- &ColumnInfo{
- Index: 1,
- Name: "token_id",
- Comment: ``,
- Notes: `column is set for unsigned`,
- Nullable: false,
- DatabaseTypeName: "ubigint",
- DatabaseTypePretty: "ubigint",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "ubigint",
- ColumnLength: -1,
- GoFieldName: "TokenID",
- GoFieldType: "uint64",
- JSONFieldName: "token_id",
- ProtobufFieldName: "token_id",
- ProtobufType: "uint64",
- ProtobufPos: 2,
- },
- &ColumnInfo{
- Index: 2,
- Name: "created_at",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "timestamp",
- DatabaseTypePretty: "timestamp",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "timestamp",
- ColumnLength: -1,
- GoFieldName: "CreatedAt",
- GoFieldType: "time.Time",
- JSONFieldName: "created_at",
- ProtobufFieldName: "created_at",
- ProtobufType: "uint64",
- ProtobufPos: 3,
- },
- &ColumnInfo{
- Index: 3,
- Name: "updated_at",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "timestamp",
- DatabaseTypePretty: "timestamp",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "timestamp",
- ColumnLength: -1,
- GoFieldName: "UpdatedAt",
- GoFieldType: "time.Time",
- JSONFieldName: "updated_at",
- ProtobufFieldName: "updated_at",
- ProtobufType: "uint64",
- ProtobufPos: 4,
- },
- &ColumnInfo{
- Index: 4,
- Name: "deleted_at",
- Comment: ``,
- Notes: ``,
- Nullable: true,
- DatabaseTypeName: "timestamp",
- DatabaseTypePretty: "timestamp",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "timestamp",
- ColumnLength: -1,
- GoFieldName: "DeletedAt",
- GoFieldType: "null.Time",
- JSONFieldName: "deleted_at",
- ProtobufFieldName: "deleted_at",
- ProtobufType: "uint64",
- ProtobufPos: 5,
- },
- &ColumnInfo{
- Index: 5,
- Name: "is_resale",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "tinyint",
- DatabaseTypePretty: "tinyint",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "tinyint",
- ColumnLength: -1,
- GoFieldName: "IsResale",
- GoFieldType: "int32",
- JSONFieldName: "is_resale",
- ProtobufFieldName: "is_resale",
- ProtobufType: "int32",
- ProtobufPos: 6,
- },
- &ColumnInfo{
- Index: 6,
- Name: "sale_type",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "char",
- DatabaseTypePretty: "char(7)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "char",
- ColumnLength: 7,
- GoFieldName: "SaleType",
- GoFieldType: "string",
- JSONFieldName: "sale_type",
- ProtobufFieldName: "sale_type",
- ProtobufType: "string",
- ProtobufPos: 7,
- },
- &ColumnInfo{
- Index: 7,
- Name: "price",
- Comment: ``,
- Notes: ``,
- Nullable: true,
- DatabaseTypeName: "double",
- DatabaseTypePretty: "double",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "double",
- ColumnLength: -1,
- GoFieldName: "Price",
- GoFieldType: "null.Float",
- JSONFieldName: "price",
- ProtobufFieldName: "price",
- ProtobufType: "float",
- ProtobufPos: 8,
- },
- &ColumnInfo{
- Index: 8,
- Name: "start_price",
- Comment: ``,
- Notes: ``,
- Nullable: true,
- DatabaseTypeName: "double",
- DatabaseTypePretty: "double",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "double",
- ColumnLength: -1,
- GoFieldName: "StartPrice",
- GoFieldType: "null.Float",
- JSONFieldName: "start_price",
- ProtobufFieldName: "start_price",
- ProtobufType: "float",
- ProtobufPos: 9,
- },
- &ColumnInfo{
- Index: 9,
- Name: "start_at",
- Comment: ``,
- Notes: ``,
- Nullable: true,
- DatabaseTypeName: "timestamp",
- DatabaseTypePretty: "timestamp",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "timestamp",
- ColumnLength: -1,
- GoFieldName: "StartAt",
- GoFieldType: "null.Time",
- JSONFieldName: "start_at",
- ProtobufFieldName: "start_at",
- ProtobufType: "uint64",
- ProtobufPos: 10,
- },
- &ColumnInfo{
- Index: 10,
- Name: "end_at",
- Comment: ``,
- Notes: ``,
- Nullable: true,
- DatabaseTypeName: "timestamp",
- DatabaseTypePretty: "timestamp",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "timestamp",
- ColumnLength: -1,
- GoFieldName: "EndAt",
- GoFieldType: "null.Time",
- JSONFieldName: "end_at",
- ProtobufFieldName: "end_at",
- ProtobufType: "uint64",
- ProtobufPos: 11,
- },
- &ColumnInfo{
- Index: 11,
- Name: "uid",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "varchar",
- DatabaseTypePretty: "varchar(256)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "varchar",
- ColumnLength: 256,
- GoFieldName: "UID",
- GoFieldType: "string",
- JSONFieldName: "uid",
- ProtobufFieldName: "uid",
- ProtobufType: "string",
- ProtobufPos: 12,
- },
- &ColumnInfo{
- Index: 12,
- Name: "currency",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "char",
- DatabaseTypePretty: "char(3)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "char",
- ColumnLength: 3,
- GoFieldName: "Currency",
- GoFieldType: "string",
- JSONFieldName: "currency",
- ProtobufFieldName: "currency",
- ProtobufType: "string",
- ProtobufPos: 13,
- },
- &ColumnInfo{
- Index: 13,
- Name: "status",
- Comment: `Ongoing\nEnd: 판매가 일어나서 정상 종료(트랜잭션 발생)\nCancel: 판매자가 취소하는 케이스! 판매하지 않고 판매만 종료(트랜잭션 미발생)\n`,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "char",
- DatabaseTypePretty: "char(7)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "char",
- ColumnLength: 7,
- GoFieldName: "Status",
- GoFieldType: "string",
- JSONFieldName: "status",
- ProtobufFieldName: "status",
- ProtobufType: "string",
- ProtobufPos: 14,
- },
- &ColumnInfo{
- Index: 14,
- Name: "hash_data",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "varchar",
- DatabaseTypePretty: "varchar(256)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "varchar",
- ColumnLength: 256,
- GoFieldName: "HashData",
- GoFieldType: "string",
- JSONFieldName: "hash_data",
- ProtobufFieldName: "hash_data",
- ProtobufType: "string",
- ProtobufPos: 15,
- },
- &ColumnInfo{
- Index: 15,
- Name: "signature",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "varchar",
- DatabaseTypePretty: "varchar(256)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "varchar",
- ColumnLength: 256,
- GoFieldName: "Signature",
- GoFieldType: "string",
- JSONFieldName: "signature",
- ProtobufFieldName: "signature",
- ProtobufType: "string",
- ProtobufPos: 16,
- },
- &ColumnInfo{
- Index: 16,
- Name: "treasury_tax",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "double",
- DatabaseTypePretty: "double",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "double",
- ColumnLength: -1,
- GoFieldName: "TreasuryTax",
- GoFieldType: "float64",
- JSONFieldName: "treasury_tax",
- ProtobufFieldName: "treasury_tax",
- ProtobufType: "float",
- ProtobufPos: 17,
- },
- },
- }
- // TableName sets the insert table name for this struct type
- func (s *Sale) TableName() string {
- return "sale"
- }
- // BeforeSave invoked before saving, return an error if field is not populated.
- func (s *Sale) BeforeSave(*gorm.DB) error {
- return nil
- }
- // Prepare invoked before saving, can be used to populate fields etc.
- func (s *Sale) Prepare() {
- }
- // Validate invoked before performing action, return an error if field is not populated.
- func (s *Sale) Validate(action Action) error {
- return nil
- }
- // TableInfo return table meta data
- func (s *Sale) TableInfo() *TableInfo {
- return saleTableInfo
- }
|