mirror of
https://github.com/ForFarmTeam/ForFarm.git
synced 2025-12-19 22:14:08 +01:00
add domain farm,cropland & update plant
This commit is contained in:
parent
1839f8dfc0
commit
8dbc7102ff
36
backend/internal/domain/cropland.go
Normal file
36
backend/internal/domain/cropland.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package domain
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
validation "github.com/go-ozzo/ozzo-validation/v4"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Cropland struct {
|
||||||
|
UUID string
|
||||||
|
Name string
|
||||||
|
Status string
|
||||||
|
Priority int
|
||||||
|
LandSize float64
|
||||||
|
GrowthStage string
|
||||||
|
PlantID string
|
||||||
|
FarmID string
|
||||||
|
CreatedAt time.Time
|
||||||
|
UpdatedAt time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Cropland) Validate() error {
|
||||||
|
return validation.ValidateStruct(c,
|
||||||
|
validation.Field(&c.Name, validation.Required),
|
||||||
|
validation.Field(&c.Status, validation.Required),
|
||||||
|
validation.Field(&c.GrowthStage, validation.Required),
|
||||||
|
validation.Field(&c.LandSize, validation.Required),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
type CroplandRepository interface {
|
||||||
|
GetByID(context.Context, string) (Cropland, error)
|
||||||
|
CreateOrUpdate(context.Context, *Cropland) error
|
||||||
|
// Delete(context.Context, string) error
|
||||||
|
}
|
||||||
33
backend/internal/domain/farm.go
Normal file
33
backend/internal/domain/farm.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package domain
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
validation "github.com/go-ozzo/ozzo-validation/v4"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Farm struct {
|
||||||
|
UUID string
|
||||||
|
Name string
|
||||||
|
Lat float64
|
||||||
|
Lon float64
|
||||||
|
CreatedAt time.Time
|
||||||
|
UpdatedAt time.Time
|
||||||
|
OwnerID string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *Farm) Validate() error {
|
||||||
|
return validation.ValidateStruct(f,
|
||||||
|
validation.Field(&f.Name, validation.Required),
|
||||||
|
validation.Field(&f.Lat, validation.Required),
|
||||||
|
validation.Field(&f.Lon, validation.Required),
|
||||||
|
validation.Field(&f.OwnerID, validation.Required),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
type FarmRepository interface {
|
||||||
|
GetByID(context.Context, string) (Farm, error)
|
||||||
|
CreateOrUpdate(context.Context, *Farm) error
|
||||||
|
// Delete(context.Context, string) error
|
||||||
|
}
|
||||||
@ -45,7 +45,7 @@ func (p *Plant) Validate() error {
|
|||||||
type PlantRepository interface {
|
type PlantRepository interface {
|
||||||
GetByUUID(context.Context, string) (Plant, error)
|
GetByUUID(context.Context, string) (Plant, error)
|
||||||
GetAll(context.Context) ([]Plant, error)
|
GetAll(context.Context) ([]Plant, error)
|
||||||
//Create(context.Context, *Plant) error
|
Create(context.Context, *Plant) error
|
||||||
//Update(context.Context, *Plant) error
|
Update(context.Context, *Plant) error
|
||||||
//Delete(context.Context, string) error
|
Delete(context.Context, string) error
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user