final project structure
This commit is contained in:
31
wagfarm-api/log/base/model.go
Normal file
31
wagfarm-api/log/base/model.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package base
|
||||
|
||||
import "time"
|
||||
|
||||
type BaseLog struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
Name string `gorm:"not null"`
|
||||
Notes string `gorm:"not null"`
|
||||
LogType string `gorm:"not null"`
|
||||
Date time.Time `gorm:"default:CURRENT_TIME"`
|
||||
Duration float64 `gorm:"not null"` // in hours
|
||||
VisibiltyID uint `gorm:"not null"`
|
||||
Visibility taxonomy.Visibility `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"`
|
||||
}
|
||||
|
||||
func (l BaseLog) GetID() uint { return l.ID }
|
||||
|
||||
type ExtendedLog struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
LogID uint `gorm:"not null"`
|
||||
BaseLog BaseLog `gorm:"foreignKey:LogID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"`
|
||||
}
|
||||
|
||||
func (l ExtendedLog) GetID() uint { return l.ID }
|
||||
|
||||
type FieldWorkLog struct {
|
||||
ExtendedLog
|
||||
WorkedAreaPercentage float64 `gorm:"not null"`
|
||||
MachineID uint `gorm:"not null"`
|
||||
Machine asset.Machine `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"`
|
||||
}
|
||||
11
wagfarm-api/log/base/route.go
Normal file
11
wagfarm-api/log/base/route.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"wagfarm-api/generic"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func RegisterRoutes(rg *gin.RouterGroup) {
|
||||
generic.RegisterCRUDRoutes(rg, generic.DefaultCRUDController[BaseLog]())
|
||||
}
|
||||
Reference in New Issue
Block a user