package model import ( "git.getensh.com/common/gopkgsv2/database" "gorm.io/gorm" ) type AdmKeyManagementModel interface{ Get(db *gorm.DB) (*AdmKeyManagement, error) } type AdmKeyManagement struct { ID int64 `gorm:"column:id" json:"id"` Key string `gorm:"column:key" json:"key"` Desc string `gorm:"column:desc" json:"desc"` CreatedAt int64 `gorm:"column:created_at" json:"created_at"` UpdatedAt int64 `gorm:"column:updated_at" json:"updated_at"` } type defaultAdmKeyManagementModel struct { tableName string fields string } func NewAdmKeyManagementModel() AdmKeyManagementModel { return &defaultAdmKeyManagementModel{ tableName: "t_adm_key_management", fields: "id, `key`, `desc`, created_at, updated_at", } } func (d *defaultAdmKeyManagementModel) Get(db *gorm.DB) (*AdmKeyManagement, error){ var res AdmKeyManagement err := database.Get(db, &res, database.Option{ TableName: d.tableName, Fields: d.fields, }) return &res, err }