package model import ( "os" "time" "gorm.io/gorm" ) type Role struct { ID int64 `gorm:"type:int(20);autoIncrement;comment:ID;" json:"id"` Name string `gorm:"type:varchar(255);comment:名称;" json:"account"` Permissions string `gorm:"type:text;comment:权限列表;nullable;" json:"permissions"` Users []User `gorm:"many2many:user_role;" json:"users"` DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"-"` CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"` } func (u *Role) AfterFind(tx *gorm.DB) (err error) { return } func (u *Role) TableName() string { dbPrefix := os.Getenv("DB_PREFIX") return dbPrefix + "role" }