2024-02-22 10:18:59 +01:00
|
|
|
// Define all Database Models here
|
|
|
|
package db
|
|
|
|
|
2024-02-22 20:52:37 +01:00
|
|
|
import (
|
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
2024-02-22 10:18:59 +01:00
|
|
|
|
|
|
|
type User struct {
|
|
|
|
gorm.Model
|
|
|
|
Name string `gorm:"unique;index"`
|
|
|
|
PassHash string
|
|
|
|
Email string
|
|
|
|
DisplayName string
|
|
|
|
Groups []Group `gorm:"many2many:user_groups"`
|
|
|
|
Admin bool
|
|
|
|
}
|
|
|
|
|
|
|
|
type Group struct {
|
|
|
|
gorm.Model
|
|
|
|
Name string `grom:"unique;index"`
|
|
|
|
DisplayName string
|
|
|
|
Users []User `gorm:"many2many:user_groups"`
|
|
|
|
}
|
2024-02-22 20:52:37 +01:00
|
|
|
|
|
|
|
type Subnet struct {
|
|
|
|
gorm.Model
|
|
|
|
Name string `grom:"unique;index"`
|
|
|
|
DisplayName string
|
|
|
|
VLAN int
|
|
|
|
IPv4Net string
|
|
|
|
IPv6Net string
|
|
|
|
LocationID uint
|
2024-02-23 11:22:28 +01:00
|
|
|
Comment string
|
2024-02-22 20:52:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type Location struct {
|
|
|
|
gorm.Model
|
|
|
|
Name string
|
|
|
|
Comment string
|
|
|
|
Subnets []Subnet
|
|
|
|
}
|
|
|
|
|
|
|
|
type Address struct {
|
|
|
|
gorm.Model
|
|
|
|
Name string
|
|
|
|
Comment string
|
|
|
|
IPv4Address string
|
|
|
|
IPv6Address string
|
|
|
|
MACAddress string
|
|
|
|
DNSName string
|
|
|
|
DeviceID uint
|
|
|
|
SubnetID uint
|
|
|
|
}
|
|
|
|
|
|
|
|
type Device struct {
|
|
|
|
gorm.Model
|
|
|
|
Name string
|
|
|
|
Comment string
|
|
|
|
Addresses []Address
|
|
|
|
}
|