datamodel done without validators

This commit is contained in:
2025-04-17 12:33:53 +02:00
parent 284a40fac2
commit 5337da219e
58 changed files with 575 additions and 227 deletions

View File

@@ -0,0 +1,39 @@
package base
import (
"time"
"wagfarm-api/taxonomy/customer"
"wagfarm-api/taxonomy/seller"
"wagfarm-api/taxonomy/unit"
"github.com/shopspring/decimal"
)
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 time.Time `gorm:"not null"`
BoughtFromID uint `gorm:"not null"`
BoughtFrom seller.Seller `gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}
type SoldResource struct {
Resource
SaleDate time.Time `gorm:"not null"`
SoldToID uint `gorm:"not null"`
SoldTo customer.Customer `gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}