package db import ( "gorm.io/gorm" "time" ) type ClorthoModel struct { ID uint `gorm:"primarykey" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt,omitempty"` } type User struct { ClorthoModel Username string `gorm:"unique;not null" json:"username"` PasswordHash *string `json:"-"` DisplayName *string `json:"displayName"` Admin bool `gorm:"default:false" json:"admin"` Keys []Key `gorm:"foreignKey:UserID" json:"keys"` Groups []Group `gorm:"many2many:groups_users;" json:"groups"` } type UserSession struct { ClorthoModel UserID uint `gorm:"not null" json:"-"` User *User `gorm:"foreignKey:UserID" json:"user"` } type Key struct { ClorthoModel UserID uint `gorm:"not null" json:"-"` User *User `gorm:"foreignKey:UserID" json:"user"` Name string `json:"name"` Content string `gorm:"not null" json:"-" json:"content"` } type Group struct { ClorthoModel Name string `gorm:"unique;not null" json:"name"` Users []User `gorm:"many2many:groups_users;" json:"users"` } type System struct { ClorthoModel Name string `gorm:"unique;not null" json:"name"` Groups []SystemGroup `gorm:"many2many:systems_system_groups;" json:"groups"` } type SystemGroup struct { ClorthoModel Name string `gorm:"unique;not null" json:"name"` Systems []System `gorm:"many2many:systems_system_groups;" json:"systems"` } type Grant struct { ClorthoModel UserID uint `gorm:"not null" json:"-"` User User `gorm:"foreignKey:UserID" json:"user"` SystemID uint `gorm:"not null" json:"-"` System *System `gorm:"foreignKey:SystemID" json:"system"` GrantedByID uint `gorm:"not null" json:"-"` GrantedBy *User `gorm:"foreignKey:GrantedByID" json:"grantedBy"` }