omnix-sopiga/services/template-service/domain/order.go

31 lines
527 B
Go
Raw Permalink Normal View History

2026-08-07 12:21:42 +07:00
package domain
import (
"fmt"
"time"
)
type Order struct {
OrderID string
CustomerID string
Amount float64
CreatedAt time.Time
}
func (o *Order) Validate() error {
if o.OrderID == "" {
return fmt.Errorf("order_id is required")
}
if o.CustomerID == "" {
return fmt.Errorf("customer_id is required")
}
if o.Amount <= 0 {
return fmt.Errorf("amount must be positive")
}
return nil
}
func (o *Order) NaturalKey() string {
return fmt.Sprintf("%s_%s_%d", o.OrderID, o.CustomerID, o.CreatedAt.Unix())
}