first commit, i i have no idea what i have done

This commit is contained in:
tdv
2025-08-31 22:42:08 +03:00
commit c5632f6a37
177 changed files with 9173 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
package models
import "time"
type Device struct {
GUID string `gorm:"primaryKey"`
Name string `gorm:"size:255;not null"`
Users []User `gorm:"many2many:user_devices;joinForeignKey:ID;joinReferences:GUID"`
Records []Record `gorm:"foreignKey:DeviceGUID;references:GUID;constraint:OnDelete:CASCADE"`
CreatedAt time.Time
UpdatedAt time.Time
}

View File

@@ -0,0 +1,13 @@
package models
import "time"
type Record struct {
ID uint `gorm:"primaryKey"`
DeviceGUID string `gorm:"index;size:64;not null"`
StartedAt int64 `gorm:"not null"`
StoppedAt int64 `gorm:"not null"`
ObjectKey string `gorm:"size:512;not null"`
CreatedAt time.Time
UpdatedAt time.Time
}

View File

@@ -0,0 +1,20 @@
package models
import "time"
type Role string
const (
RoleAdmin Role = "admin"
RoleUser Role = "user"
)
type User struct {
ID uint `gorm:"primaryKey"`
Username string `gorm:"uniqueIndex;size:255;not null"`
Password string `gorm:"not null"`
Role Role `gorm:"type:varchar(16);not null;default:'user'"`
Devices []Device `gorm:"many2many:user_devices;joinForeignKey:ID;joinReferences:GUID"`
CreatedAt time.Time
UpdatedAt time.Time
}