123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363 |
- 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 `collection` (
- `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
- `contract_address` varchar(256) COLLATE utf8mb4_bin NOT NULL,
- `owner_address` varchar(256) COLLATE utf8mb4_bin NOT NULL,
- `network` enum('eth','bsc','mr') COLLATE utf8mb4_bin NOT NULL DEFAULT 'eth',
- `symbol` varchar(256) COLLATE utf8mb4_bin NOT NULL,
- `is_official` tinyint(4) NOT NULL DEFAULT '0',
- `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- `deleted_at` timestamp NULL DEFAULT NULL,
- `curating_number` int(10) unsigned DEFAULT NULL,
- `status` enum('visible','invisible') COLLATE utf8mb4_bin NOT NULL DEFAULT 'visible',
- `type` enum('erc721','erc1155') COLLATE utf8mb4_bin NOT NULL DEFAULT 'erc721',
- PRIMARY KEY (`id`),
- UNIQUE KEY `id_UNIQUE` (`id`)
- ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='삭제하는 케이스가 없기 때문에 상태 값이 invisible로 바뀌면 로그에는 burn으로 남긴다.'
- JSON Sample
- -------------------------------------
- { "id": 79, "contract_address": "ysNXAZoApFBnnjQFxAjORtqJN", "owner_address": "EXeaFJWTPSgSluAJfmoXeDPMb", "network": "vfBkrnYyTOOWPphHPASmtuifG", "symbol": "ScDyxLFbxTJKetOuZRIODhRQN", "is_official": 76, "created_at": "2117-11-23T16:07:05.493163554+09:00", "updated_at": "2105-02-21T07:13:07.571526828+09:00", "deleted_at": "2296-02-12T01:57:37.014082293+09:00", "curating_number": 54, "status": "AsGHGEntGgGWpvEUOnMVuIAlw", "type": "mlVxMeZYaUyBcRGTtRbHAtByu"}
- Comments
- -------------------------------------
- [ 0] column is set for unsigned
- [ 9] column is set for unsigned
- */
- // Collection struct is a row record of the collection table in the metarare database
- type Collection 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] contract_address varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: []
- ContractAddress string `gorm:"column:contract_address;type:varchar;size:256;" json:"contract_address"`
- //[ 2] owner_address varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: []
- OwnerAddress string `gorm:"column:owner_address;type:varchar;size:256;" json:"owner_address"`
- //[ 3] network char(3) null: false primary: false isArray: false auto: false col: char len: 3 default: [eth]
- Network string `gorm:"column:network;type:char;size:3;default:eth;" json:"network"`
- //[ 4] symbol varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: []
- Symbol string `gorm:"column:symbol;type:varchar;size:256;" json:"symbol"`
- //[ 5] is_official tinyint null: false primary: false isArray: false auto: false col: tinyint len: -1 default: [0]
- IsOfficial int32 `gorm:"column:is_official;type:tinyint;default:0;" json:"is_official"`
- //[ 6] 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"`
- //[ 7] 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"`
- //[ 8] 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"`
- //[ 9] curating_number uint null: true primary: false isArray: false auto: false col: uint len: -1 default: []
- CuratingNumber null.Int `gorm:"column:curating_number;type:uint;" json:"curating_number"`
- //[10] status char(9) null: false primary: false isArray: false auto: false col: char len: 9 default: [visible]
- Status string `gorm:"column:status;type:char;size:9;default:visible;" json:"status"`
- //[11] type char(7) null: false primary: false isArray: false auto: false col: char len: 7 default: [erc721]
- Type string `gorm:"column:type;type:char;size:7;default:erc721;" json:"type"`
- }
- var collectionTableInfo = &TableInfo{
- Name: "collection",
- 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: "contract_address",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "varchar",
- DatabaseTypePretty: "varchar(256)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "varchar",
- ColumnLength: 256,
- GoFieldName: "ContractAddress",
- GoFieldType: "string",
- JSONFieldName: "contract_address",
- ProtobufFieldName: "contract_address",
- ProtobufType: "string",
- ProtobufPos: 2,
- },
- &ColumnInfo{
- Index: 2,
- Name: "owner_address",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "varchar",
- DatabaseTypePretty: "varchar(256)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "varchar",
- ColumnLength: 256,
- GoFieldName: "OwnerAddress",
- GoFieldType: "string",
- JSONFieldName: "owner_address",
- ProtobufFieldName: "owner_address",
- ProtobufType: "string",
- ProtobufPos: 3,
- },
- &ColumnInfo{
- Index: 3,
- Name: "network",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "char",
- DatabaseTypePretty: "char(3)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "char",
- ColumnLength: 3,
- GoFieldName: "Network",
- GoFieldType: "string",
- JSONFieldName: "network",
- ProtobufFieldName: "network",
- ProtobufType: "string",
- ProtobufPos: 4,
- },
- &ColumnInfo{
- Index: 4,
- Name: "symbol",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "varchar",
- DatabaseTypePretty: "varchar(256)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "varchar",
- ColumnLength: 256,
- GoFieldName: "Symbol",
- GoFieldType: "string",
- JSONFieldName: "symbol",
- ProtobufFieldName: "symbol",
- ProtobufType: "string",
- ProtobufPos: 5,
- },
- &ColumnInfo{
- Index: 5,
- Name: "is_official",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "tinyint",
- DatabaseTypePretty: "tinyint",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "tinyint",
- ColumnLength: -1,
- GoFieldName: "IsOfficial",
- GoFieldType: "int32",
- JSONFieldName: "is_official",
- ProtobufFieldName: "is_official",
- ProtobufType: "int32",
- ProtobufPos: 6,
- },
- &ColumnInfo{
- Index: 6,
- 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: 7,
- },
- &ColumnInfo{
- Index: 7,
- 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: 8,
- },
- &ColumnInfo{
- Index: 8,
- 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: 9,
- },
- &ColumnInfo{
- Index: 9,
- Name: "curating_number",
- Comment: ``,
- Notes: `column is set for unsigned`,
- Nullable: true,
- DatabaseTypeName: "uint",
- DatabaseTypePretty: "uint",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "uint",
- ColumnLength: -1,
- GoFieldName: "CuratingNumber",
- GoFieldType: "null.Int",
- JSONFieldName: "curating_number",
- ProtobufFieldName: "curating_number",
- ProtobufType: "uint32",
- ProtobufPos: 10,
- },
- &ColumnInfo{
- Index: 10,
- Name: "status",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "char",
- DatabaseTypePretty: "char(9)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "char",
- ColumnLength: 9,
- GoFieldName: "Status",
- GoFieldType: "string",
- JSONFieldName: "status",
- ProtobufFieldName: "status",
- ProtobufType: "string",
- ProtobufPos: 11,
- },
- &ColumnInfo{
- Index: 11,
- Name: "type",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "char",
- DatabaseTypePretty: "char(7)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "char",
- ColumnLength: 7,
- GoFieldName: "Type",
- GoFieldType: "string",
- JSONFieldName: "type",
- ProtobufFieldName: "type",
- ProtobufType: "string",
- ProtobufPos: 12,
- },
- },
- }
- // TableName sets the insert table name for this struct type
- func (c *Collection) TableName() string {
- return "collection"
- }
- // BeforeSave invoked before saving, return an error if field is not populated.
- func (c *Collection) BeforeSave(*gorm.DB) error {
- return nil
- }
- // Prepare invoked before saving, can be used to populate fields etc.
- func (c *Collection) Prepare() {
- }
- // Validate invoked before performing action, return an error if field is not populated.
- func (c *Collection) Validate(action Action) error {
- return nil
- }
- // TableInfo return table meta data
- func (c *Collection) TableInfo() *TableInfo {
- return collectionTableInfo
- }
|