final project structure
This commit is contained in:
30
wagfarm-api/asset/base/model.go
Normal file
30
wagfarm-api/asset/base/model.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package base
|
||||
|
||||
type Asset struct {
|
||||
ID uint `gorm:"primaryKey`
|
||||
Name string `gorm:"not null"`
|
||||
Notes string
|
||||
}
|
||||
|
||||
func (a Asset) GetID() uint { return a.ID }
|
||||
|
||||
type Resource struct {
|
||||
Asset
|
||||
UnitID uint `gorm:"not null"`
|
||||
Unit unit.Unit `gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
|
||||
Cost decimal.Decimal `gorm:"not null; type:decimal(10,2);"` // in euro/unit
|
||||
}
|
||||
|
||||
type BoughtResource struct {
|
||||
Resource
|
||||
BuyDate Datetime.Time `gorm:"type:date;default:CURRENT_DATE"`
|
||||
BoughtFromID uint `gorm:"not null"`
|
||||
BoughtFrom Seller `gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
|
||||
}
|
||||
|
||||
type SoldResource struct {
|
||||
Resource
|
||||
SaleDate Datetime.Time `gorm:"type:date;default:CURRENT_DATE"`
|
||||
SoldToID uint `gorm:"not null"`
|
||||
SoldTo Customer `gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
|
||||
}
|
||||
Reference in New Issue
Block a user