trying around with different routing and controller structures
This commit is contained in:
67
wagfarm-api/models/logs.go
Normal file
67
wagfarm-api/models/logs.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package models
|
||||
|
||||
var LogModels = []interface{}{
|
||||
&Log{},
|
||||
&SeedingLog{},
|
||||
&FertilizingLog{},
|
||||
&CropProtectionLog{},
|
||||
&HarvestLog{},
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user