Files
wagfarm/wagfarm-api/models/log_models.go
2025-04-14 17:07:12 +02:00

60 lines
2.2 KiB
Go

package models
type Log struct {
ID uint `gorm:"primaryKey"`
Name string `gorm:"not null"`
Notes string `gorm:"not null"`
LogType string `gorm:"not null"`
Date Datetime.Time `gorm:"type:date;default:CURRENT_DATE"not null`
Duration float64 `gorm:"not null"` // in hours
VisibiltyID uint `gorm:"not null"`
Visibility Visibility `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"`
}
type _LogMetadata struct {
ID uint `gorm:"primaryKey"`
LogID uint `gorm:"not null"`
Log Log `gorm:"foreignKey:LogID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"`
}
type _FieldWorkLog struct {
_LogMetadata
WorkedAreaPercentage float64 `gorm:"not null"`
MachineID uint `gorm:"not null"`
Machine Machine `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"`
}
type SeedingLog struct {
_FieldWorkLog
SeedID uint `gorm:"not null"`
Seed Seed `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"`
TechniqueID uint `gorm:"not null"`
Technique SeedingTechnique `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"`
Amount float64 `gorm:"not null"` // in units/ha
ConditionsID uint `gorm:"not null"`
Conditions SeedingCondition `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"`
}
type FertilizingLog struct {
_FieldWorkLog
FertilizerID uint `gorm:"not null"`
Fertilizer Fertilizer `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"`
Amount float64 `gorm:"not null"` // in units of the fertilizer
}
type CropProtectionLog struct {
_FieldWorkLog
PesticideID uint `gorm:"not null"`
Pesticide Pesticide `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"`
Amount float64 `gorm:"not null"` // in units of the pesticide
PerformedByID uint `gorm:"not null"`
PerformedBy Worker `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"`
}
type HarvestLog struct {
_FieldWorkLog
ProductID uint `gorm:"not null"`
Product Product `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"`
Amount float64 `gorm:"not null"` // in units of the product
}