123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- 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 `log` (
- `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
- `log_relation_id` bigint(20) unsigned NOT NULL,
- `type` enum('create','sell','purchase','transfer','burn','bid','like','withdrawal') COLLATE utf8mb4_bin NOT NULL,
- `sale_uid` varchar(256) COLLATE utf8mb4_bin DEFAULT NULL,
- `to_address` varchar(256) COLLATE utf8mb4_bin DEFAULT NULL,
- `from_address` varchar(256) COLLATE utf8mb4_bin DEFAULT NULL,
- `price` double DEFAULT NULL,
- `is_cancel` tinyint(4) DEFAULT '0',
- `tx` varchar(256) COLLATE utf8mb4_bin DEFAULT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `id_UNIQUE` (`id`),
- KEY `fk_template_table_log_relation1_idx` (`log_relation_id`),
- CONSTRAINT `fk_template_table_log_relation1` FOREIGN KEY (`log_relation_id`) REFERENCES `log_relation` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
- JSON Sample
- -------------------------------------
- { "id": 72, "log_relation_id": 85, "type": "NGHjuUSYhitQnJbfXRnYANIlV", "sale_uid": "metxsoQWKaotFRqVDcrqKUiCk", "to_address": "NrfxseBemNEwiBiARaxIwoFPS", "from_address": "bJyumtYuACeSDgTxnkZjHuFDS", "price": 0.33262747080622135, "is_cancel": 15, "tx": "bjTncXoWtdbUkDlwwBvQcXflt"}
- Comments
- -------------------------------------
- [ 0] column is set for unsigned
- [ 1] column is set for unsigned
- */
- // Log struct is a row record of the log table in the metarare database
- type Log 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] log_relation_id ubigint null: false primary: false isArray: false auto: false col: ubigint len: -1 default: []
- LogRelationID uint64 `gorm:"column:log_relation_id;type:ubigint;" json:"log_relation_id"`
- //[ 2] type char(10) null: false primary: false isArray: false auto: false col: char len: 10 default: []
- Type string `gorm:"column:type;type:char;size:10;" json:"type"`
- //[ 3] sale_uid varchar(256) null: true primary: false isArray: false auto: false col: varchar len: 256 default: []
- SaleUID null.String `gorm:"column:sale_uid;type:varchar;size:256;" json:"sale_uid"`
- //[ 4] to_address varchar(256) null: true primary: false isArray: false auto: false col: varchar len: 256 default: []
- ToAddress null.String `gorm:"column:to_address;type:varchar;size:256;" json:"to_address"`
- //[ 5] from_address varchar(256) null: true primary: false isArray: false auto: false col: varchar len: 256 default: []
- FromAddress null.String `gorm:"column:from_address;type:varchar;size:256;" json:"from_address"`
- //[ 6] 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"`
- //[ 7] is_cancel tinyint null: true primary: false isArray: false auto: false col: tinyint len: -1 default: [0]
- IsCancel null.Int `gorm:"column:is_cancel;type:tinyint;default:0;" json:"is_cancel"`
- //[ 8] tx varchar(256) null: true primary: false isArray: false auto: false col: varchar len: 256 default: []
- Tx null.String `gorm:"column:tx;type:varchar;size:256;" json:"tx"`
- }
- var logTableInfo = &TableInfo{
- Name: "log",
- 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: "log_relation_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: "LogRelationID",
- GoFieldType: "uint64",
- JSONFieldName: "log_relation_id",
- ProtobufFieldName: "log_relation_id",
- ProtobufType: "uint64",
- ProtobufPos: 2,
- },
- &ColumnInfo{
- Index: 2,
- Name: "type",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "char",
- DatabaseTypePretty: "char(10)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "char",
- ColumnLength: 10,
- GoFieldName: "Type",
- GoFieldType: "string",
- JSONFieldName: "type",
- ProtobufFieldName: "type",
- ProtobufType: "string",
- ProtobufPos: 3,
- },
- &ColumnInfo{
- Index: 3,
- Name: "sale_uid",
- Comment: ``,
- Notes: ``,
- Nullable: true,
- DatabaseTypeName: "varchar",
- DatabaseTypePretty: "varchar(256)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "varchar",
- ColumnLength: 256,
- GoFieldName: "SaleUID",
- GoFieldType: "null.String",
- JSONFieldName: "sale_uid",
- ProtobufFieldName: "sale_uid",
- ProtobufType: "string",
- ProtobufPos: 4,
- },
- &ColumnInfo{
- Index: 4,
- Name: "to_address",
- Comment: ``,
- Notes: ``,
- Nullable: true,
- DatabaseTypeName: "varchar",
- DatabaseTypePretty: "varchar(256)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "varchar",
- ColumnLength: 256,
- GoFieldName: "ToAddress",
- GoFieldType: "null.String",
- JSONFieldName: "to_address",
- ProtobufFieldName: "to_address",
- ProtobufType: "string",
- ProtobufPos: 5,
- },
- &ColumnInfo{
- Index: 5,
- Name: "from_address",
- Comment: ``,
- Notes: ``,
- Nullable: true,
- DatabaseTypeName: "varchar",
- DatabaseTypePretty: "varchar(256)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "varchar",
- ColumnLength: 256,
- GoFieldName: "FromAddress",
- GoFieldType: "null.String",
- JSONFieldName: "from_address",
- ProtobufFieldName: "from_address",
- ProtobufType: "string",
- ProtobufPos: 6,
- },
- &ColumnInfo{
- Index: 6,
- 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: 7,
- },
- &ColumnInfo{
- Index: 7,
- Name: "is_cancel",
- Comment: ``,
- Notes: ``,
- Nullable: true,
- DatabaseTypeName: "tinyint",
- DatabaseTypePretty: "tinyint",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "tinyint",
- ColumnLength: -1,
- GoFieldName: "IsCancel",
- GoFieldType: "null.Int",
- JSONFieldName: "is_cancel",
- ProtobufFieldName: "is_cancel",
- ProtobufType: "int32",
- ProtobufPos: 8,
- },
- &ColumnInfo{
- Index: 8,
- Name: "tx",
- Comment: ``,
- Notes: ``,
- Nullable: true,
- DatabaseTypeName: "varchar",
- DatabaseTypePretty: "varchar(256)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "varchar",
- ColumnLength: 256,
- GoFieldName: "Tx",
- GoFieldType: "null.String",
- JSONFieldName: "tx",
- ProtobufFieldName: "tx",
- ProtobufType: "string",
- ProtobufPos: 9,
- },
- },
- }
- // TableName sets the insert table name for this struct type
- func (l *Log) TableName() string {
- return "log"
- }
- // BeforeSave invoked before saving, return an error if field is not populated.
- func (l *Log) BeforeSave(*gorm.DB) error {
- return nil
- }
- // Prepare invoked before saving, can be used to populate fields etc.
- func (l *Log) Prepare() {
- }
- // Validate invoked before performing action, return an error if field is not populated.
- func (l *Log) Validate(action Action) error {
- return nil
- }
- // TableInfo return table meta data
- func (l *Log) TableInfo() *TableInfo {
- return logTableInfo
- }
|