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` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(128) COLLATE utf8mb4_bin NOT NULL, `status` enum('stable','blocked') COLLATE utf8mb4_bin NOT NULL DEFAULT 'stable', `email` varchar(256) COLLATE utf8mb4_bin NOT NULL, `password` varchar(256) COLLATE utf8mb4_bin NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `deleted_at` timestamp NULL DEFAULT NULL, `phone` varchar(128) COLLATE utf8mb4_bin NOT NULL, `position` varchar(128) COLLATE utf8mb4_bin NOT NULL COMMENT '직책\n', `chargeof` varchar(128) COLLATE utf8mb4_bin NOT NULL COMMENT '담당업무', `team` varchar(128) COLLATE utf8mb4_bin NOT NULL COMMENT '소속(혹은 팀)\n', PRIMARY KEY (`id`), UNIQUE KEY `email_UNIQUE` (`email`), UNIQUE KEY `id_UNIQUE` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin JSON Sample ------------------------------------- { "id": 54, "name": "hZMeeyVVvQOGMhiGuJDVOVJlf", "status": "wLnXGWqWvFoAqLuuHpiJbXMRm", "email": "fjuKmMpcvMsOHjNXdvkGgAJRD", "password": "qULEnYAYAgpZmnEXbSuDAwVxh", "created_at": "2283-01-17T06:58:38.684502583+09:00", "updated_at": "2228-10-19T06:29:45.563913436+09:00", "deleted_at": "2078-11-18T01:47:30.911309112+09:00", "phone": "PVXHCxKkXNbFcNynvnMDECMdj", "position": "twEDuIAMswAxifODXmgDDlWtM", "chargeof": "ITwnLAYECkXnaoYNsJxlJCITq", "team": "dxkChksflqMuGvtaBpAHHLVsW"} Comments ------------------------------------- [ 0] column is set for unsigned */ // Admin struct is a row record of the admin table in the metarare database type Admin 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] name varchar(128) null: false primary: false isArray: false auto: false col: varchar len: 128 default: [] Name string `gorm:"column:name;type:varchar;size:128;" json:"name"` //[ 2] status char(7) null: false primary: false isArray: false auto: false col: char len: 7 default: [stable] Status string `gorm:"column:status;type:char;size:7;default:stable;" json:"status"` //[ 3] email varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: [] Email string `gorm:"column:email;type:varchar;size:256;" json:"email"` //[ 4] password varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: [] Password string `gorm:"column:password;type:varchar;size:256;" json:"password"` //[ 5] 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"` //[ 6] 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"` //[ 7] 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"` //[ 8] phone varchar(128) null: false primary: false isArray: false auto: false col: varchar len: 128 default: [] Phone string `gorm:"column:phone;type:varchar;size:128;" json:"phone"` //[ 9] position varchar(128) null: false primary: false isArray: false auto: false col: varchar len: 128 default: [] Position string `gorm:"column:position;type:varchar;size:128;" json:"position"` // 직책\n //[10] chargeof varchar(128) null: false primary: false isArray: false auto: false col: varchar len: 128 default: [] Chargeof string `gorm:"column:chargeof;type:varchar;size:128;" json:"chargeof"` // 담당업무 //[11] team varchar(128) null: false primary: false isArray: false auto: false col: varchar len: 128 default: [] Team string `gorm:"column:team;type:varchar;size:128;" json:"team"` // 소속(혹은 팀)\n AdminPermission AdminPermission } var adminTableInfo = &TableInfo{ Name: "admin", 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: "name", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(128)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 128, GoFieldName: "Name", GoFieldType: "string", JSONFieldName: "name", ProtobufFieldName: "name", ProtobufType: "string", ProtobufPos: 2, }, &ColumnInfo{ Index: 2, Name: "status", Comment: ``, 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: 3, }, &ColumnInfo{ Index: 3, Name: "email", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(256)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 256, GoFieldName: "Email", GoFieldType: "string", JSONFieldName: "email", ProtobufFieldName: "email", ProtobufType: "string", ProtobufPos: 4, }, &ColumnInfo{ Index: 4, Name: "password", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(256)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 256, GoFieldName: "Password", GoFieldType: "string", JSONFieldName: "password", ProtobufFieldName: "password", ProtobufType: "string", ProtobufPos: 5, }, &ColumnInfo{ Index: 5, 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: 6, }, &ColumnInfo{ Index: 6, 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: 7, }, &ColumnInfo{ Index: 7, 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: 8, }, &ColumnInfo{ Index: 8, Name: "phone", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(128)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 128, GoFieldName: "Phone", GoFieldType: "string", JSONFieldName: "phone", ProtobufFieldName: "phone", ProtobufType: "string", ProtobufPos: 9, }, &ColumnInfo{ Index: 9, Name: "position", Comment: `직책\n`, Notes: ``, Nullable: false, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(128)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 128, GoFieldName: "Position", GoFieldType: "string", JSONFieldName: "position", ProtobufFieldName: "position", ProtobufType: "string", ProtobufPos: 10, }, &ColumnInfo{ Index: 10, Name: "chargeof", Comment: `담당업무`, Notes: ``, Nullable: false, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(128)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 128, GoFieldName: "Chargeof", GoFieldType: "string", JSONFieldName: "chargeof", ProtobufFieldName: "chargeof", ProtobufType: "string", ProtobufPos: 11, }, &ColumnInfo{ Index: 11, Name: "team", Comment: `소속(혹은 팀)\n`, Notes: ``, Nullable: false, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(128)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 128, GoFieldName: "Team", GoFieldType: "string", JSONFieldName: "team", ProtobufFieldName: "team", ProtobufType: "string", ProtobufPos: 12, }, }, } // TableName sets the insert table name for this struct type func (a *Admin) TableName() string { return "admin" } // BeforeSave invoked before saving, return an error if field is not populated. func (a *Admin) BeforeSave(*gorm.DB) error { return nil } // Prepare invoked before saving, can be used to populate fields etc. func (a *Admin) Prepare() { } // Validate invoked before performing action, return an error if field is not populated. func (a *Admin) Validate(action Action) error { return nil } // TableInfo return table meta data func (a *Admin) TableInfo() *TableInfo { return adminTableInfo }