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 `admin_permission` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `admin_id` bigint(20) unsigned NOT NULL, `user` tinyint(4) NOT NULL DEFAULT '0', `collection` tinyint(4) NOT NULL DEFAULT '0', `system` tinyint(4) NOT NULL DEFAULT '0', `admin` tinyint(4) NOT NULL DEFAULT '0', `log` 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, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`), KEY `fk_admin_permission_admin_idx` (`admin_id`), CONSTRAINT `fk_admin_permission_admin` FOREIGN KEY (`admin_id`) REFERENCES `admin` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin JSON Sample ------------------------------------- { "id": 46, "admin_id": 92, "user": 62, "collection": 83, "system": 22, "admin": 93, "log": 19, "created_at": "2180-07-06T16:12:34.96190249+09:00", "updated_at": "2180-10-15T05:55:35.50110137+09:00", "deleted_at": "2104-09-07T06:08:47.931462761+09:00"} Comments ------------------------------------- [ 0] column is set for unsigned [ 1] column is set for unsigned */ // AdminPermission struct is a row record of the admin_permission table in the metarare database type AdminPermission 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] admin_id ubigint null: false primary: false isArray: false auto: false col: ubigint len: -1 default: [] AdminID uint64 `gorm:"column:admin_id;type:ubigint;" json:"admin_id"` //[ 2] user tinyint null: false primary: false isArray: false auto: false col: tinyint len: -1 default: [0] User int32 `gorm:"column:user;type:tinyint;default:0;" json:"user"` //[ 3] collection tinyint null: false primary: false isArray: false auto: false col: tinyint len: -1 default: [0] Collection int32 `gorm:"column:collection;type:tinyint;default:0;" json:"collection"` //[ 4] system tinyint null: false primary: false isArray: false auto: false col: tinyint len: -1 default: [0] System int32 `gorm:"column:system;type:tinyint;default:0;" json:"system"` //[ 5] admin tinyint null: false primary: false isArray: false auto: false col: tinyint len: -1 default: [0] Admin int32 `gorm:"column:admin;type:tinyint;default:0;" json:"admin"` //[ 6] log tinyint null: false primary: false isArray: false auto: false col: tinyint len: -1 default: [0] Log int32 `gorm:"column:log;type:tinyint;default:0;" json:"log"` //[ 7] 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"` //[ 8] 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"` //[ 9] 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"` } var admin_permissionTableInfo = &TableInfo{ Name: "admin_permission", 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: "admin_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: "AdminID", GoFieldType: "uint64", JSONFieldName: "admin_id", ProtobufFieldName: "admin_id", ProtobufType: "uint64", ProtobufPos: 2, }, &ColumnInfo{ Index: 2, Name: "user", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "tinyint", DatabaseTypePretty: "tinyint", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "tinyint", ColumnLength: -1, GoFieldName: "User", GoFieldType: "int32", JSONFieldName: "user", ProtobufFieldName: "user", ProtobufType: "int32", ProtobufPos: 3, }, &ColumnInfo{ Index: 3, Name: "collection", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "tinyint", DatabaseTypePretty: "tinyint", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "tinyint", ColumnLength: -1, GoFieldName: "Collection", GoFieldType: "int32", JSONFieldName: "collection", ProtobufFieldName: "collection", ProtobufType: "int32", ProtobufPos: 4, }, &ColumnInfo{ Index: 4, Name: "system", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "tinyint", DatabaseTypePretty: "tinyint", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "tinyint", ColumnLength: -1, GoFieldName: "System", GoFieldType: "int32", JSONFieldName: "system", ProtobufFieldName: "system", ProtobufType: "int32", ProtobufPos: 5, }, &ColumnInfo{ Index: 5, Name: "admin", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "tinyint", DatabaseTypePretty: "tinyint", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "tinyint", ColumnLength: -1, GoFieldName: "Admin", GoFieldType: "int32", JSONFieldName: "admin", ProtobufFieldName: "admin", ProtobufType: "int32", ProtobufPos: 6, }, &ColumnInfo{ Index: 6, Name: "log", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "tinyint", DatabaseTypePretty: "tinyint", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "tinyint", ColumnLength: -1, GoFieldName: "Log", GoFieldType: "int32", JSONFieldName: "log", ProtobufFieldName: "log", ProtobufType: "int32", ProtobufPos: 7, }, &ColumnInfo{ Index: 7, 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: 8, }, &ColumnInfo{ Index: 8, 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: 9, }, &ColumnInfo{ Index: 9, 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: 10, }, }, } // TableName sets the insert table name for this struct type func (a *AdminPermission) TableName() string { return "admin_permission" } // BeforeSave invoked before saving, return an error if field is not populated. func (a *AdminPermission) BeforeSave(*gorm.DB) error { return nil } // Prepare invoked before saving, can be used to populate fields etc. func (a *AdminPermission) Prepare() { } // Validate invoked before performing action, return an error if field is not populated. func (a *AdminPermission) Validate(action Action) error { return nil } // TableInfo return table meta data func (a *AdminPermission) TableInfo() *TableInfo { return admin_permissionTableInfo }